整理代码
This commit is contained in:
@@ -63,7 +63,7 @@ def assign_random_task(group_id, player_id=None):
|
||||
try:
|
||||
# 获取群内所有玩家
|
||||
players = encyclopedia_db.get_all_players_in_group(group_id)
|
||||
|
||||
|
||||
if not players:
|
||||
message = (
|
||||
f"😔 哎呀,群 {group_id} 静悄悄\n"
|
||||
@@ -152,7 +152,7 @@ def submit_answer(group_id, player_id, task_id, answer):
|
||||
|
||||
# 获取任务信息
|
||||
task_data = encyclopedia_db.get_task_by_id(group_id, active_task_id)
|
||||
|
||||
|
||||
if not task_data:
|
||||
message = (
|
||||
f"😔 哎哟,任务 task_{active_task_id} 不翼而飞啦!\n"
|
||||
@@ -186,10 +186,10 @@ def submit_answer(group_id, player_id, task_id, answer):
|
||||
if is_correct:
|
||||
# 更新玩家积分
|
||||
encyclopedia_db.update_player_points(player_id, group_id, points)
|
||||
|
||||
|
||||
# 完成任务
|
||||
encyclopedia_db.complete_task(active_task_id)
|
||||
|
||||
|
||||
if player_id == holder_id:
|
||||
message = (
|
||||
f"🎉 {player_name} 你是天才吗?\n"
|
||||
@@ -249,14 +249,14 @@ def show_rank(group_id, player_id):
|
||||
try:
|
||||
# 获取排行榜
|
||||
ranks = encyclopedia_db.get_player_ranking(group_id, 10)
|
||||
|
||||
|
||||
if not ranks:
|
||||
message = (
|
||||
f"😔 群 {group_id} 冷冷清清\n"
|
||||
f"🌟 快来一起燥起来吧!"
|
||||
)
|
||||
return {"message": message, "player_id": player_id}
|
||||
|
||||
|
||||
rank_text = f"🎉 群 {group_id} 排行榜(Top 10)来啦!\n"
|
||||
for i, row in enumerate(ranks, 1):
|
||||
rank_text += f"🐓 {i}. {row['player_name']}: {row['points']} 分\n"
|
||||
@@ -272,14 +272,14 @@ def show_active_tasks(group_id, player_id):
|
||||
try:
|
||||
# 获取活跃任务
|
||||
tasks = encyclopedia_db.get_active_tasks_in_group(group_id)
|
||||
|
||||
|
||||
if not tasks:
|
||||
message = (
|
||||
f"😄 群 {group_id} 现在一片祥和\n"
|
||||
f"🌟 没任务?快用 /t 搞一个!"
|
||||
)
|
||||
return {"message": message, "player_id": player_id}
|
||||
|
||||
|
||||
task_text = f"🎉 群 {group_id} 活跃任务速递:\n"
|
||||
for task in tasks:
|
||||
task_text += (
|
||||
@@ -299,14 +299,14 @@ def list_uncompleted_tasks(group_id, player_id):
|
||||
try:
|
||||
# 获取未完成任务
|
||||
tasks = encyclopedia_db.get_active_tasks_in_group(group_id)
|
||||
|
||||
|
||||
if not tasks:
|
||||
message = (
|
||||
f"😄 群 {group_id} 全员开挂?\n"
|
||||
f"🌟 没未完成任务,快用 /t 再战!"
|
||||
)
|
||||
return {"message": message, "player_id": player_id}
|
||||
|
||||
|
||||
task_text = f"🎉 群 {group_id} 未完成任务大曝光:\n"
|
||||
for task in tasks:
|
||||
task_text += (
|
||||
@@ -425,4 +425,4 @@ if __name__ == "__main__":
|
||||
# 测试用例
|
||||
print(game_process_message("45317011307@chatroom", "Jyunere", "/t")) # 新用户获取任务
|
||||
print(game_process_message("45317011307@chatroom", "Jyunere", "/a 18 罗马斗兽场")) # 提交答案
|
||||
print(game_process_message("45317011307@chatroom", "Jyunere", "/r")) # 查看排行榜
|
||||
print(game_process_message("45317011307@chatroom", "Jyunere", "/r")) # 查看排行榜
|
||||
|
||||
17
robot.py
17
robot.py
@@ -1,19 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import importlib
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import xml.etree.ElementTree as ET
|
||||
from queue import Empty
|
||||
from threading import Thread
|
||||
from datetime import datetime, timedelta
|
||||
import random
|
||||
from typing import Optional
|
||||
|
||||
import redis
|
||||
|
||||
from base.func_doubao import Doubao
|
||||
from base.func_epic import is_friday, get_free
|
||||
@@ -33,8 +25,7 @@ from configuration import Config
|
||||
from constants import ChatType
|
||||
from dify.dify_chat import DifyChat
|
||||
from douyin_parser.main import DouyinParser
|
||||
from game_task.game_task_encyclopedia import game_process_message, setup_schedule, get_group_ids, \
|
||||
run_random_task_assignment
|
||||
from game_task.game_task_encyclopedia import game_process_message, get_group_ids,run_random_task_assignment
|
||||
from group_add.main import GroupAdd
|
||||
from group_auto.group_auto_invite import get_first_group_id, process_command
|
||||
from group_auto.group_member_change import GroupMemberChange
|
||||
@@ -46,7 +37,7 @@ from message_summary.message_summary_dify import message_summary_dify
|
||||
from music.bot_music import BotMusic
|
||||
from plugin_common.event_system import EventType, EventSystem
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginInterface, PluginStatus
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
from plugin_common.plugin_manager import PluginManager
|
||||
from plugin_common.plugin_registry import PluginRegistry
|
||||
from point_trade.main import PointTrade
|
||||
@@ -59,8 +50,8 @@ __version__ = "39.2.4.0"
|
||||
|
||||
from sehuatang.shehuatang import pdf_file_path
|
||||
from xiuren.main import Xiuren
|
||||
from xiuren.meitu_dl import meitu_dowload_pic, meitu_dowload_pub_pic, meitu_dowload_heisi_pic
|
||||
from xiuren.random_pic import get_xiuren_pic, get_xiuren_heisi_pic
|
||||
from xiuren.meitu_dl import meitu_dowload_pub_pic
|
||||
from xiuren.random_pic import get_xiuren_heisi_pic
|
||||
from xiuren.xiuren_pdf import generate_pdf_from_images
|
||||
|
||||
from db.connection import DBConnectionManager
|
||||
|
||||
Reference in New Issue
Block a user