Skip to content

Commit

Permalink
1.13.7 修复@好友昵称重复bug (#209) (#210)
Browse files Browse the repository at this point in the history
* 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 <atorber@163.com>

* 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 <104893934+choogoo@users.noreply.github.com>

* 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 <atorber@163.com>

* 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 <104893934+choogoo@users.noreply.github.com>

---------

Co-authored-by: choogoo <104893934+choogoo@users.noreply.github.com>
  • Loading branch information
atorber and choogoo authored Jan 19, 2024
1 parent e1bbc73 commit 8a81ab0
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 19 deletions.
Binary file removed examples/file/794b2b037b3b0eade767c776076fbeb8.png
Binary file not shown.
Binary file removed examples/file/951bc21aeb9b85dc2ceab655afca8a1a.png
Binary file not shown.
Binary file removed examples/file/c621679153cb48c4c5a196044cff422c.png
Binary file not shown.
9 changes: 9 additions & 0 deletions examples/ripe-wechaty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ async function onLogin (user: Contact) {
log.info('联系人数量:', contactList.length)
const friends = contactList.filter(c => c.friend())
log.info('好友数量:', friends.length)

// 发送@好友消息
// const room = await bot.Room.find({topic:'大师是群主'})
// const contact = await bot.Contact.find({name:'luyuchao'})
// log.info('room:', room)
// if(room && contact){
// const contacts:Contact[]= [contact]
// await room.say(new Date().toLocaleString() + ':瓦力上线了!', ...contacts)
// }
}

function onLogout (user: Contact) {
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-puppet-xp",
"version": "1.13.6",
"version": "1.13.7",
"description": "Puppet XP for Wechaty",
"type": "module",
"exports": {
Expand Down Expand Up @@ -98,5 +98,10 @@
"publishConfig": {
"access": "public",
"tag": "latest"
},
"git": {
"scripts": {
"pre-push": "npx git-scripts-pre-push"
}
}
}
20 changes: 11 additions & 9 deletions src/init-agent-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var wxOffsets = {
},
// send text
sendText: {
WX_SEND_TEXT_OFFSET: 0xce6c80
WX_SEND_TEXT_OFFSET: 0xCE6C80
},
// ocr
ocr: {
Expand Down Expand Up @@ -611,16 +611,16 @@ var modifyContactRemark = function (wxid, remark) {
// console.log('nativeFunction:', nativeFunction)
try {
var success = nativeFunction();
console.log('设置备注好友备注结果:', success);
// console.log('设置备注好友备注结果:', success)
return success;
}
catch (e) {
console.error('[设置备注好友备注]Error during modifyContactRemark nativeFunction function execution:', e);
// console.error('[设置好友备注]Error during modifyContactRemark nativeFunction function execution:', e);
return false;
}
};
// 示例调用
modifyContactRemark("tyutluyc", "超哥2");
// modifyContactRemark("ledongmao", "超哥2");
// 获取群组列表
var getChatroomMemberInfoFunction = function () {
// 获取群组列表地址
Expand Down Expand Up @@ -784,7 +784,7 @@ var delMemberFromChatRoom = function (chat_room_id, wxids) {
return false;
}
};
// delMemberFromChatRoom('21341182572@chatroom', ['tyutluyc'])
// delMemberFromChatRoom('21341182572@chatroom', ['ledongmao'])
// 未完成,添加群成员
/**21:16:16 ERR SidecarBody [SCRIPT_MESSAGRE_HANDLER_SYMBOL]() MessageType.Error: Error: stack overflow
at addMemberToChatRoom (/script1.js:946)
Expand Down Expand Up @@ -851,7 +851,7 @@ var addMemberToChatRoom = function (chat_room_id, wxids) {
return false;
}
};
// addMemberToChatRoom('21341182572@chatroom', ['tyutluyc'])
// addMemberToChatRoom('21341182572@chatroom', ['ledongmao'])
// 邀请群成员
/**21:30:53 ERR SidecarBody [SCRIPT_MESSAGRE_HANDLER_SYMBOL]() MessageType.Error: Error: access violation accessing 0x2538fc20
at inviteMemberToChatRoom (/script1.js:1040)
Expand Down Expand Up @@ -935,7 +935,7 @@ var inviteMemberToChatRoom = function (chat_room_id, wxids) {
return false;
}
};
// inviteMemberToChatRoom('21341182572@chatroom', ['tyutluyc'])
// inviteMemberToChatRoom('21341182572@chatroom', ['ledongmao'])
// 发送文本消息
var sendMsgNativeFunction = function (talkerId, content) {
var txtAsm = Memory.alloc(Process.pageSize);
Expand Down Expand Up @@ -989,7 +989,9 @@ var ecxBuffer;
var sendAtMsgNativeFunction = (function (roomId, text, contactId, nickname) {
asmAtMsg = Memory.alloc(Process.pageSize);
ecxBuffer = Memory.alloc(0x3b0);
var atContent = '@' + nickname + ' ' + text;
var atContent = text;
if (!text.startsWith('@' + nickname))
atContent = '@' + nickname + ' ' + text;
roomid_ = initStruct(roomId);
wxid_ = initidStruct(contactId);
msg_ = initmsgStruct(atContent);
Expand Down Expand Up @@ -1023,7 +1025,7 @@ var sendAtMsgNativeFunction = (function (roomId, text, contactId, nickname) {
var nativeativeFunction = new NativeFunction(ptr(asmAtMsg), 'void', []);
nativeativeFunction();
});
sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'tyutluyc', '超哥');
// sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'atorber', '超哥')
// 发送图片消息
var sendPicMsgNativeFunction = function (contactId, path) {
var picAsm = Memory.alloc(Process.pageSize);
Expand Down
11 changes: 6 additions & 5 deletions src/init-agent-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const wxOffsets = {
},
// send text
sendText: {
WX_SEND_TEXT_OFFSET: 0xce6c80,
WX_SEND_TEXT_OFFSET: 0xCE6C80,
},
// ocr
ocr: {
Expand Down Expand Up @@ -1116,12 +1116,13 @@ const sendMsgNativeFunction = (talkerId: any, content: any) => {
let asmAtMsg:any = null
let roomid_, msg_, wxid_, atid_
let ecxBuffer
const sendAtMsgNativeFunction = ((roomId, text, contactId,nickname) => {
const sendAtMsgNativeFunction = ((roomId, text, contactId, nickname) => {

asmAtMsg = Memory.alloc(Process.pageSize)
ecxBuffer = Memory.alloc(0x3b0)

const atContent = '@'+nickname+' '+text
let atContent = text

if(!text.startsWith('@'+nickname)) atContent = '@'+nickname+' '+text

roomid_ = initStruct(roomId)
wxid_ = initidStruct(contactId)
Expand Down Expand Up @@ -1169,7 +1170,7 @@ const sendAtMsgNativeFunction = ((roomId, text, contactId,nickname) => {

})

// sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'ledongmao', '超哥')
// sendAtMsgNativeFunction('21341182572@chatroom', new Date().toLocaleString(), 'atorber', '超哥')

// 发送图片消息
const sendPicMsgNativeFunction = (contactId: string, path: string) => {
Expand Down
6 changes: 3 additions & 3 deletions src/puppet-xp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,7 @@ class PuppetXp extends PUPPET.Puppet {
count++
}
await fsPromise.access(dataPath)

// log.info('图片解密文件路径:', dataPath, true)

const imageInfo = ImageDecrypt(dataPath, messageId)
// const imageInfo = ImageDecrypt('C:\\Users\\choogoo\\Documents\\WeChat Files\\wxid_pnza7m7kf9tq12\\FileStorage\\Image\\Thumb\\2022-05\\e83b2aea275460cd50352559e040a2f8_t.dat','cl34vez850000gkmw2macd3dw')

Expand Down Expand Up @@ -906,7 +904,9 @@ class PuppetXp extends PUPPET.Puppet {
mentionIdList?: string[],
): Promise<void> {
if (conversationId.split('@').length === 2 && mentionIdList && mentionIdList[0]) {
await this.sidecar.sendAtMsg(conversationId, text, mentionIdList[0])
const wxid = mentionIdList[0]
const contact = await this.contactRawPayload(wxid)
await this.sidecar.sendAtMsg(conversationId, text, mentionIdList[0], contact.name)
} else {
await this.sidecar.sendMsg(conversationId, text)
}
Expand Down
3 changes: 2 additions & 1 deletion src/wechat-sidecar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ class WeChatSidecar extends SidecarBody {
roomId:string,
text: string,
contactId: string,
): Promise<string> { return Ret(roomId, text, contactId) }
nickname: string,
): Promise<string> { return Ret(roomId, text, contactId, nickname) }

@Call(agentTarget('SendMiniProgramNativeFunction'))
SendMiniProgram (
Expand Down

0 comments on commit 8a81ab0

Please sign in to comment.