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

support self-ask in private message #292

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Benature
Copy link

我朋友只有一个微信号,他想把自己的微信作为 ChatGPT 机器人使用。在与别人私聊的对话中,他希望自己也可以通过触发关键词来向 ChatGPT 提问。因此做了以下的改动,私以为对于没有多余微信号的使用者还是有点用的。

  • isNonsense 过滤中忽略了 talker 是 self 的情况
  • 如果 talker 是 self 则 say 的对象为 listener。(为了保证类型后面加了 || talker

@RealTong
Copy link
Collaborator

我朋友只有一个微信号,他想把自己的微信作为 ChatGPT 机器人使用。在与别人私聊的对话中,他希望自己也可以通过触发关键词来向 ChatGPT 提问。因此做了以下的改动,私以为对于没有多余微信号的使用者还是有点用的。

  • isNonsense 过滤中忽略了 talker 是 self 的情况
  • 如果 talker 是 self 则 say 的对象为 listener。(为了保证类型后面加了 || talker

Hi @Benature , thank you for your PR
After testing, I found that sending a message to myself gives me an uncaughtException AssertionError [ERR_ASSERTION]: 1204 == 0 error. And 100% triggered
image
Is there something wrong with my operation?

@Benature
Copy link
Author

Benature commented Dec 12, 2022

I've encountered the 发送文本消息失败 only before I modified L373-374. I thought it was because that wechaty say to the bot wechat itself. May I ask how did you test in the wechat sending message? Here is my test (my ChatGPT token failed for now so I just returned a fixed string)

image

image

  async onPrivateMessage(talker: ContactInterface, text: string) {
    const talkerId = talker.id;
-    // const gptMessage = await this.getGPTMessage(text, talkerId);
+    const gptMessage = "gpt message";
    await this.trySay(talker, gptMessage);
  }

(The triggered word is 小G)

@Benature
Copy link
Author

Seems it is about the empty triggered word, I will check it in the afternoon.

@Benature
Copy link
Author

last commit: In isNonsense, I filter out the private chat that is not sending text, or it will trigger ChatGPT if no trigger word is set.

(talker.self() && messageType != MessageType.Text)

@chenzn1
Copy link
Contributor

chenzn1 commented Feb 22, 2023

如果是自问自答,建议要搭配 CHAT_TRIGGER_RULE 使用。必须要符合规则才触发

@sundl123
Copy link

这个MR挺好的,试了下可用。参考这个commit: sundl123/wechat-chatgpt@2120ef4

@RealTong
Copy link
Collaborator

@Benature @sundl123
这两个方案我都试过了, 还是会出现发送「发送文本信息失败」的错误啊.

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