Skip to content

Commit b99bc18

Browse files
committed
add many many features for v0.95-dev
1 parent 54ea18a commit b99bc18

File tree

5 files changed

+69
-45
lines changed

5 files changed

+69
-45
lines changed

.config/rev_config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"email": "",
44
"password": "",
55
"session_token": "",
6-
"paid": false
6+
"paid": true
77
}

Readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Using ChatGPT-weBot based on ChatGPT(Non-API key call) and official WeChat hook
2020
- [x] Support context-aware question answering
2121
- [x] **Never get banned by using official WeChat execution.**
2222
- [x] Set the keywords to wake up the WeChat robot in private.
23-
- [x] Set the keywords to wake up the WeChat robot in the group. **(have bugs)**
23+
- [x] Set the keywords to wake up the WeChat robot in the group.
24+
- [x] Get help doc in line.
25+
- [x] Can set keywords to reset the previous conversation.
2426
- [x] Support replying message when mentioning your bot in the group. **(have bugs)**
25-
- [ ] Get help doc in line. **(need work)**
26-
- [ ] Can set keywords to reset the previous conversation. **(need work)**
2727
- [ ] Regenerate to get another answer. **(need work)**
2828
- [ ] Rollback conversation. **(need work)**
2929
- [ ] Other

Readme_ZH.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616

1717
## 支持和特点
1818

