feat: 赞赏码发送

This commit is contained in:
Rock Chin
2023-02-10 19:03:25 +08:00
parent 618487947b
commit d72c364962
7 changed files with 44 additions and 2 deletions

View File

@@ -96,6 +96,14 @@ class DataGatherer:
# 遍历其中所有模型,求和
return sum(self.usage[key_md5]["image"].values())
def get_total_text_length(self):
total = 0
for key in self.usage:
if "text" not in self.usage[key]:
continue
total += sum(self.usage[key]["text"].values())
return total
def dump_to_db(self):
pkg.utils.context.get_database_manager().dump_usage_json(self.usage)

View File

@@ -25,6 +25,8 @@ class OpenAIInteract:
self.key_mgr = pkg.openai.keymgr.KeysManager(api_key)
self.audit_mgr = pkg.audit.gatherer.DataGatherer()
logging.info("文字总使用量:%d", self.audit_mgr.get_total_text_length())
openai.api_key = self.key_mgr.get_using_key()
pkg.utils.context.set_openai_manager(self)

View File

@@ -295,3 +295,10 @@ class QQBotManager:
logging.info("通知管理员:{}".format(message))
send_task = self.bot.send_friend_message(config.admin_qq, "[bot]{}".format(message))
threading.Thread(target=asyncio.run, args=(send_task,)).start()
def notify_admin_message_chain(self, message):
config = pkg.utils.context.get_config()
if hasattr(config, "admin_qq") and config.admin_qq != 0:
logging.info("通知管理员:{}".format(message))
send_task = self.bot.send_friend_message(config.admin_qq, message)
threading.Thread(target=asyncio.run, args=(send_task,)).start()

3
pkg/utils/constants.py Normal file

File diff suppressed because one or more lines are too long