Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a827da4

Browse files
committedDec 8, 2022
fix: 🐛 Support using session generation on windows systems
1 parent 4406810 commit a827da4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
 

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ cython_debug/
307307
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
308308
# and can be added to the global gitignore or merged into this file. For a more nuclear
309309
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
310-
#.idea/
310+
.idea/
311311

312312
### Python Patch ###
313313
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration

‎src/chatgpt.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export class ChatGPTBot {
2020
return this.cache.get(email);
2121
}
2222
const cmd = `poetry run python3 src/generate_session.py ${email} ${password}`;
23-
const { stdout, stderr, exitCode } = await execa(`sh`, ["-c", cmd]);
23+
const platform = process.platform;
24+
const { stdout, stderr, exitCode } = await execa(platform==="win32"?"powershell":"sh", [platform==="win32"?"/c":"-c", cmd]);
2425
if (exitCode !== 0) {
2526
console.error(stderr);
2627
return "";
@@ -102,7 +103,7 @@ export class ChatGPTBot {
102103
async getGPTMessage(text: string, talkerId: string): Promise<string> {
103104
const conversation = this.getConversation(talkerId);
104105
try {
105-
return await conversation.sendMessage(text);
106+
return await conversation.sendMessage(text,{timeoutMs: 2 * 60 * 1000});
106107
} catch (e) {
107108
this.resetConversation(talkerId);
108109
console.error(e);
@@ -127,7 +128,15 @@ export class ChatGPTBot {
127128
}
128129
async onMessage(message: Message) {
129130
const talker = message.talker();
130-
if (talker.self() || message.type() > 10 || talker.name() == "微信团队") {
131+
if (talker.self()
132+
|| message.type() > 10
133+
|| talker.name() == "微信团队"
134+
// 语音(视频)消息
135+
|| message.text().includes("收到一条视频/语音聊天消息,请在手机上查看")
136+
// 红包消息
137+
|| message.text().includes("收到红包,请在手机上查看")
138+
// 位置消息
139+
|| message.text().includes("/cgi-bin/mmwebwx-bin/webwxgetpubliclinkimg")) {
131140
return;
132141
}
133142
const text = message.text();

0 commit comments

Comments
 (0)
Please sign in to comment.