Merge pull request #22 from Soulter/20-revChatGPTLoginPerf
perf: 逆向库支持access/session登录
This commit is contained in:
@@ -3,7 +3,7 @@ from revChatGPT.V1 import Chatbot
|
||||
class revChatGPT:
|
||||
def __init__(self, config):
|
||||
|
||||
print("[RevChatGPT] 逆向库初始化:"+str(config))
|
||||
if 'password' in config:
|
||||
config['password'] = str(config['password'])
|
||||
self.chatbot = Chatbot(config=config)
|
||||
|
||||
|
||||
@@ -56,20 +56,30 @@ direct_message_mode: true
|
||||
# enable设置为true后,将会停止使用上面正常的官方API调用而使用本逆向项目
|
||||
#
|
||||
# 多账户可以保证每个请求都能得到及时的回复。
|
||||
# 关于account的格式
|
||||
|
||||
|
||||
# 关于account的格式,请你务必认真阅读以下格式。
|
||||
|
||||
|
||||
# account支持email+password、session_token、access_token多种方式登录。
|
||||
# 如果要使用session_token、access_token登录,直接添加新的一行(注意缩进!) - access_token: xxxxxxx即可
|
||||
# account:
|
||||
# - session_token: xxxxxxxx
|
||||
# - access_token: xxxxxxxx
|
||||
# - email: 第1个账户
|
||||
# password: 第1个账户密码
|
||||
# - email: 第2个账户
|
||||
# password: 第2个账户密码
|
||||
# - ....
|
||||
# 请严格按照上面这个格式填写。
|
||||
# 这里我免费提供2个账号给大家,不过用的人一定会很多的,所以会造成一些bug,因此还是用自己的账号好一点。
|
||||
# 这里免费提供2个账号给大家,不过用的人一定会很多的,所以会造成一些bug,因此还是用自己的账号好一点。
|
||||
# 需要账号可以联系我。QQ905617992
|
||||
|
||||
rev_ChatGPT:
|
||||
enable: false
|
||||
account:
|
||||
- access_token:
|
||||
# - session_token: xxxxxxxx
|
||||
- email: d.o.m.her.ry61.7@gmail.com
|
||||
password: 11111111
|
||||
- email: ca.it.li.nal.o.i.si.o91@gmail.com
|
||||
|
||||
@@ -187,17 +187,18 @@ def initBot(cfg, prov):
|
||||
if 'account' in cfg['rev_ChatGPT']:
|
||||
from addons.revChatGPT.revchatgpt import revChatGPT
|
||||
for i in range(0, len(cfg['rev_ChatGPT']['account'])):
|
||||
print(f"[System] 正在创建rev_ChatGPT负载{str(i)}: " + cfg['rev_ChatGPT']['account'][i]['email'])
|
||||
try:
|
||||
print(f"[System] 创建rev_ChatGPT负载{str(i)}: " + str(cfg['rev_ChatGPT']['account'][i]))
|
||||
revstat = {
|
||||
'obj': revChatGPT(cfg['rev_ChatGPT']['account'][i]),
|
||||
'busy': False
|
||||
}
|
||||
rev_chatgpt.append(revstat)
|
||||
|
||||
except:
|
||||
print("[System] 创建rev_ChatGPT负载失败")
|
||||
else:
|
||||
input("[System-err] 请退出本程序, 然后在配置文件中填写rev_ChatGPT的email和password")
|
||||
input("[System-err] 请退出本程序, 然后在配置文件中填写rev_ChatGPT相关配置")
|
||||
elif prov == OPENAI_OFFICIAL:
|
||||
from cores.openai.core import ChatGPT
|
||||
chatgpt = ChatGPT(cfg['openai'])
|
||||
@@ -345,9 +346,11 @@ def get_rev_ChatGPT_response(prompts_str):
|
||||
def send_qq_msg(message, res, image_mode=False):
|
||||
if not image_mode:
|
||||
try:
|
||||
asyncio.run_coroutine_threadsafe(message.reply(content=res), client.loop)
|
||||
except:
|
||||
raise
|
||||
res = asyncio.run_coroutine_threadsafe(message.reply(content=res), client.loop)
|
||||
res.result()
|
||||
except BaseException as e:
|
||||
print("[System-Error] 回复QQ消息失败")
|
||||
raise e
|
||||
else:
|
||||
asyncio.run_coroutine_threadsafe(message.reply(image=res, content=""), client.loop)
|
||||
|
||||
@@ -574,7 +577,7 @@ def oper_msg(message, at=False, loop=None):
|
||||
gap_chatgpt_res = gap_chatgpt_res.replace(i, "***")
|
||||
# 发送信息
|
||||
send_qq_msg(message, ''+gap_chatgpt_res)
|
||||
except:
|
||||
except BaseException as e:
|
||||
print("QQ频道API错误: \n"+str(e))
|
||||
f_res = ""
|
||||
for t in chatgpt_res:
|
||||
@@ -582,7 +585,7 @@ def oper_msg(message, at=False, loop=None):
|
||||
try:
|
||||
send_qq_msg(message, ''+f_res)
|
||||
# send(message, f"QQ频道API错误:{str(e)}\n下面是格式化后的回答:\n{f_res}")
|
||||
except:
|
||||
except BaseException as e:
|
||||
# 如果还是不行则过滤url
|
||||
f_res = re.sub(r'(https|http)?:\/\/(\w|\.|\/|\?|\=|\&|\%)*\b', '', f_res, flags=re.MULTILINE)
|
||||
f_res = f_res.replace(".", "·")
|
||||
|
||||
Reference in New Issue
Block a user