Closed prairiewolf11 closed 1 year ago
搞定 pip install revChatGPT
class ChatGPTRobot(AbstractRobot):
SLUG = "ChatGPT"
def __init__(self, email, password, proxy, paid):
"""
ChatGPT机器人
"""
super(self.__class__, self).__init__()
self.proxy = proxy
self.chatbot = Chatbot(config={
"email": email,
"password": password,
"paid": paid
})
@classmethod
def get_config(cls):
# Try to get chatgpt config from config
return config.get("ChatGPT", {})
def chat(self, texts, parsed):
msg = "".join(texts)
msg = utils.stripPunctuation(msg)
logger.info("msg: " + msg)
try:
respond = ""
for data in self.chatbot.ask(msg):
respond = data["message"]
logger.info("{} 回答:{}".format(self.SLUG, respond))
return respond
except Exception:
logger.critical("ChatGPT robot failed to response for %r", msg, exc_info=True)
return "抱歉, ChatGPT回答失败"
.