19-
- [x] 支持对话
19+
- [x] 支持对话
2020
- [x] 支持上下文感知问答
21-
- [x] **使用官方微信软件执行,信息来源方面永不封禁**
21+
- [x] **使用官方微信软件执行,信息来源方面永不封禁**
2222
- [x] 设置关键字在私聊中唤醒微信机器人
23-
- [x] 设置关键字在群中唤醒微信机器人。(有Bug)
24-
- [x] 在群聊中提到您的机器人时,支持回复消息。(有Bug)
25-
- [ ] 在线获取帮助文档。(待完善)
26-
- [ ] 可以设置关键字以重置之前的对话。(待完善
27-
- [ ] 重新生成以获得另一个答案。(待完善)
28-
- [ ] 回滚对话(待完善)
23+
- [x] 设置关键字在群中唤醒微信机器人
24+
- [x] 在线获取帮助文档
25+
- [x] 可以设置关键字以重置之前的对话
26+
- [x] 在群聊中提到您的机器人时,支持回复消息(有Bug
27+
- [ ] 重新生成另一个答案(待完善)
28+
- [ ] 回滚对话(待完善)
2929
- [ ] 其他
3030

3131

client/wxclient.py

+56-32
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@ def handle_recv_txt_msg(j):
228228
wx_id = j["wxid"]
229229
room_id = ""
230230
content: str = j["content"]
231+
reply = ""
231232

232-
is_room: bool
233233
is_ask: bool = False
234+
is_room: bool
234235

235236
chatbot: Chatbot
236237

@@ -253,44 +254,66 @@ def handle_recv_txt_msg(j):
253254
is_ask = True
254255
content = re.sub(groupChatKey, "", content)
255256

256-
if autoReply and is_ask and ((not is_room and privateReplyMode) or (is_room and groupReplyMode)):
257-
if chatbot is None:
258-
chatbot = Chatbot(
259-
rev_config,
260-
conversation_id=None,
261-
parent_id=None,
262-
)
257+
if autoReply and ((not is_room and privateReplyMode) or (is_room and groupReplyMode)):
258+
if is_ask:
259+
if chatbot is None:
260+
chatbot = Chatbot(
261+
rev_config,
262+
conversation_id=None,
263+
parent_id=None,
264+
)
265+
if is_room:
266+
global_dict[(wx_id, room_id)] = chatbot
267+
else:
268+
global_dict[(wx_id, "")] = chatbot
269+
270+
print("ask:" + content)
271+
for data in chatbot.ask(
272+
prompt=content,
273+
):
274+
reply += data["message"][len(reply):]
275+
276+
elif content.startswith(helpKey):
263277
if is_room:
264-
global_dict[(wx_id, room_id)] = chatbot
265-
else:
266-
global_dict[(wx_id, "")] = chatbot
278+
reply = str(
279+
b'\xe6\xac\xa2\xe8\xbf\x8e\xe4\xbd\xbf\xe7\x94\xa8 ChatGPT-weBot\xef\xbc\x8c\xe6\x9c\xac\xe9'
280+
b'\xa1\xb9\xe7\x9b\xae\xe5\x9c\xa8 github \xe5\x90\x8c\xe5\x90\x8d\xe5\xbc\x80\xe6\xba\x90\n',
281+
'utf-8') + helpKey + " 查看可用命令帮助\n" + groupChatKey + " 唤醒群内机器人\n" + resetChatKey + \
282+
" 重置上下文\n" + regenerateKey + " 重新生成答案\n" + rollbackKey + " +数字n 回滚到倒数第n个问题"
267283

268-
print("ask:" + content)
269-
reply = ""
270-
for data in chatbot.ask(
271-
prompt=content,
272-
):
273-
reply += data["message"][len(reply):]
284+
else:
285+
reply = str(
286+
b'\xe6\xac\xa2\xe8\xbf\x8e\xe4\xbd\xbf\xe7\x94\xa8 ChatGPT-weBot\xef\xbc\x8c\xe6\x9c\xac\xe9'
287+
b'\xa1\xb9\xe7\x9b\xae\xe5\x9c\xa8 github \xe5\x90\x8c\xe5\x90\x8d\xe5\xbc\x80\xe6\xba\x90\n',
288+
'utf-8') + helpKey + " 查看可用命令帮助\n" + privateChatKey + " 唤醒机器人\n" + resetChatKey + \
289+
" 重置上下文\n" + regenerateKey + " 重新生成答案\n" + rollbackKey + " +数字n 回滚到倒数第n个问题"
290+
time.sleep(1.5)
291+
292+
elif content.startswith(resetChatKey):
293+
if chatbot is not None:
294+
chatbot.clear_conversations()
295+
del (global_dict[(wx_id, room_id)])
296+
reply = "重置完成"
297+
else:
298+
reply = "您还没有开始第一次对话"
299+
time.sleep(1.5)
274300

275-
if is_room:
276-
ws.send(send_txt_msg(text_string=reply, wx_id=room_id))
301+
elif content.startswith(regenerateKey): # todo
302+
pass
277303

304+
elif content.startswith(rollbackKey): # todo
305+
pass
278306
else:
279-
ws.send(send_txt_msg(text_string=reply, wx_id=wx_id))
280-
print("reply:" + reply)
281-
282-
elif content.startswith(resetChatKey): # todo
283-
pass
284-
285-
elif content.startswith(regenerateKey): # todo
286-
pass
287-
288-
elif content.startswith(rollbackKey): # todo
289-
pass
290-
307+
return
291308
else:
292309
return
293310

311+
if is_room:
312+
ws.send(send_txt_msg(text_string=reply.strip(), wx_id=room_id))
313+
else:
314+
ws.send(send_txt_msg(text_string=reply.strip(), wx_id=wx_id))
315+
print("reply:" + reply)
316+
294317

295318
def handle_recv_pic_msg(j):
296319
print(j)
@@ -366,9 +389,10 @@ def on_error(ws, error):
366389

367390

368391
def on_close(ws):
369-
for key, value in global_dict: # todo: still have bugs
392+
for key, value in global_dict.items(): # todo: still have bugs
370393
print("clear conversation id:" + value.parent_id)
371394
value.clear_conversations()
395+
del value
372396

373397
print(ws)
374398
print("closed")

revChat/revChatGPT.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import requests
1010
from OpenAIAuth import Authenticator, Error as AuthError
1111

12-
BASE_URL = environ.get("CHATGPT_BASE_URL") or "https://chatgpt.duti.tech/"
12+
BASE_URL = "https://chatgpt.duti.tech/"
1313

1414

1515
class Error(Exception):

0 commit comments

Comments
 (0)