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

Commit

Permalink
Merge pull request #32 from takayama-lily/dev
Browse files Browse the repository at this point in the history
-
  • Loading branch information
takayama-lily authored Sep 12, 2020
2 parents 8d66769 + 56068f9 commit 97ac505
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 29 deletions.
23 changes: 12 additions & 11 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,23 @@ client.on("system.login", (data)=>{
## Event: `message`

+ `message.private`
+ `message.private.friend`
+ `message.private.single` 单向好友(对方未加你)
+ `message.private.friend` 好友消息
+ `message.private.single` 单向好友消息(对方未加你)
+ `message.private.group` 群临时会话
+ `message.private.other`
+ `message.private.other` 其他临时会话
+ `message.group`
+ `message.group.normal`
+ `message.group.anonymous`
+ `message.group.normal` 群消息
+ `message.group.anonymous` 群匿名消息

----

## Event: `request`

+ `request.friend`
+ `request.friend.add`
+ `request.friend.add` 好友请求
+ `request.group`
+ `request.group.add`
+ `request.group.invite`
+ 字段 `role` 表示邀请者权限
+ `request.group.add` 加群请求
+ `request.group.invite` 加群邀请

----

Expand All @@ -137,17 +136,19 @@ client.on("system.login", (data)=>{

+ `notice.friend`
+ `notice.friend.increase` 好友增加
+ `notice.friend.decrease` 好友减少(被拉黑或自己删除)
+ `notice.friend.recall` 消息撤回事件
+ `notice.group`
+ `notice.group.increase` 群员增加
+ `notice.group.decrease` 群员减少
+ 字段 `dismiss` 表示是否是解散
+ `notice.group.recall` 消息撤回事件
+ `notice.group.admin` 管理变更
+ `notice.group.admin` 管理变更事件
+ `notice.group.ban` 群禁言事件
+ `notice.group.transfer` 群转让事件
+ `notice.group.notice` 收到群公告
+ `notice.group.file` 收到群文件
+ `notice.group.name` 群名变更事件
+ `notice.group.title` 群头衔变更事件

----

Expand Down
6 changes: 3 additions & 3 deletions docs/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

|[好友功能]|API|事件|
|-|-|-|
|好友列表||◯(好友增加)|
|好友列表||◯(好友增减)|
|处理申请|||
|撤回消息|||

Expand All @@ -24,12 +24,12 @@
|[群功能]|API|事件|
|-|-|-|
|群列表||◯(群增减)|
|成员列表||◯(成员增加)|
|成员列表||◯(成员增减)|
|踢人|||
|禁言|||
|撤回|||
|修改名片|||
|修改群名|||
|修改群名|||
|群公告|||
|其他设置|||
|群文件|||
Expand Down
62 changes: 49 additions & 13 deletions lib/incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ function decodeNewFriendResponse(blob, c) {
nickname: v.msg.reqUinNick,
source: v.msg.msgSource,
comment: v.msg.msgAdditional,
sex: "unknown",
sex: v.msg.reqUinGender===0?"male":(v.msg.reqUinGender===1?"famale":"unknown"),
age: v.msg.reqUinAge,
flag: common.genFriendRequestFlag(user_id, v.msgSeq),
});
Expand Down Expand Up @@ -610,7 +610,7 @@ function decodeNewGroupResponse(blob, c) {

//----------------------------------------------------------------------------------------------------

async function decodeFriendAndGroupEvent(blob, c) {
function decodeFriendAndGroupEvent(blob, c) {
if (!c.sync_finished) return;
const nested = jce.decodeWrapper(blob);
const parent = jce.decode(nested);
Expand All @@ -623,7 +623,6 @@ async function decodeFriendAndGroupEvent(blob, c) {
const list = parent[2];
for (let v of list) {
v = jce.decode(v);
// common.log(v)
if (v[2] === 528) {
let data = jce.decode(v[6]);
if (data[0] === 0x8A || data[0] === 0x8B) {
Expand All @@ -636,18 +635,52 @@ async function decodeFriendAndGroupEvent(blob, c) {
});
} else if (data[0] === 0xB3) {
data = pb.decode("SubB3", data[10]);
await c.getFriendList(true);
event.emit(c, "notice.friend.increase", {
user_id: toInt(data.msgAddFrdNotify.uin), nickname: data.msgAddFrdNotify.nick
});
(async()=>{
await c.getFriendList(true);
event.emit(c, "notice.friend.increase", {
user_id: toInt(data.msgAddFrdNotify.uin), nickname: data.msgAddFrdNotify.nick
});
})();
} else if (data[0] === 0xD4) {
data = pb.decode("SubD4", data[10])
const group_id = toInt(data.uin);
c.group_list.delete(group_id);
c.group_member_list.delete(group_id);
}
if (data[0] === 0x3B) {
// 显示头衔 <Buffer 08 01 10 9f dd 95 a1 04 18 01>
// 隐藏头衔 <Buffer 08 01 10 9f dd 95 a1 04 18 00>
}
if (data[0] === 0x44) {}
if (data[0] === 0x27) {
// 修改群名和群头像 删除好友
data = pb.decode("Sub27", data[10]);
if (data.sub27.type === 80) {
const o = data.sub27.msgNewGrpName;
const group_id = toInt(o.groupCode);
try {
c.group_list.get(group_id).group_name = o.entry.name;
} catch (e) {}
event.emit(c, "notice.group.name", {
group_id,
operator_id: toInt(o.authUin),
new_name: o.entry.name
});
}
if (data.sub27.type === 5) {
let user_id = toInt(data.sub27.msgDelFrdNotify.uin), nickname = null;
try {
nickname = c.friend_list.get(user_id).nickname;
c.friend_list.delete(user_id);
} catch (e) {}
event.emit(c, "notice.friend.decrease", {
user_id, nickname
});
}
// 修改群名 <Buffer 0a 30 08 00 10 50 62 2a 08 9f dd 95 a1 04 12 16 08 01 12 12 e6 9c ba e5 99 a8 e4 ba ba e6 b5 8b e8 af 95 e7 be a4 18 9f dd 95 a1 04 20 f5 ef e8 b1 01>
// 加群头像 <Buffer 0a 1a 08 00 10 15 5a 14 08 01 10 9f dd 95 a1 04 18 9f dd 95 a1 04 20 f5 ef e8 b1 01>
// 好友减少 <Buffer 0a 0c 08 00 10 05 72 06 08 f5 ef e8 b1 01>
// 好友增加 <Buffer 0a 16 10 28 4a 12 0a 10 08 00 10 f5 ef e8 b1 01 1a 06 e9 ab 98 e5 b1 b1>
// 好友增加 <Buffer 0a 3e 10 07 a2 01 39 0a 31 08 f5 ef e8 b1 01 82 19 28 08 87 6a 12 23 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 14 more bytes>
}
} else if (v[2] === 732) {
const group_id = v[6].readUInt32BE();
Expand All @@ -669,8 +702,15 @@ async function decodeFriendAndGroupEvent(blob, c) {
group_id, user_id, operator_id, message_id
});
}
// 修改群头像和群名,是否展示群头衔事件是528
// if (v[6][4] === 0x14) {
// var a = v[6].slice(6).toString()
// common.log(a.toString())
// }
// <44 25 6e 9f>是群号 <16 3a 37 f5>是qq号
// <Buffer 44 25 6e 9f 0f 00 08 00 01 00 00 00 02 00 00> 群文件上传权限 允许所有人
// <Buffer 44 25 6e 9f 0f 00 08 00 03 00 00 00 02 00 00> 群文件上传权限 仅管理员
// <Buffer 44 25 6e 9f 0f 00 08 00 00 00 00 00 01 00 00> 群相册上传权限 允许所有人
// <Buffer 44 25 6e 9f 0f 00 08 00 01 00 00 00 01 00 00> 群相册上传权限 仅管理员
// 允许游客 <Buffer 44 25 6e 9f 06 01 16 3a 37 f5 01> 进入但不能发言
// 允许匿名 <Buffer 44 25 6e 9f 0e 01 16 3a 37 f5 00 00 00 00 00 01>
// 禁止匿名 <Buffer 44 25 6e 9f 0e 01 16 3a 37 f5 ff ff ff ff 00 01>
Expand All @@ -687,10 +727,6 @@ async function decodeFriendAndGroupEvent(blob, c) {
// 关互动标 <Buffer 44 25 6e 9f 10 00 22 08 18 10 af 8f e3 fa 05 18 ff ff ff ff 0f 20 9f dd 95 a1 04 68 17 a8 01 f5 ef e8 b1 01 f2 01 02 08 01>
// 展示等级 <Buffer 44 25 6e 9f 10 00 22 08 18 10 8d f4 e6 fa 05 18 ff ff ff ff 0f 20 9f dd 95 a1 04 68 17 a8 01 f5 ef e8 b1 01 f2 01 02 08 00>
// 隐藏等级 <Buffer 44 25 6e 9f 10 00 22 08 18 10 c0 f3 e6 fa 05 18 ff ff ff ff 0f 20 9f dd 95 a1 04 68 17 a8 01 f5 ef e8 b1 01 f2 01 02 10 01>
// <Buffer 44 25 6e 9f 0f 00 08 00 01 00 00 00 02 00 00> 群文件上传权限 允许所有人
// <Buffer 44 25 6e 9f 0f 00 08 00 03 00 00 00 02 00 00> 群文件上传权限 仅管理员
// <Buffer 44 25 6e 9f 0f 00 08 00 00 00 00 00 01 00 00> 群相册上传权限 允许所有人
// <Buffer 44 25 6e 9f 0f 00 08 00 01 00 00 00 01 00 00> 群相册上传权限 仅管理员
// 头衔变更 <Buffer 44 25 6e 9f 10 00 50 08 01 20 9f dd 95 a1 04 2a 44 12 3a e6 81 ad e5 96 9c e8 80 81 e5 a9 86 20 e1 b4 ae e1 b4 bc e1 b5 80 e2 81 b4 e8 8e b7 e5 be 97 ... 37 more bytes>
}
}
Expand Down
60 changes: 60 additions & 0 deletions lib/pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,66 @@ var $root = ($protobuf.roots["default"] || ($protobuf.roots["default"] = new $pr
}
}
},
Sub27: {
fields: {
sub27: {
type: "Sub27Entry",
id: 1
},
}
},
Sub27Entry: {
fields: {
type: {
type: "int32",
id: 2
},
msgNewGrpName: {
type: "Sub27NewGrpName",
id: 12
},
msgDelFrdNotify: {
type: "Sub27DelFrdNotify",
id: 14
},
}
},
Sub27NewGrpName: {
fields: {
groupUin: {
type: "int64",
id: 1
},
entry: {
type: "Sub27NewGrpNameEntry",
id: 2
},
groupCode: {
type: "int64",
id: 3
},
authUin: {
type: "int64",
id: 4
},
}
},
Sub27NewGrpNameEntry: {
fields: {
name: {
type: "string",
id: 2
},
}
},
Sub27DelFrdNotify: {
fields: {
uin: {
type: "int64",
id: 1
},
}
},
LongMsgDeleteReq: {
fields: {
msgResid: {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oicq",
"version": "1.3.6",
"version": "1.4.0",
"description": "QQ protocol!",
"main": "client.js",
"scripts": {
Expand Down

0 comments on commit 97ac505

Please sign in to comment.