wechat-chatgpt
wechat-chatgpt copied to clipboard
support self-ask in private message
我朋友只有一个微信号,他想把自己的微信作为 ChatGPT 机器人使用。在与别人私聊的对话中,他希望自己也可以通过触发关键词来向 ChatGPT 提问。因此做了以下的改动,私以为对于没有多余微信号的使用者还是有点用的。
-
isNonsense
过滤中忽略了 talker 是 self 的情况 - 如果 talker 是 self 则 say 的对象为 listener。(为了保证类型后面加了
|| talker
)
我朋友只有一个微信号,他想把自己的微信作为 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
Is there something wrong with my operation?
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)


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
)
Seems it is about the empty triggered word, I will check it in the afternoon.
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)
如果是自问自答,建议要搭配 CHAT_TRIGGER_RULE
使用。必须要符合规则才触发
这个MR挺好的,试了下可用。参考这个commit: https://github.com/sundl123/wechat-chatgpt/commit/2120ef461dd4a33c2305bab92b1c80bf8fda974a
@Benature @sundl123 这两个方案我都试过了, 还是会出现发送「发送文本信息失败」的错误啊.