CoolQ Socket API written in VC++.
一个酷Q的 Socket 代理插件
org.dazzyd.cqsocketapi.cpk
into CoolQ app folder.Default Config.ini
file will generate in org.dazzyd.cqsocketapi
folder.
You can write your owned bot based on my qqbot in Python 3.
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.
org.dazzyd.cqsocketapi.cpk
复制粘贴到酷Q的app文件夹中。编辑Config.ini文件可以改变一些设置,文件位于org.dazzyd.cqsocketapi
文件夹中。
[Server]
SERVER_PORT=11235 // 监听端口
CLIENT_SIZE=32 // 最大允许客户端数量
CLIENT_TIMEOUT=300 // 客户端超时时间(秒)
FRAME_PREFIX_SIZE=256 // 数据包前缀大小(字节)
FRAME_PAYLOAD_SIZE=32768 // 数据包数据区域大小(字节)
插件(服务端)与客户端(您自己实现的,下同)进行UDP数据包交换。
插件默认监听本地11235端口。
客户端需要每隔至少5分钟发送一次ClientHello
信息以保持连接。
该信息需包含客户端的端口。
注:所有文本数据需经过GB18030编码的base64转码后进行传送
单个UDP数据包由前缀与多个由空格作为间隔的区域组成。
Frame = Prefix (max 256) + Payload (max 32768)
Prefix = 'ServerHello'
Payload = ClientTimeout + PrefixSize + PlayloadSize + FrameSize
Prefix = 'PrivateMessage'
Payload = QQ + EncodedText
Prefix = 'GroupMessage'
Payload = GroupID + QQ + EncodedText
Prefix = 'DiscussMessage'
Payload = DiscussID + QQ + EncodedText
Prefix = 'GroupMemberDecrease'
Payload = GroupID + QQ + OperatedQQ
Prefix = 'GroupMemberIncrease'
Payload = GroupID + QQ + OperatedQQ
EncodedText = base64_encode( GB18030_encode( text ) )
Frame = Prefix (max 256) + Payload (max 32768)
Prefix = 'ClientHello'
Payload = Port
Prefix = 'PrivateMessage'
Payload = QQ + EncodedText
Prefix = 'GroupMessage'
Payload = GroupID + EncodedText
Prefix = 'DiscussMessage'
Payload = DiscussID + EncodedText
EncodedText = base64_encode( GB18030_encode( text ) )
GroupMessage 123456 10000 dGVzdCCy4srU