Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.13.7 修复@好友昵称重复bug (#209) #210

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading