Skip to content

Commit b0d0077

Browse files
authored
Update CQCode.php
1 parent 16cff10 commit b0d0077

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

SDK/CQCode.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class CQCode{
66
public static function CQ($type, $argArray = NULL){
77
$code='[CQ:'.$type;
88
if(NULL !== $argArray) foreach($argArray as $key => $value){
9+
if($value === NULL) continue;
910
$code.= (','.$key.'='.self::EncodeCQCode($value));
1011
}
1112
$code.=']';
@@ -36,24 +37,27 @@ public static function Image($file){
3637
return self::CQ('image', ['file' => $file]);
3738
}
3839

39-
public static function Record($file){
40-
return self::CQ('record', ['file' => $file]);
40+
public static function Record($file, $magic = NULL){
41+
return self::CQ('record', [
42+
'file' => $file,
43+
'magic' => $magic,
44+
]);
4145
}
4246

43-
public static function Rps($type){
47+
public static function Rps($type = NULL){
4448
return self::CQ('rps', ['type' => $type]);
4549
}
4650

47-
public static function Dice($type){
51+
public static function Dice($type = NULL){
4852
return self::CQ('dice', ['type' => $type]);
4953
}
5054

5155
public static function Shake(){
5256
return self::CQ('shake');
5357
}
5458

55-
public static function Anonymous($ignore){
56-
return self::CQ('anonymous', $ignore?(['ignore' => 'true']):NULL);
59+
public static function Anonymous($ignore = NULL){
60+
return self::CQ('anonymous', ['ignore' => $ignore]);
5761
}
5862

5963
public static function Location($lat, $lon, $title, $content){
@@ -65,25 +69,26 @@ public static function Location($lat, $lon, $title, $content){
6569
]);
6670
}
6771

68-
public static function Music($type, $id){
72+
public static function Music($type, $id, $style = NULL){
6973
return self::CQ('music', [
7074
'type' => $type,
7175
'id' => $id,
76+
'style' => $style,
7277
]);
7378
}
7479

75-
public static function CustomMusic($audio, $url, $title, $content, $image){
80+
public static function CustomMusic($url, $audio, $title, $content = NULL, $image = NULL){
7681
return self::CQ('music', [
7782
'type' => 'custom',
78-
'audio' => $audio,
7983
'url' => $url,
84+
'audio' => $audio,
8085
'title' => $title,
8186
'content' => $content,
82-
'image' => $image
87+
'image' => $image,
8388
]);
8489
}
8590

86-
public static function Share($url, $title, $content, $image){
91+
public static function Share($url, $title, $content = NULL, $image = NULL){
8792
return self::CQ('share', [
8893
'url' => $url,
8994
'title' => $title,
@@ -93,6 +98,9 @@ public static function Share($url, $title, $content, $image){
9398
}
9499

95100
public static function EncodeCQCode($str){
101+
if($str === true) return 'true';
102+
if($str === false) return 'false';
103+
//if($str === NULL) return ?; //这种情况的处理待定
96104
return str_replace([
97105
'&',
98106
'[',

0 commit comments

Comments
 (0)