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

添加微信支持 #448

Closed
wants to merge 5 commits into from
Closed

Conversation

shyu216
Copy link

@shyu216 shyu216 commented Mar 28, 2023

  • 利用的是itchat,运行后扫二维码登录,可短暂记住账号密码,保存在itchat.pkl中

  • 暂无config.cfg功能实现

  • 依赖在requirement_wechat里面

  • 目前可以用这个运行
    cd chatgpt && python3.11\python.exe itchat-bot.py

@shyu216
Copy link
Author

shyu216 commented Mar 28, 2023

嗷目前有两个小bug

  • 扫二维码要扫五六次才能成功

  • 不正常退出就保存不了pkl

Copy link
Owner

@lss233 lss233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢你的 PR!请不要忘记了在 README.md 中补充你所加入的功能的介绍。

import asyncio
import os

# 如果加到bot.py里面,就不需要这两行了
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你可以参考 bot.py,在那边统一启动。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

@@ -0,0 +1,2 @@
[itchat]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得不需要分成多个配置文件,要不然不好管理,改动很大。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

return False

hotReload = True # 一段时间内不用再扫码
loginCallback = init_data
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们对变量使用 snake_case 命名风格。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

platforms/itchat-bot.py Outdated Show resolved Hide resolved
requirement_wechat.txt Outdated Show resolved Hide resolved
""" 监听用户消息,用于自动回复 """
# logger.info(msg)
name = 'group-' + msg.fromUserName
is_manager = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: 兼容触发词系统

@itchat.msg_register([TEXT], isFriendChat=True)
def friend_reply(msg):
""" 监听用户消息,用于自动回复 """
logger.info(msg.fromUserName+':'+msg.text)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: 兼容触发词系统


logger.info('登录成功')
while True:
if len(request_list)>0:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么要用一个队列来管理所有的聊天消息? 这样会导致程序一次只能回复一个人。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那个itchat接收消息的function是sync的,但是我们的handle_message是async的,我不知道怎么办。。。

@lss233
Copy link
Owner

lss233 commented Mar 28, 2023

说起来这个容易封号吗

@shyu216
Copy link
Author

shyu216 commented Mar 28, 2023

说起来这个容易封号吗

有道理,我找了一下,好像确实有这样的案例:https://github.com/AutumnWhj/ChatGPT-wechat-bot/issues/158(
事情有些蹊跷,封号集中在2月9号)

我前一个星期用的是 https://github.com/fuergaosi233/wechat-chatgpt ,暂时还没有被封的迹象。。。

但这些是wechaty,基于javascript的,itchat我正在试。。。

@lss233
Copy link
Owner

lss233 commented Mar 29, 2023

根据我的了解,itchat 已经停止维护了……

@shyu216
Copy link
Author

shyu216 commented Mar 29, 2023

根据我的了解,itchat 已经停止维护了……

确实,大佬有什么建议吗。。。

或许可以试试这个:https://github.com/wechaty/python-wechaty

@lss233
Copy link
Owner

lss233 commented Mar 29, 2023

这方面我也不是很懂。Wechaty 似乎是收费的,免费的方案也是使用 Web 协议登录,和 itchat 基本上一样。
或许可以看看 https://juejin.cn/post/7179140844073680954
我找到的 Hook 方案的框架:https://gitee.com/qxvxhook/pc-vx-hook-http-api

@shyu216
Copy link
Author

shyu216 commented Mar 29, 2023

这方面我也不是很懂。Wechaty 似乎是收费的,免费的方案也是使用 Web 协议登录,和 itchat 基本上一样。
或许可以看看 https://juejin.cn/post/7179140844073680954
我找到的 Hook 方案的框架:https://gitee.com/qxvxhook/pc-vx-hook-http-api

感谢大佬,我觉得我可以放弃了,哈哈

微信太坏了。。。

@RickyLoveFreedom
Copy link

可以试下这个,https://github.com/billyplus/ntchat.git 目前还不错

@wenxie18
Copy link

wenxie18 commented May 9, 2023

ntchat没有 mac版本

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

Successfully merging this pull request may close these issues.

4 participants