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

Updated the automatic packaging logic #235

Merged
merged 63 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
0863b88
3.9.2.23 init (#180)
choogoo Jul 11, 2023
ad0e0e3
3.9.2.23 init (#182)
choogoo Jul 11, 2023
3faaa0b
适配3.9.2.23 (#185)
choogoo Sep 21, 2023
865ef7f
add 1.3.0 illustrate
atorber Sep 21, 2023
7bfb22c
Update README.md
atorber Sep 21, 2023
e2fe791
Update README.md
atorber Sep 21, 2023
5ae42d1
Merge pull request #2 from atorber/3.9.2.23
atorber Sep 21, 2023
eae4d90
add demo
atorber Sep 21, 2023
240252a
1.13.1
atorber Nov 14, 2023
6d3f020
Merge branch 'main' into 3.9.2.23
atorber Nov 14, 2023
b741379
1.13.1
atorber Nov 14, 2023
60c8f7d
Merge branch '3.9.2.23' of https://github.com/atorber/puppet-xp into …
atorber Nov 14, 2023
ad155b2
1.13.2 dev
atorber Nov 19, 2023
d7d72c7
Merge pull request #3 from atorber/3.9.2.23
atorber Nov 20, 2023
0d6c8ec
增加扫码登录、检测登录状态
atorber Nov 22, 2023
5e8a1ef
增加登入登出事件
atorber Nov 23, 2023
6a0afa8
增加ts改造init
atorber Dec 29, 2023
4b7892d
1.13.2
atorber Jan 1, 2024
2788998
1.13.2
atorber Jan 2, 2024
d397db3
1.13.2
atorber Jan 5, 2024
a68a3ee
Merge branch 'main' into 3.9.2.23
atorber Jan 5, 2024
a9b060f
1.13.2
atorber Jan 9, 2024
cc171f4
1.13.2
atorber Jan 9, 2024
4ef747e
Merge pull request #5 from atorber/3.9.2.23
atorber Jan 9, 2024
7f8d6f1
Update .npmignore
atorber Jan 9, 2024
c1575cd
Update .gitignore
atorber Jan 9, 2024
a76931c
Merge pull request #6 from atorber/3.9.2.23
atorber Jan 9, 2024
f030e9c
Merge branch 'main' into main
atorber Jan 9, 2024
60333db
1.13.2删除agent的ts文件
atorber Jan 10, 2024
17e269b
Merge pull request #7 from atorber/3.9.2.23
atorber Jan 10, 2024
7f59bcb
Merge branch 'main' into main
atorber Jan 10, 2024
77d2075
1.13.4
atorber Jan 10, 2024
1e308b9
Merge pull request #8 from atorber/3.9.2.23
atorber Jan 10, 2024
4955de7
Merge branch 'main' into main
atorber Jan 10, 2024
d1fb18b
1.13.5
atorber Jan 12, 2024
8243c3b
Update init-agent-script.ts
atorber Jan 12, 2024
e9f16c5
1.13.5
atorber Jan 13, 2024
3abc2bf
Merge branch '3.9.2.23'
atorber Jan 13, 2024
eabf3d1
Merge branch 'main' into main
atorber Jan 13, 2024
e5c6981
1.13.6
atorber Jan 19, 2024
48f9ba6
Merge branch '3.9.2.23'
atorber Jan 19, 2024
b54418c
del png file
atorber Jan 19, 2024
9bfac54
Merge branch '3.9.2.23' of https://github.com/atorber/puppet-xp into …
atorber Jan 19, 2024
0533e0f
Update init-agent-script.js
atorber Jan 19, 2024
a46d99c
Merge pull request #9 from atorber/3.9.2.23
atorber Jan 19, 2024
5935308
1.13.7 修复@好友出现两个昵称的bug
atorber Jan 19, 2024
bcfb55f
1.13.7 修复@好友昵称重复bug (#209)
atorber Jan 19, 2024
805d569
1.13.7
atorber Jan 19, 2024
ff5966b
Merge branch '3.9.2.23' into 3.9.2.23
atorber Jan 19, 2024
fb1ddb0
Merge pull request #10 from atorber/3.9.2.23
atorber Jan 19, 2024
c8afba9
Update README.md
atorber Jan 19, 2024
bcb26f2
Merge pull request #11 from atorber/3.9.2.23
atorber Jan 19, 2024
59287a5
Merge pull request #12 from wechaty/main
atorber Jan 19, 2024
81a96b3
1.13.8
atorber Jan 19, 2024
1b6b35e
Merge branch '3.9.2.23'
atorber Jan 19, 2024
3a9f7e5
Merge branch 'wechaty:main' into main
atorber Jan 21, 2024
e7a23ce
Merge branch 'wechaty:main' into main
atorber Mar 14, 2024
cee7c00
Merge branch 'wechaty:main' into main
atorber Apr 10, 2024
2e8b70f
3.9.10.19 init
atorber Jun 6, 2024
ff28874
3.9.10.19 init
atorber Jun 7, 2024
41d6470
Update package.json
atorber Jun 7, 2024
b666511
match wechat client version
atorber Jun 7, 2024
16360d9
Update npm.yml
atorber Jun 7, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: ./scripts/npm-pack-testing.sh

publish:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/v'))
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/3'))
name: Publish
needs: [build, pack]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Check Branch
id: check-branch
run: |
if [[ ${{ github.ref }} =~ ^refs/heads/(main|v[0-9]+\.[0-9]+.*)$ ]]; then
if [[ ${{ github.ref }} =~ ^refs/heads/(main|[0-9]+\.[0-9]+\.[0-9].*)$ ]]; then
echo ::set-output name=match::true
fi # See: https://stackoverflow.com/a/58869470/1123955
- name: Is A Publish Branch
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ puppet-xp|wechat|npm install|

## HISTORY

### v2.0.0

1. Support WeChat version 3.9.10.19
2. Support list
- getMyselfInfo
- sendMsg
- recvMsg

### v1.13.12

1. Fixed the bug where the system crashes upon receiving a message before successful startup
Expand Down
102 changes: 102 additions & 0 deletions examples/raw-sidecar-hook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/* eslint-disable no-console */

/**
* Wechaty - https://github.com/wechaty/wechaty
*
* @copyright 2021 Wechaty Contributors <https://github.com/wechaty>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import {
attach,
detach,
} from 'sidecar'

import {
WeChatSidecar,
// XpSidecar
} from '../src/wechat-sidecar.js'

async function main () {
console.info('WeChat Sidecar starting...')
// new XpSidecar({ wechatVersion: '3.9.2.23' })

const sidecar = new WeChatSidecar()
await attach(sidecar)

console.info('WeChat Sidecar started.')

sidecar.on('hook', ({ method, args }) => {
// console.log(`onhook事件消息:${new Date().toLocaleString()}\n`, method, JSON.stringify(args))
console.log(`onhook事件消息:${new Date().toLocaleString()}`, method)
switch (method) {
case 'recvMsg':{
void onRecvMsg(args)
break
}
case 'checkQRLogin':
break
case 'loginEvent':{
break
}
case 'agentReady':
console.log('agentReady...')
break
default:
console.info('onHook没有匹配到处理方法:', method, JSON.stringify(args))
break
}
})

const onRecvMsg = async (args: any) => {
console.info('onRecvMsg事件触发:', JSON.stringify(args))

if (args instanceof Error) {
console.error('onRecvMsg: 参数错误 Error', args)
return
}

const toId = String(args[3])
const text = String(args[2])
const talkerId = String(args[1])

// const nickname = await sidecar.GetContactOrChatRoomNickname(talkerId)
// console.log('发言人昵称:', nickname)
console.info('talkerId:', talkerId)
console.info('toId:', toId)
console.info('text:', text)
if (talkerId && text === 'ding') {
console.info('叮咚测试: ding found, reply dong')
try {
await sidecar.sendMsg(talkerId || toId, 'dong')
// await sidecar.sendAtMsg(toId, 'dong',talkerId)
} catch (e) {
console.error('发送消息失败:', e)
}
}
}

const clean = () => {
console.info('Sidecar detaching...')
void detach(sidecar)
}

process.on('SIGINT', clean)
process.on('SIGTERM', clean)
}

main()
.catch(e => {
console.error('主函数运行失败:', e)
})
88 changes: 44 additions & 44 deletions examples/raw-sidecar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ async function main () {

console.info('WeChat Sidecar started.')

const ver = await sidecar.getWeChatVersion()
const verStr = await sidecar.getWechatVersionString()
const isSupported = await sidecar.checkSupported()
console.info(`\nWeChat Version: ${ver} -> ${verStr} , Supported: ${isSupported}\n`)
// const ver = await sidecar.getWeChatVersion()
// const verStr = await sidecar.getWechatVersionString()
// const isSupported = await sidecar.checkSupported()
// console.info(`\nWeChat Version: ${ver} -> ${verStr} , Supported: ${isSupported}\n`)

const isLoggedIn = await sidecar.isLoggedIn()
// const isLoggedIn = await sidecar.isLoggedIn()
const myselfInfo = await sidecar.getMyselfInfo()
console.info(`当前登陆账号信息: ${myselfInfo}`)

const loginUrl = await sidecar.getLoginUrl()
console.info(`登陆二维码地址loginUrl: ${loginUrl}`)
// const loginUrl = await sidecar.getLoginUrl()
// console.info(`登陆二维码地址loginUrl: ${loginUrl}`)

// const contact = await sidecar.getChatroomMemberInfo()
// //console.log(contact)
Expand All @@ -74,18 +74,18 @@ async function main () {
void onScan(args)
break
case 'loginEvent':{
if (!isLoggedIn) {
let loginRes = false
sidecar.isLoggedIn().then(res => {
loginRes = res
if (loginRes) {
void onLogin()
}
return res
}).catch(e => {
console.error('登录状态检查失败:', e)
})
}
// if (!isLoggedIn) {
// let loginRes = false
// sidecar.isLoggedIn().then(res => {
// loginRes = res
// if (loginRes) {
// void onLogin()
// }
// return res
// }).catch(e => {
// console.error('登录状态检查失败:', e)
// })
// }
break
}
case 'agentReady':
Expand All @@ -100,31 +100,31 @@ async function main () {
}
})

const onLogin = async () => {
console.info('登陆事件触发')
console.info(`登陆状态: ${isLoggedIn}`)
// await sidecar.sendMsg('filehelper', 'Sidecar is ready!')
const contacts = await sidecar.getContact()
// console.log(`contacts: ${contacts}`)
const contactsJSON = JSON.parse(contacts)
console.log('contacts列表:', contactsJSON.length)

for (const contact of contactsJSON) {
if (!contact.name) {
console.info('好友:', JSON.stringify(contact))
}
}
// const onLogin = async () => {
// console.info('登陆事件触发')
// console.info(`登陆状态: ${isLoggedIn}`)
// await sidecar.sendMsg('filehelper', 'Sidecar is ready!')
// const contacts = await sidecar.getContact()
// console.log(`contacts: ${contacts}`)
// const contactsJSON = JSON.parse(contacts)
// console.log('contacts列表:', contactsJSON.length)

// for (const contact of contactsJSON) {
// if (!contact.name) {
// console.info('好友:', JSON.stringify(contact))
// }
// }

const roomList = await sidecar.getChatroomMemberInfo()
// console.log(`roomList: ${roomList}`)
const roomListJSON = JSON.parse(roomList)
console.log('roomList列表:', roomListJSON.length)
// for (const room of roomListJSON) {
// console.info('room:', room)
// }
// await sidecar.sendAtMsg('21341182572@chatroom', new Date().toLocaleString(), 'atorber', '超哥');
// const roomList = await sidecar.getChatroomMemberInfo()
// console.log(`roomList: ${roomList}`)
// const roomListJSON = JSON.parse(roomList)
// console.log('roomList列表:', roomListJSON.length)
// for (const room of roomListJSON) {
// console.info('room:', room)
// }
// await sidecar.sendAtMsg('21341182572@chatroom', new Date().toLocaleString(), 'atorber', '超哥');

}
// }

const onLogout = (bySrv: number) => {
console.info('登出事件触发:', bySrv)
Expand Down Expand Up @@ -170,8 +170,8 @@ async function main () {
// const nickname = await sidecar.GetContactOrChatRoomNickname(talkerId)
// console.log('发言人昵称:', nickname)

const talker = await sidecar.getChatroomMemberNickInfo(talkerId, toId)
console.log('发言人:', talker)
// const talker = await sidecar.getChatroomMemberNickInfo(talkerId, toId)
// console.log('发言人:', talker)
if (talkerId && text === 'ding') {
console.info('叮咚测试: ding found, reply dong')
await sidecar.sendMsg(toId, 'dong')
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-puppet-xp",
"version": "1.13.12",
"version": "2.0.0",
"description": "Puppet XP for Wechaty",
"type": "module",
"exports": {
Expand Down Expand Up @@ -29,6 +29,7 @@
"start:raw": "cross-env BROLOG_LEVEL=silly NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/raw-sidecar.ts",
"start:raw:nobuild": "cross-env BROLOG_LEVEL=info NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/raw-sidecar.ts",
"start:raw:info": "npm run build:agent && cross-env BROLOG_LEVEL=info NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/raw-sidecar.ts",
"start:raw:hook": "npm run build:agent && cross-env BROLOG_LEVEL=info NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/raw-sidecar-hook.ts",
"start:ripe": "cross-env WECHATY_LOG=verbose NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/ripe-wechaty.ts",
"start:ripe:info": "npm run build:agent && cross-env WECHATY_LOG=info NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/ripe-wechaty.ts",
"start:ripe:demo": "npm run build:agent && cross-env WECHATY_LOG=info NODE_OPTIONS=\"--no-warnings --loader=ts-node/esm\" node examples/demo.ts",
Expand Down Expand Up @@ -83,8 +84,9 @@
"wechaty-puppet": "^1.10.2"
},
"dependencies": {
"@swc/core": "^1.5.25",
"cuid": "^2.1.8",
"sidecar": "^0.17.8",
"sidecar": "^1.0.19",
"xml2js": "^0.4.23",
"xmlreader": "^0.2.3"
},
Expand Down
Loading
Loading