CoolQ Socket API written in VC++.
- Place
org.dazzyd.cqsocketapi.cpk
into CoolQ app folder. - Enable CQSocketAPI in CoolQ APP management window.
- Restart CoolQ.
You can write your owned bot based on my qqbot in Python 3.
Node.js的實現可參考附帶的QQBot.js。需要npm install --save-dev encoding
。
The communication between server and clients is sending UDP frame to each other.
The server listens on port 11235
.
Clients should send ClientHello
frame to inform server of client port.
ClientHello
frame must be sent on startup and every (at most) 5 minutes.
A UDP frame contains one Prefix and multiple Fields. Prefix and Fields are joined by one space.
Frame = Prefix (max 256) + Payload (max 32768)
一個Frame內部的各資訊以空白(U+0020)分隔。伺服端可接收以下訊息:
請加入資料型態信息
ServerHello
PrivateMessage
+ QQNum + EncodedText (Message) + SubType + SendTime + EncodedText (UserInfo)GroupMessage
+ GroupID + QQNum + EncodedText (Message) + SubType + SendTime + EncodedText (UserInfo)DiscussMessage
+ DiscussID + QQNum + EncodedText (Message) + SubType + SendTime + EncodedText (UserInfo)GroupAdmin
+ GroupId + SubType + QQNum + SendTime + EncodedText (UserInfo)GroupMemberDecrease
+ GroupID + AdminQQNum + OperatedQQNum + SubType + SendTime + EncodedText (Admin) + EncodedText (User)GroupMemberIncrease
+ GroupID + AdminQQNum + OperatedQQNum + SubType + SendTime + EncodedText (User)GroupMemberInfo
+ EncodedText (UserInfo)StrangerInfo
+ EncodedText (UserInfo)LoginNick
+ EncodedText (UserName)
其中:
EncodedText = base64_encode( GB18030_encode( text ) )
UserInfo的格式可參考附帶的QQBot.js。
GroupMessage 123456 10000 dGVzdCCy4srUILK7bmGBMIo3dmU=
應理解為:
{
"type": "GroupMessage",
"GroupID": 123456,
"QQNum": 10000,
"EncodedText": "dGVzdCCy4srUIG5hgTCKN3ZlW0NROmVtb2ppLGlkPTEyODE2Ml0="
}
由於輸入來自伺服器,GroupID
解讀為「來源群」。QQ中的很多ID,如QQ號、群號,都為正整數。
編碼的EncodedText
最终应解码至test 测试 naïve💢
,其中💢
(U+1F4A2)以CQ格式[CQ:emoji,id=128162]
呈現。
Frame = Prefix (max 256) + Payload (max 32768)
ClientHello
+ PortPrivateMessage
+ QQNum + EncodedTextGroupMessage
+ GroupID + EncodedTextDiscussMessage
+ DiscussID + EncodedTextGroupMemberInfo
+ GroupID + QQNum + IsNotCachedBoolean01
(0表示利用快取結果)StrangerInfo
+ QQNum + IsNotCachedBoolean01
LoginNick
其中:
EncodedText = base64_encode( GB18030_encode( text ) )
GroupMessage 123456 ZWZmaWNpZW5jeQ==
理解為:
{
"type": "GroupMessage",
"GroupID": 123456,
"base64Message": "ZWZmaWNpZW5jeQ=="
}
此為傳送到群號123456的群的一條信息,內容為efficiency
。
腾讯新闻可能会不定期向你的QQ推送新闻,其QQ号为2909288299。如果有需要处理私聊的程序,请注意处理或过滤腾讯新闻内容,以免因为自己QQ发布不良内容导致封号。