Skip to content

Commit

Permalink
1.13.1 (#193)
Browse files Browse the repository at this point in the history
* add 1.3.0 illustrate

* Update README.md

* Update README.md

* add demo

* 1.13.1

* 1.13.1
  • Loading branch information
atorber authored Nov 14, 2023
1 parent 3faaa0b commit de97586
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 49 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,22 @@ Puppet|xp👍|
登录事件|✅
依赖协议|Windows

## VERSION SUPPORT

puppet-xp|wechat|
|:---|:---|
|1.11.14|[WeChat-v3.3.0.115](https://github.com/wechaty/wechaty-puppet-xp/releases/download/v0.5/WeChatSetup-v3.3.0.115.exe)|
|1.12.7|[WeChat-v3.6.0.18](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.6.0.18/WeChatSetup-3.6.0.18.exe)|
|1.3.x|[WeChat-v3.2.2.23](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.9.2.23/WeChatSetup-3.9.2.23.exe)|

## HISTORY

### main v1.12.0 (November 22, 2022)
### next v1.13.0 (September 21, 2023)

1. This version start to support WeChat v3.9.2.23,need to update WeChat on your pc to 3.9.2.23
2. [WeChatSetup-v3.2.2.23.exe](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.9.2.23/WeChatSetup-3.9.2.23.exe)

### main v1.12.7 (November 22, 2022)

1. This version start to support WeChat v3.6.0.18,need to update WeChat on your pc to 3.6.0.18
2. [WeChatSetup-v3.6.0.18.exe](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.6.0.18/WeChatSetup-3.6.0.18.exe)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/media/test.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/media/test.mp4
Binary file not shown.
87 changes: 87 additions & 0 deletions examples/media/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# WECHATY-PUPPET-WECHAT4U [![NPM](https://github.com/wechaty/wechaty-puppet-wechat4u/actions/workflows/npm.yml/badge.svg)](https://github.com/wechaty/wechaty-puppet-wechat4u/actions/workflows/npm.yml)

[![Powered by Wechaty](https://img.shields.io/badge/Powered%20By-Wechaty-blue.svg)](https://github.com/chatie/wechaty)
[![NPM Version](https://badge.fury.io/js/wechaty-puppet-wechat4u.svg)](https://badge.fury.io/js/wechaty-puppet-wechat4u)
[![npm (tag)](https://img.shields.io/npm/v/wechaty-puppet-wechat4u/next.svg)](https://www.npmjs.com/package/wechaty-puppet-wechat4u?activeTab=versions)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-blue.svg)](https://www.typescriptlang.org/)
[![ES Modules](https://img.shields.io/badge/ES-Modules-brightgreen)](https://github.com/Chatie/tsconfig/issues/16)

![wechaty puppet wechat4u](https://wechaty.github.io/puppet-wechat4u/images/wechat4u-logo.png)

Wechat4u Puppet for Wechaty

See: [New Puppet - Plan to support `WECHATY_HEAD=WECHAT4U` #69](https://github.com/Chatie/wechaty/issues/69)

## ABOUT WECHAT4U

[Wechat4U](https://github.com/nodeWechat/wechat4u) is an excellent wechat bot framework that supports both Node.js & Browser, with rich features and an active community of experienced contributors.

## KNOWN LIMITATIONS

~~1. WeChat Account that registered after 2017 mignt not be able to login Web Wechat, so it can not use PuppetPuppeteer with Wechaty. Please make sure your WeChat Account can be able to login by visiting <https://wx.qq.com>~~
~~1. Web API can not create room and invite members to room since 2018.~~

UOS has support

更新 - 2023/02/10
目前使用 1.13.14 大多数使用者可能出现微信被官方封禁提醒,从已知收集的封禁情况,暂未有可解决方案。

猜测可能与近期ChatGPT结合本仓库实现个性化机器人导致相关封禁,请合理,谨慎使用本仓库。

If you want to break the above limitations, please consider to use a Wechaty Puppet other than using Web API, like [wechaty-puppet-padchat](https://github.com/lijiarui/wechaty-puppet-padchat).

Learn more about the Puppet at [Wechaty wiki: Puppet](https://github.com/Chatie/wechaty/wiki/Puppet)

## HISTORY

### v1.14.0 (April 21, 2023)

1.Stable version

2.Fix Contact isFriend

### v1.13.8 (Nov 22, 2022)

1.Fix Contact update

### v1.13.1 (Nov 18, 2022)

1.Support uos login

2.Refactor the code to support more event

### master v1.0 (Oct 30, 2021)

Release 1.0 of Wechaty Puppet for Wechat4u

### v0.20 (Sep 14, 2021)

1. ES Modules support

### v0.18 (Feb 20, 2021)

Fix `wechaty-puppet` dependencies

### v0.0.1 (Jun 30, 2018)

Init version

## MAINTAINERS

- [Leo Chen](https://wechaty.js.org/contributors/leochen-g/), [Project Admin](https://github.com/wechaty/puppet-wechat4u/pull/42#issuecomment-1324436596)
- [Huan](https://wechaty.js.org/contributors/huan/), Author of Puppet WeChat4U

## AUTHOR

[Huan LI](http://linkedin.com/in/zixia) \<[email protected]\>

<!-- markdownlint-disable MD033 -->
<a href="https://stackexchange.com/users/265499">
<img src="https://stackexchange.com/users/flair/265499.png" width="208" height="58" alt="profile for zixia on Stack Exchange, a network of free, community-driven Q&amp;A sites" title="profile for zixia on Stack Exchange, a network of free, community-driven Q&amp;A sites">
</a>

## COPYRIGHT & LICENSE

- Code & Docs © 2018 Huan LI \<[email protected]\>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons
96 changes: 55 additions & 41 deletions examples/ripe-wechaty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { FileBox } from 'file-box'

import { PuppetXp } from '../src/puppet-xp.js'
import qrcodeTerminal from 'qrcode-terminal'
import timersPromise from 'timers/promises'
import fs from 'fs'

function onScan (qrcode: string, status: ScanStatus) {
if (qrcode) {
Expand Down Expand Up @@ -48,43 +48,66 @@ async function onMessage (msg: Message) {
if (msg.text() === 'ding') {
await msg.say('dong')
}
if (msg.type() === types.Message.Image) {
const img = await msg.toImage()
const thumbFile = await img.thumbnail()
log.info('thumbFile', thumbFile.name)
await thumbFile.toFile(`${process.cwd()}/cache/${thumbFile.name}`, true)

// await timersPromise.setTimeout(3000)
// console.info(img)
const hdFile = await img.hd()
log.info('hdFile', hdFile.name)
await hdFile.toFile(`${process.cwd()}/cache/${hdFile.name}`, true)
// setTimeout(msg.wechaty.wrapAsync(
// async function () {
// const imginfo = await msg.toFileBox()
// console.info(imginfo)
// },
// ), 500)
const basepath = 'examples/media/'
/**
* 发送文件
*/
if (msg.text() === 'txt') {
const newpath = basepath + 'test.txt'
const fileBox = FileBox.fromFile(newpath)
await msg.say(fileBox)
}
if (msg.type() === types.Message.Emoticon) {
const emoticon = await msg.toFileBox()
await emoticon.toFile(`${process.cwd()}/cache/${emoticon.name}`, true)
await timersPromise.setTimeout(1000)
console.info(emoticon)
// setTimeout(msg.wechaty.wrapAsync(
// async function () {
// const imginfo = await msg.toFileBox()
// console.info(imginfo)
// },
// ), 500)

/**
* 发送图片
*/
if (msg.text() === 'jpg') {
const newpath = 'https://github.com/wechaty/wechaty/blob/main/docs/images/bot-qr-code.png'
const fileBox = FileBox.fromUrl(newpath)
await msg.say(fileBox)
}
if (msg.text() === 'file') {
const newpath = 'C:\\Users\\wechaty\\Documents\\GitHub\\wechat-openai-qa-bot\\cache\\data1652178575294.xls'

log.info('newpath==================================', newpath)
/**
* 发送表情
*/
if (msg.text() === 'gif') {
const newpath = basepath + 'test.gif'
const fileBox = FileBox.fromFile(newpath)
await msg.say(fileBox)
}

/**
* 发送视频
*/
if (msg.text() === 'mp4') {
const newpath = basepath + 'test.mp4'
const fileBox = FileBox.fromFile(newpath)
await msg.say(fileBox)
}

try {
if (msg.type() === types.Message.Image || msg.type() === types.Message.Attachment || msg.type() === types.Message.Video || msg.type() === types.Message.Audio || msg.type() === types.Message.Emoticon) {
const file = await msg.toFileBox() // Save the media message as a FileBox
const filePath = 'examples/file/' + file.name
file.toFile(filePath)
log.info(`Saved file: ${filePath}`)
} else {
// Log other non-text messages
const logData = {
date: new Date(),
from: msg.talker().name(),
text: msg.text(),
type: msg.type(),
}
const logPath = 'examples/log/message.log'
fs.appendFileSync(logPath, JSON.stringify(logData, null, 2) + '\n')
log.info(`Logged message data to ${logPath}`)
}
} catch (e) {
console.error(`Error handling message: ${e}`)
}

}

const puppet = new PuppetXp()
Expand All @@ -98,27 +121,18 @@ bot.on('login', onLogin)
bot.on('logout', onLogout)
bot.on('message', onMessage)
bot.on('room-join', async (room, inviteeList, inviter) => {
// "超超超哥"邀请"瓦力"加入了群聊
// "超超超哥"邀请你加入了群聊,群聊参与人还有:瓦力
// "luyuchao"邀请"瓦力"加入了群聊
// 你邀请"瓦力"加入了群聊
const nameList = inviteeList.map(c => c.name()).join(',')
log.info(`Room ${await room.topic()} got new member ${nameList}, invited by ${inviter}`)
})
bot.on('room-leave', async (room, leaverList, remover) => {
// 你被"luyuchao"移出群聊
// 你将"瓦力"移出了群聊
const nameList = leaverList.map(c => c.name()).join(',')
log.info(`Room ${await room.topic()} lost member ${nameList}, the remover is: ${remover}`)
})
bot.on('room-topic', async (room, topic, oldTopic, changer) => {
// "luyuchao"修改群名为“北辰香麓欣麓园抗疫”
// 你修改群名为“大师是群主”
log.info(`Room ${await room.topic()} topic changed from ${oldTopic} to ${topic} by ${changer.name()}`)
})
bot.on('room-invite', async roomInvitation => {
log.info(JSON.stringify(roomInvitation))
// "超超超哥"邀请你加入了群聊,群聊参与人还有:瓦力
try {
log.info('received room-invite event.')
await roomInvitation.accept()
Expand All @@ -131,4 +145,4 @@ bot.start()
.then(() => {
return log.info('StarterBot', 'Starter Bot Started.')
})
.catch(console.error)
.catch(console.error)
3 changes: 2 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.0",
"version": "1.13.1",
"description": "Puppet XP for Wechaty",
"type": "module",
"exports": {
Expand All @@ -26,6 +26,7 @@
"quick-start": "cross-env NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/quick-start.ts",
"start:raw": "cross-env BROLOG_LEVEL=silly NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/raw-sidecar.ts",
"start:ripe": "cross-env WECHATY_LOG=verbose NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/ripe-wechaty.ts",
"start:ripe:info": "cross-env WECHATY_LOG=info NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/ripe-wechaty.ts",
"lint": "npm run lint:es && npm run lint:ts && npm run lint:md",
"lint:md": "markdownlint README.md",
"lint:ts": "tsc --isolatedModules --noEmit",
Expand Down
10 changes: 5 additions & 5 deletions src/init-agent-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ const recvMsgNativeCallback = (() => {
// console.log(msgType)
// console.log(contentPtr.readUtf16String())
// console.log('----------------------------------------')
const groupMsgAddr = addr.add(0x170).readU32() //* 2 + 2
const groupMsgAddr = addr.add(0x174).readU32() //* 2 + 2
let myGroupMsgSenderIdPtr = null
if (groupMsgAddr == 0) { //weChatPublic is zero,type is 49

Expand All @@ -295,8 +295,8 @@ const recvMsgNativeCallback = (() => {

} else {

const groupMsgSenderIdPtr = addr.add(0x170).readPointer()
const groupMsgSenderIdLen = addr.add(0x170 + 0x04).readU32() * 2 + 2
const groupMsgSenderIdPtr = addr.add(0x174).readPointer()
const groupMsgSenderIdLen = addr.add(0x174 + 0x04).readU32() * 2 + 2
myGroupMsgSenderIdPtr = Memory.alloc(groupMsgSenderIdLen)
Memory.copy(myGroupMsgSenderIdPtr, groupMsgSenderIdPtr, groupMsgSenderIdLen)

Expand Down Expand Up @@ -458,7 +458,7 @@ const getContactNativeFunction = (() => {

//console.log(ret)

console.log('getContactNativeFunction:', ret.length)
// console.log('getContactNativeFunction:', ret.length)
/*for (let item of ret){
console.log(JSON.stringify(item))
}*/
Expand Down Expand Up @@ -794,7 +794,7 @@ const getChatroomMemberNickInfoFunction = ((memberId, roomId) => {
nativeativeFunction()

const nickname = readWideString(nickBuff)
console.log('----nickname', nickname)
// console.log('----nickname', nickname)
return readWideString(nickBuff)
})

Expand Down
2 changes: 1 addition & 1 deletion src/puppet-xp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class PuppetXp extends PUPPET.Puppet {
this.#sidecar = new WeChatSidecar()

await attach(this.sidecar)
void this.onLogin()
await this.onLogin()

this.sidecar.on('hook', ({ method, args }) => {
log.verbose('PuppetXp', 'onHook(%s, %s)', method, JSON.stringify(args))
Expand Down

0 comments on commit de97586

Please sign in to comment.