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

[Feature] 可以添加登录记录保存不 #30

Closed
liu2-3zhi opened this issue Jun 26, 2023 · 10 comments
Closed

[Feature] 可以添加登录记录保存不 #30

liu2-3zhi opened this issue Jun 26, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@liu2-3zhi
Copy link

老是新设备登录,微信账号容易出现风控,可否像正常的电脑微信一样,把登录记录保存下来。

@liu2-3zhi liu2-3zhi added the enhancement New feature or request label Jun 26, 2023
@lcjqyml
Copy link
Owner

lcjqyml commented Jun 26, 2023

参考下面创建一个挂载文件就可以记录登陆状态了:

touch ~/memory-card.json
docker run -v ~/memory-card.json:/app/my-wechat-bot.memory-card.json ... lcjqyml/wechatbot:latest

@lcjqyml lcjqyml closed this as completed Jun 26, 2023
@liu2-3zhi
Copy link
Author

如果有记录会自动登录吗?

@lcjqyml
Copy link
Owner

lcjqyml commented Jun 26, 2023

会,你可以试试

@liu2-3zhi
Copy link
Author

出现了报错:

wechatbot-wechatbot-1  | 
wechatbot-wechatbot-1  | > [email protected] dev
wechatbot-wechatbot-1  | > nodemon --exec node --watch config.yaml --loader ts-node/esm src/main.ts
wechatbot-wechatbot-1  | 
wechatbot-wechatbot-1  | [nodemon] 2.0.22
wechatbot-wechatbot-1  | [nodemon] to restart at any time, enter `rs`
wechatbot-wechatbot-1  | [nodemon] watching path(s): config.yaml
wechatbot-wechatbot-1  | [nodemon] watching extensions: ts
wechatbot-wechatbot-1  | [nodemon] starting `node --loader ts-node/esm src/main.ts`
wechatbot-wechatbot-1  | (node:32) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
wechatbot-wechatbot-1  | (Use `node --trace-warnings ...` to show where the warning was created)
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] Config ->
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] chatbotProxy: http://172.19.0.1:8080
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] autoAcceptFriendShip: true
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] autoAcceptRoomInvite: false
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] privateChatTrigger: 
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] groupChatTrigger: 
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] responseQuote: true
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] ❌ Your Bot failed to start: Error: no payload, please call load() first.
wechatbot-wechatbot-1  |     at MemoryCard.get (file:///app/node_modules/memory-card/src/memory-card.ts:328:13)
wechatbot-wechatbot-1  |     at PuppetWechat4u.onStart (file:///app/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:118:40)
wechatbot-wechatbot-1  |     at async PuppetWechat4u.start (file:///app/node_modules/state-switch/src/service-ctl/service-ctl.ts:89:9)
wechatbot-wechatbot-1  |     at async PuppetWechat4u.start (file:///app/node_modules/wechaty-puppet/src/mixins/service-mixin.ts:34:7)
wechatbot-wechatbot-1  |     at async PuppetWechat4u.start (file:///app/node_modules/wechaty-puppet/src/mixins/ready-mixin.ts:24:7)
wechatbot-wechatbot-1  |     at async WechatyImpl.start (file:///app/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:83:11)
wechatbot-wechatbot-1  | [6/26/2023, 7:48:32 AM] 🤔 Can you login WeChat in browser? The bot works on the desktop WeChat
wechatbot-wechatbot-1  |     at async WechatyImpl.start (file:///app/node_modules/state-switch/src/service-ctl/service-ctl.ts:81:11)
wechatbot-wechatbot-1  |     at async main (file:///app/src/main.ts:73:5)
wechatbot-wechatbot-1  | [nodemon] clean exit - waiting for changes before restart

docker-compose.yml 内容如下

version: '3.4'
services:
  wechatbot:
    image: lcjqyml/wechatbot:latest
    restart: always
    working_dir: /app
    volumes:
      - ./config.yaml:/app/config.yaml
      - ~/memory-card.json:/app/my-wechat-bot.memory-card.json

config.yaml内容如下

chatbotProxy: "http://chatgpt-qq-chatgpt-1:8080"
#自动通过好友请求
autoAcceptFriendShip: "true"
#自动通过群聊邀请
autoAcceptRoomInvite: "false"
#机器人私聊触发器,空则都触发
privateChatTrigger: ""
#机器人群聊触发器,空则@触发,否则:trigger 或 @bot trigger 触发
groupChatTrigger: ""
#群聊中回复时是否引用触发的消息
responseQuote: "true"

@lcjqyml
Copy link
Owner

lcjqyml commented Jun 26, 2023

外部的文件 ~/memory-card.json必须提前创建,再挂载进去。

@lcjqyml
Copy link
Owner

lcjqyml commented Jun 26, 2023

或者你换个路径创建

@liu2-3zhi
Copy link
Author

liu2-3zhi commented Jun 26, 2023

我已经创建了空文件,并直接使用了绝对路径,但仍然出现了报错:

wechatbot-wechatbot-1  | [6/26/2023, 7:55:46 AM] Config ->
wechatbot-wechatbot-1  | [6/26/2023, 7:55:46 AM] chatbotProxy: http://chatgpt-qq-chatgpt-1:8080
wechatbot-wechatbot-1  | [6/26/2023, 7:55:46 AM] autoAcceptFriendShip: true
wechatbot-wechatbot-1  | [6/26/2023, 7:55:46 AM] autoAcceptRoomInvite: false
wechatbot-wechatbot-1  | [6/26/2023, 7:55:46 AM] privateChatTrigger: 
wechatbot-wechatbot-1  | [6/26/2023, 7:55:46 AM] groupChatTrigger: 
wechatbot-wechatbot-1  | [6/26/2023, 7:55:46 AM] responseQuote: true
wechatbot-wechatbot-1  | [6/26/2023, 7:55:47 AM] ❌ Your Bot failed to start: Error: no payload, please call load() first.
wechatbot-wechatbot-1  |     at MemoryCard.get (file:///app/node_modules/memory-card/src/memory-card.ts:328:13)
wechatbot-wechatbot-1  |     at PuppetWechat4u.onStart (file:///app/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:118:40)
wechatbot-wechatbot-1  |     at async PuppetWechat4u.start (file:///app/node_modules/state-switch/src/service-ctl/service-ctl.ts:89:9)
wechatbot-wechatbot-1  |     at async PuppetWechat4u.start (file:///app/node_modules/wechaty-puppet/src/mixins/service-mixin.ts:34:7)
wechatbot-wechatbot-1  |     at async PuppetWechat4u.start (file:///app/node_modules/wechaty-puppet/src/mixins/ready-mixin.ts:24:7)
wechatbot-wechatbot-1  |     at async WechatyImpl.start (file:///app/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:83:11)
wechatbot-wechatbot-1  |     at async WechatyImpl.start (file:///app/node_modules/state-switch/src/service-ctl/service-ctl.ts:81:11)
wechatbot-wechatbot-1  |     at async main (file:///app/src/main.ts:73:5)
wechatbot-wechatbot-1  | [6/26/2023, 7:55:47 AM] 🤔 Can you login WeChat in browser? The bot works on the desktop WeChat
wechatbot-wechatbot-1  | [nodemon] clean exit - waiting for changes before restart

docker-compose.yml 内容如下

version: '3.4'
services:
  wechatbot:
    image: lcjqyml/wechatbot:latest
    restart: always
    working_dir: /app
    volumes:
      - ./config.yaml:/app/config.yaml
      - /home/Zelly/Desktop/wechatbot/memory-card.json:/app/my-wechat-bot.memory-card.json

config.yaml内容如下

chatbotProxy: "http://chatgpt-qq-chatgpt-1:8080"
#自动通过好友请求
autoAcceptFriendShip: "true"
#自动通过群聊邀请
autoAcceptRoomInvite: "false"
#机器人私聊触发器,空则都触发
privateChatTrigger: ""
#机器人群聊触发器,空则@触发,否则:trigger 或 @bot trigger 触发
groupChatTrigger: ""
#群聊中回复时是否引用触发的消息
responseQuote: "true"

@lcjqyml
Copy link
Owner

lcjqyml commented Jun 26, 2023

相当不合理,我就是这么干的就没问题。实在不行,你挂个临时目录进去 :

 - /home/tmp:/app/tmp

扫码登陆后,进入wechatbot容器,把里面的/app/my-wechat-bot.memory-card.json 拷贝到对应上面的临时目录/app/tmp 转出来到宿主机,再用转出来的这个json挂载进去。

@liu2-3zhi
Copy link
Author

奇葩奇葩,docker-compose.yml这样就可以

services:
  wechatbot:
    image: lcjqyml/wechatbot:latest
    restart: always
    working_dir: /app
    volumes:
      - ./config.yaml:/app/config.yaml
      - ./my-wechat-bot.memory-card.json:/app/my-wechat-bot.memory-card.json

里面的文件和外面的文件的文件名一模一样就可以,但是理论上原先也是可以的。好奇怪

- ~/memory-card.json:/app/my-wechat-bot.memory-card.json

@liu2-3zhi
Copy link
Author

还有一个问题,就是设备记录。第一次登录掉线后,再次登录会显示为新设备,希望这个问题可以解决一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants