Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit c4a9719

Browse files
Merge pull request #88 from takayama-lily/dev
-
2 parents d5fd922 + 41274cd commit c4a9719

File tree

9 files changed

+729
-541
lines changed

9 files changed

+729
-541
lines changed

client.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ class AndroidClient extends Client {
149149

150150
this.on("error", (err)=>{
151151
this.logger.error(err.message);
152-
this.status = Client.INIT;
153152
});
154153
this.on("close", (e_flag)=>{
155154
this.read();

docs/project.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,32 @@
6565

6666
----
6767

68+
## 什么是CQ码?
69+
70+
CQ码是指字符串格式下用于表示多媒体内容的方式,形如:
71+
`[CQ:image,file=123.jpg]`
72+
`[CQ:at,qq=123456]`
73+
常用的有at、表情、图片、语音、音乐、分享等。
74+
因此混在字符串中的CQ码,以下字符会被转义:`[]&,`
75+
推荐使用数组格式的消息链,可以避免转义操作。
76+
6877
|[CQ码]|||说明|
6978
|-|-|-|-|
70-
|at|||[CQ:at,qq=123456,text=@ABC] text用来定义@不到时的输出|
71-
|face|◯|◯|表情,[CQ:face,id=104]
72-
|sface|||小表情(HD协议不支持)[CQ:sface,id=271,text=/吃瓜]|
79+
|at|||[CQ:at,qq=123456,text=@ABC,dummy=0]<br>text用来定义@不到时的输出<br>dummy设为1可以假@|
80+
|face|◯|◯|[CQ:face,id=104]
81+
|sface|||此表情HD协议不支持[CQ:sface,id=271,text=/吃瓜]|
7382
|bface|||原创表情,[CQ:bface,file=xxxxxxxx,text=摸头]|
74-
|dice&rps|||魔法表情骰子和猜拳:<br>[CQ:dice,id=1] ※id=1-6 不填则随机<br>[CQ:rps,id=1] ※id=1-3 分别对应1石头2剪刀3布|
83+
|dice&rps|||骰子和猜拳:<br>[CQ:dice,id=1]<br>[CQ:rps,id=1]|
7584
|image|||参考 [图片](https://github.com/howmanybots/onebot/blob/master/v11/specs/message/segment.md#%E5%9B%BE%E7%89%87)|
7685
|record|||语音,写法同image<br>支持任何格式的音频自动转amr(必须将 [ffmpeg](http://ffmpeg.org/download.html) 加入环境变量path)<br>linux下的ffmpeg不自带amr解码器,可能需要自行编译ffmpeg|
7786
|flash|||闪照,写法同image|
7887
|anonymous|||发匿名,[CQ:anonymous,ignore=1]<br>ignore可省略,为0时匿名失败不发送|
79-
|notice|||群公告[CQ:notice,title=群公告,content=xxxxxx]|
80-
|file|||群文件[CQ:file,url=xxxxxx,size=123456,md5=xxxxxx,duration=0,name=xxxxxx]|
88+
|notice|||群公告|
89+
|file|||群文件|
8190
|music|||
8291
|video|||
8392
|location|||[CQ:location,address=江西省九江市修水县,lat=29.063940,lng=114.339610]|
84-
|contact|||
85-
|anonymous|||
93+
|contact|◯|✕|联系人或群推荐
8694
|reply|||
87-
|share|||
95+
|share|◯|◯|链接分享
8896
|<s>node</s>|||<s>[CQ:node,uin=123456789,name=昵称,content=消息内容,time=时间戳]<br>time可省略,暂时只支持纯文本/s>|

lib/common.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,20 @@ function uin2code(groupUin) {
6262
return left * 1000000 + groupUin % 1000000;
6363
}
6464

65+
function escapeXml(xml) {
66+
return xml.replace(/[&"><]/g, function(s) {
67+
if (s === "&") return "&amp;";
68+
if (s === "<") return "&lt;";
69+
if (s === ">") return "&gt;";
70+
if (s === '"') return "&quot;";
71+
});
72+
}
73+
6574
function log(any) {
6675
console.log(util.inspect(any, {depth: 20, showHidden: false, maxArrayLength: 1000, maxStringLength: 5000}));
6776
}
6877

6978
module.exports = {
7079
uuid, md5, timestamp, checkUin, uinAutoCheck,
71-
log, code2uin, uin2code,
80+
log, code2uin, uin2code, escapeXml
7281
};

0 commit comments

Comments
 (0)