尝试签到之后就撤回,防止中断聊天
This commit is contained in:
@@ -7,6 +7,7 @@ from db.connection import DBConnectionManager
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
from plugin_common.plugin_interface import PluginStatus
|
||||
from utils.decorator.plugin_decorators import plugin_stats_decorator
|
||||
from utils.revoke.message_auto_revoke import MessageAutoRevoke
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus, GroupBotManager
|
||||
from db.sign_in import SignInDB
|
||||
from db.sign_in_redis import SignInRedisDB
|
||||
@@ -216,7 +217,7 @@ class MessageSignPlugin(MessagePluginInterface):
|
||||
sender = message.get("sender")
|
||||
roomid = message.get("roomid", "")
|
||||
all_contacts = message.get("all_contacts", {})
|
||||
|
||||
revoke: MessageAutoRevoke = message.get("revoke")
|
||||
try:
|
||||
# 获取当前时间,带有时区信息
|
||||
current_time = datetime.now(tz=pytz.timezone(self.timezone))
|
||||
@@ -237,8 +238,9 @@ class MessageSignPlugin(MessagePluginInterface):
|
||||
|
||||
# 如果 sign_stat 已经大于或等于今天的零点,则认为用户已经签到过了
|
||||
if sign_stat >= today_start:
|
||||
await self.bot.send_text_message(
|
||||
client_msg_id, create_time, new_msg_id = await self.bot.send_text_message(
|
||||
(roomid if roomid else sender), f"您今天已经签到过了!", sender)
|
||||
revoke.add_message_to_revoke(roomid, client_msg_id, create_time, new_msg_id, 4)
|
||||
return False, "已签到"
|
||||
|
||||
# 在_handle_sign_in方法中,修改断签处理逻辑
|
||||
@@ -313,13 +315,18 @@ class MessageSignPlugin(MessagePluginInterface):
|
||||
daily_vocab = self.get_random_vocabulary()
|
||||
output += f"\n今日词汇:{daily_vocab}"
|
||||
|
||||
await self.bot.send_text_message((roomid if roomid else sender), output, sender)
|
||||
client_msg_id, create_time, new_msg_id = await self.bot.send_at_message((roomid if roomid else sender),
|
||||
output, sender)
|
||||
revoke.add_message_to_revoke(roomid, client_msg_id, create_time, new_msg_id, 60)
|
||||
return True, "签到成功"
|
||||
|
||||
except Exception as e:
|
||||
self.LOG.error(f"处理签到请求出错: {e}")
|
||||
await self.bot.send_text_message((roomid if roomid else sender), f"签到出错:{e}",
|
||||
sender)
|
||||
|
||||
client_msg_id, create_time, new_msg_id = await self.bot.send_at_message((roomid if roomid else sender),
|
||||
f"签到出错:{e}",
|
||||
sender)
|
||||
revoke.add_message_to_revoke(roomid, client_msg_id, create_time, new_msg_id, 3)
|
||||
return False, f"处理出错: {e}"
|
||||
|
||||
def reset_today_count_if_needed(self):
|
||||
|
||||
Reference in New Issue
Block a user