Skip to content

Commit 8a81ab0

Browse files
atorberchoogoo
andauthored
1.13.7 修复@好友昵称重复bug (#209) (#210)
* 1.13.7 修复@好友昵称重复bug (#209) * 3.9.2.23 init (#180) * 3.9.2.23 initt * Update init-agent-script.js * 3.9.2.23 adapter * 3.9.2.23 init (#182) * 3.9.2.23 initt * Update init-agent-script.js * 3.9.2.23 adapter * 适配3.9.2.23 * Delete agent-script-3.9.2.23-new.js * 适配3.9.2.23 (#185) * 3.9.2.23 initt * Update init-agent-script.js * 3.9.2.23 adapter * 适配3.9.2.23 * Delete agent-script-3.9.2.23-new.js * 适配3.9.2.23 --------- Co-authored-by: LuChao <[email protected]> * add 1.3.0 illustrate * Update README.md * Update README.md * add demo * 1.13.1 * 1.13.1 * 1.13.2 dev * 增加扫码登录、检测登录状态 * 增加登入登出事件 * 增加ts改造init * 1.13.2 * 1.13.2 * 1.13.2 * 1.13.2 * 1.13.2 1. 修复获取群成员昵称乱码 * Update .npmignore * Update .gitignore * 1.13.2删除agent的ts文件 * 1.13.4 * 1.13.5 * Update init-agent-script.ts * 1.13.5 * 1.13.6 * del png file * Update init-agent-script.js * 1.13.7 修复@好友出现两个昵称的bug --------- Co-authored-by: choogoo <[email protected]> * 1.13.7 (#211) * 3.9.2.23 init (#180) * 3.9.2.23 initt * Update init-agent-script.js * 3.9.2.23 adapter * 3.9.2.23 init (#182) * 3.9.2.23 initt * Update init-agent-script.js * 3.9.2.23 adapter * 适配3.9.2.23 * Delete agent-script-3.9.2.23-new.js * 适配3.9.2.23 (#185) * 3.9.2.23 initt * Update init-agent-script.js * 3.9.2.23 adapter * 适配3.9.2.23 * Delete agent-script-3.9.2.23-new.js * 适配3.9.2.23 --------- Co-authored-by: LuChao <[email protected]> * add 1.3.0 illustrate * Update README.md * Update README.md * add demo * 1.13.1 * 1.13.1 * 1.13.2 dev * 增加扫码登录、检测登录状态 * 增加登入登出事件 * 增加ts改造init * 1.13.2 * 1.13.2 * 1.13.2 * 1.13.2 * 1.13.2 1. 修复获取群成员昵称乱码 * Update .npmignore * Update .gitignore * 1.13.2删除agent的ts文件 * 1.13.4 * 1.13.5 * Update init-agent-script.ts * 1.13.5 * 1.13.6 * del png file * Update init-agent-script.js * 1.13.7 修复@好友出现两个昵称的bug * 1.13.7 --------- Co-authored-by: choogoo <[email protected]> --------- Co-authored-by: choogoo <[email protected]>
1 parent e1bbc73 commit 8a81ab0

9 files changed

+37
-19
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

examples/ripe-wechaty.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ async function onLogin (user: Contact) {
3939
log.info('联系人数量:', contactList.length)
4040
const friends = contactList.filter(c => c.friend())
4141
log.info('好友数量:', friends.length)
42+
43+
// 发送@好友消息
44+
// const room = await bot.Room.find({topic:'大师是群主'})
45+
// const contact = await bot.Contact.find({name:'luyuchao'})
46+
// log.info('room:', room)
47+
// if(room && contact){
48+
// const contacts:Contact[]= [contact]
49+
// await room.say(new Date().toLocaleString() + ':瓦力上线了!', ...contacts)
50+
// }
4251
}
4352

4453
function onLogout (user: Contact) {

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wechaty-puppet-xp",
3-
"version": "1.13.6",
3+
"version": "1.13.7",
44
"description": "Puppet XP for Wechaty",
55
"type": "module",
66
"exports": {
@@ -98,5 +98,10 @@
9898
"publishConfig": {
9999
"access": "public",
100100
"tag": "latest"
101+
},
102+
"git": {
103+
"scripts": {
104+
"pre-push": "npx git-scripts-pre-push"
105+
}
101106
}
102107
}

src/init-agent-script.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ var wxOffsets = {
143143
},
144144
// send text
145145
sendText: {
146-
WX_SEND_TEXT_OFFSET: 0xce6c80
146+
WX_SEND_TEXT_OFFSET: 0xCE6C80
147147
},
148148
// ocr
149149
ocr: {
@@ -611,16 +611,16 @@ var modifyContactRemark = function (wxid, remark) {
611611
// console.log('nativeFunction:', nativeFunction)
612612
try {
613613
var success = nativeFunction();
614-
console.log('设置备注好友备注结果:', success);
614+
// console.log('设置备注好友备注结果:', success)
615615
return success;
616616
}
617617
catch (e) {
618-
console.error('[设置备注好友备注]Error during modifyContactRemark nativeFunction function execution:', e);
618+
// console.error('[设置好友备注]Error during modifyContactRemark nativeFunction function execution:', e);
619619
return false;
620620
}
621621
};
622622
// 示例调用
623-
modifyContactRemark("tyutluyc", "超哥2");
623+
// modifyContactRemark("ledongmao", "超哥2");
624624
// 获取群组列表
625625
var getChatroomMemberInfoFunction = function () {
626626
// 获取群组列表地址
@@ -784,7 +784,7 @@ var delMemberFromChatRoom = function (chat_room_id, wxids) {
784784
return false;
785785
}
786786
};
787-
// delMemberFromChatRoom('21341182572@chatroom', ['tyutluyc'])
787+
// delMemberFromChatRoom('21341182572@chatroom', ['ledongmao'])
788788
// 未完成,添加群成员
789789
/**21:16:16 ERR SidecarBody [SCRIPT_MESSAGRE_HANDLER_SYMBOL]() MessageType.Error: Error: stack overflow
790790
at addMemberToChatRoom (/script1.js:946)
@@ -851,7 +851,7 @@ var addMemberToChatRoom = function (chat_room_id, wxids) {
851851
return false;
852852
}
853853
};
854-
// addMemberToChatRoom('21341182572@chatroom', ['tyutluyc'])
854+
// addMemberToChatRoom('21341182572@chatroom', ['ledongmao'])
855855
// 邀请群成员
856856
/**21:30:53 ERR SidecarBody [SCRIPT_MESSAGRE_HANDLER_SYMBOL]() MessageType.Error: Error: access violation accessing 0x2538fc20
857857
at inviteMemberToChatRoom (/script1.js:1040)
@@ -935,7 +935,7 @@ var inviteMemberToChatRoom = function (chat_room_id, wxids) {
935935
return false;
936936
}
937937
};
938-
// inviteMemberToChatRoom('21341182572@chatroom', ['tyutluyc'])
938+
// inviteMemberToChatRoom('21341182572@chatroom', ['ledongmao'])
939939
// 发送文本消息
940940
var sendMsgNativeFunction = function (talkerId, content) {
941941
var txtAsm = Memory.alloc(Process.pageSize);
@@ -989,7 +989,9 @@ var ecxBuffer;
989989
var sendAtMsgNativeFunction = (function (roomId, text, contactId, nickname) {
990990
asmAtMsg = Memory.alloc(Process.pageSize);
991991
ecxBuffer = Memory.alloc(0x3b0);
992-
var atContent = '@' + nickname + ' ' + text;
992+
var atContent = text;
993+
if (!text.startsWith('@' + nickname))
994+
atContent = '@' + nickname + ' ' + text;
993995
roomid_ = initStruct(roomId);
994996
wxid_ = initidStruct(contactId);
995997
msg_ = initmsgStruct(atContent);
@@ -1023,7 +1025,7 @@ var sendAtMsgNativeFunction = (function (roomId, text, contactId, nickname) {
10231025
var nativeativeFunction = new NativeFunction(ptr(asmAtMsg), 'void', []);
10241026
nativeativeFunction();
10251027
});
1026-
sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'tyutluyc', '超哥');
1028+
// sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'atorber', '超哥')
10271029
// 发送图片消息
10281030
var sendPicMsgNativeFunction = function (contactId, path) {
10291031
var picAsm = Memory.alloc(Process.pageSize);

src/init-agent-script.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const wxOffsets = {
146146
},
147147
// send text
148148
sendText: {
149-
WX_SEND_TEXT_OFFSET: 0xce6c80,
149+
WX_SEND_TEXT_OFFSET: 0xCE6C80,
150150
},
151151
// ocr
152152
ocr: {
@@ -1116,12 +1116,13 @@ const sendMsgNativeFunction = (talkerId: any, content: any) => {
11161116
let asmAtMsg:any = null
11171117
let roomid_, msg_, wxid_, atid_
11181118
let ecxBuffer
1119-
const sendAtMsgNativeFunction = ((roomId, text, contactId,nickname) => {
1119+
const sendAtMsgNativeFunction = ((roomId, text, contactId, nickname) => {
11201120

11211121
asmAtMsg = Memory.alloc(Process.pageSize)
11221122
ecxBuffer = Memory.alloc(0x3b0)
1123-
1124-
const atContent = '@'+nickname+' '+text
1123+
let atContent = text
1124+
1125+
if(!text.startsWith('@'+nickname)) atContent = '@'+nickname+' '+text
11251126

11261127
roomid_ = initStruct(roomId)
11271128
wxid_ = initidStruct(contactId)
@@ -1169,7 +1170,7 @@ const sendAtMsgNativeFunction = ((roomId, text, contactId,nickname) => {
11691170

11701171
})
11711172

1172-
// sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'ledongmao', '超哥')
1173+
// sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'atorber', '超哥')
11731174

11741175
// 发送图片消息
11751176
const sendPicMsgNativeFunction = (contactId: string, path: string) => {

src/puppet-xp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,7 @@ class PuppetXp extends PUPPET.Puppet {
765765
count++
766766
}
767767
await fsPromise.access(dataPath)
768-
769768
// log.info('图片解密文件路径:', dataPath, true)
770-
771769
const imageInfo = ImageDecrypt(dataPath, messageId)
772770
// const imageInfo = ImageDecrypt('C:\\Users\\choogoo\\Documents\\WeChat Files\\wxid_pnza7m7kf9tq12\\FileStorage\\Image\\Thumb\\2022-05\\e83b2aea275460cd50352559e040a2f8_t.dat','cl34vez850000gkmw2macd3dw')
773771

@@ -906,7 +904,9 @@ class PuppetXp extends PUPPET.Puppet {
906904
mentionIdList?: string[],
907905
): Promise<void> {
908906
if (conversationId.split('@').length === 2 && mentionIdList && mentionIdList[0]) {
909-
await this.sidecar.sendAtMsg(conversationId, text, mentionIdList[0])
907+
const wxid = mentionIdList[0]
908+
const contact = await this.contactRawPayload(wxid)
909+
await this.sidecar.sendAtMsg(conversationId, text, mentionIdList[0], contact.name)
910910
} else {
911911
await this.sidecar.sendMsg(conversationId, text)
912912
}

src/wechat-sidecar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ class WeChatSidecar extends SidecarBody {
183183
roomId:string,
184184
text: string,
185185
contactId: string,
186-
): Promise<string> { return Ret(roomId, text, contactId) }
186+
nickname: string,
187+
): Promise<string> { return Ret(roomId, text, contactId, nickname) }
187188

188189
@Call(agentTarget('SendMiniProgramNativeFunction'))
189190
SendMiniProgram (

0 commit comments

Comments
 (0)