mirror of
https://github.com/Zippland/Bubbles.git
synced 2026-01-19 01:21:15 +08:00
删除决斗功能
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,5 +10,4 @@ logs/
|
||||
*.log.*
|
||||
|
||||
config.yaml
|
||||
duel_ranks.json
|
||||
data/
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import re
|
||||
import random
|
||||
from typing import Optional, Match, Dict, Any
|
||||
import json # 确保已导入json
|
||||
from datetime import datetime # 确保已导入datetime
|
||||
import os # 导入os模块用于文件路径操作
|
||||
# from function.func_duel import DuelRankSystem
|
||||
|
||||
# 前向引用避免循环导入
|
||||
from typing import TYPE_CHECKING
|
||||
@@ -26,14 +24,6 @@ def handle_help(ctx: 'MessageContext', match: Optional[Match]) -> bool:
|
||||
"- 新闻",
|
||||
"- ask [问题]",
|
||||
"",
|
||||
"【决斗 & 偷袭】",
|
||||
"- 决斗@XX",
|
||||
"- 偷袭@XX",
|
||||
"- 决斗排行/排行榜",
|
||||
"- 我的战绩/决斗战绩",
|
||||
"- 我的装备/查看装备",
|
||||
"- 改名 [旧名] [新名]",
|
||||
"",
|
||||
"【提醒】",
|
||||
"- 提醒xxxxx:一次性、每日、每周",
|
||||
"- 查看提醒/我的提醒/提醒列表",
|
||||
@@ -49,44 +39,6 @@ def handle_help(ctx: 'MessageContext', match: Optional[Match]) -> bool:
|
||||
# 发送消息
|
||||
return ctx.send_text(help_text)
|
||||
|
||||
def handle_check_equipment(ctx: 'MessageContext', match: Optional[Match]) -> bool:
|
||||
"""
|
||||
处理 "查看装备" 命令
|
||||
|
||||
匹配: 我的装备/查看装备
|
||||
"""
|
||||
if not ctx.is_group:
|
||||
ctx.send_text("❌ 装备查看功能只支持群聊")
|
||||
return True
|
||||
|
||||
try:
|
||||
from function.func_duel import DuelRankSystem
|
||||
|
||||
player_name = ctx.sender_name
|
||||
rank_system = DuelRankSystem(ctx.msg.roomid)
|
||||
player_data = rank_system.get_player_data(player_name)
|
||||
|
||||
if not player_data:
|
||||
ctx.send_text(f"⚠️ 没有找到 {player_name} 的数据")
|
||||
return True
|
||||
|
||||
items = player_data.get("items", {"elder_wand": 0, "magic_stone": 0, "invisibility_cloak": 0})
|
||||
result = [
|
||||
f"🧙♂️ {player_name} 的魔法装备:",
|
||||
f"🪄 老魔杖: {items.get('elder_wand', 0)}次 ",
|
||||
f"💎 魔法石: {items.get('magic_stone', 0)}次",
|
||||
f"🧥 隐身衣: {items.get('invisibility_cloak', 0)}次 "
|
||||
]
|
||||
|
||||
ctx.send_text("\n".join(result))
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
if ctx.logger:
|
||||
ctx.logger.error(f"查看装备出错: {e}")
|
||||
ctx.send_text("⚠️ 查看装备失败")
|
||||
return False
|
||||
|
||||
def handle_summary(ctx: 'MessageContext', match: Optional[Match]) -> bool:
|
||||
"""
|
||||
处理 "消息总结" 命令
|
||||
@@ -1109,4 +1061,4 @@ def handle_weather_forecast(ctx: 'MessageContext', match: Optional[Match]) -> bo
|
||||
ctx.logger.error(f"获取城市 {city_name}({city_code}) 天气预报时出错: {e}", exc_info=True)
|
||||
ctx.send_text(f"😥 获取 {city_name} 天气预报时遇到问题,请稍后再试。")
|
||||
|
||||
return True
|
||||
return True
|
||||
|
||||
@@ -2,8 +2,6 @@ import re
|
||||
from .models import Command
|
||||
from .handlers import (
|
||||
handle_help,
|
||||
# handle_duel, handle_sneak_attack, handle_duel_rank,
|
||||
# handle_duel_stats, handle_check_equipment, handle_rename,
|
||||
handle_summary, handle_clear_messages, handle_news_request,
|
||||
handle_chitchat, handle_insult,
|
||||
handle_perplexity_ask, handle_reminder, handle_list_reminders, handle_delete_reminder,
|
||||
@@ -133,4 +131,4 @@ def get_commands_info():
|
||||
return "\n".join(info)
|
||||
|
||||
# 导出所有命令
|
||||
__all__ = ["COMMANDS", "get_commands_info"]
|
||||
__all__ = ["COMMANDS", "get_commands_info"]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
27
robot.py
27
robot.py
@@ -20,7 +20,6 @@ from ai_providers.ai_gemini import Gemini
|
||||
from ai_providers.ai_perplexity import Perplexity
|
||||
from function.func_weather import Weather
|
||||
from function.func_news import News
|
||||
from function.func_duel import start_duel, get_rank_list, get_player_stats, change_player_name, DuelManager, attempt_sneak_attack
|
||||
from function.func_summary import MessageSummary # 导入新的MessageSummary类
|
||||
from function.func_reminder import ReminderManager # 导入ReminderManager类
|
||||
from configuration import Config
|
||||
@@ -54,7 +53,6 @@ class Robot(Job):
|
||||
self.wxid = self.wcf.get_self_wxid() # 获取机器人自己的wxid
|
||||
self.allContacts = self.getAllContacts()
|
||||
self._msg_timestamps = []
|
||||
self.duel_manager = DuelManager(self.sendDuelMsg)
|
||||
|
||||
try:
|
||||
db_path = "data/message_history.db"
|
||||
@@ -416,36 +414,12 @@ class Robot(Job):
|
||||
for r in receivers:
|
||||
self.sendTextMsg(report, r)
|
||||
|
||||
def sendDuelMsg(self, msg: str, receiver: str) -> None:
|
||||
"""发送决斗消息,不受消息频率限制,不记入历史记录
|
||||
:param msg: 消息字符串
|
||||
:param receiver: 接收人wxid或者群id
|
||||
"""
|
||||
try:
|
||||
self.wcf.send_text(f"{msg}", receiver, "")
|
||||
except Exception as e:
|
||||
self.LOG.error(f"发送决斗消息失败: {e}")
|
||||
|
||||
def cleanup_perplexity_threads(self):
|
||||
"""清理所有Perplexity线程"""
|
||||
# 如果已初始化Perplexity实例,调用其清理方法
|
||||
perplexity_instance = self.get_perplexity_instance()
|
||||
if perplexity_instance:
|
||||
perplexity_instance.cleanup()
|
||||
|
||||
# 检查并等待决斗线程结束
|
||||
if hasattr(self, 'duel_manager') and self.duel_manager.is_duel_running():
|
||||
self.LOG.info("等待决斗线程结束...")
|
||||
# 最多等待5秒
|
||||
for i in range(5):
|
||||
if not self.duel_manager.is_duel_running():
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
if self.duel_manager.is_duel_running():
|
||||
self.LOG.warning("决斗线程在退出时仍在运行")
|
||||
else:
|
||||
self.LOG.info("决斗线程已结束")
|
||||
|
||||
def cleanup(self):
|
||||
"""清理所有资源,在程序退出前调用"""
|
||||
@@ -672,4 +646,3 @@ class Robot(Job):
|
||||
|
||||
self.LOG.debug(f"预处理消息: text='{ctx.text}', is_group={ctx.is_group}, is_at_bot={ctx.is_at_bot}, sender='{ctx.sender_name}', is_quoted_image={is_quoted_image}")
|
||||
return ctx
|
||||
|
||||
|
||||
Reference in New Issue
Block a user