调整答题思路,新群自动完成提醒
This commit is contained in:
@@ -193,15 +193,34 @@ class GameTaskPlugin(MessagePluginInterface):
|
|||||||
# 获取群内所有玩家
|
# 获取群内所有玩家
|
||||||
players = self.encyclopedia_db.get_all_players_in_group(roomid)
|
players = self.encyclopedia_db.get_all_players_in_group(roomid)
|
||||||
|
|
||||||
|
# 如果群里没有玩家,自动初始化并添加当前用户
|
||||||
if not players:
|
if not players:
|
||||||
|
# 检查并添加群聊
|
||||||
|
if not self.encyclopedia_db.check_group_exists(roomid):
|
||||||
|
self.encyclopedia_db.add_group(roomid)
|
||||||
|
self.message_util.send_text_msg(
|
||||||
|
f"🎉 群 {roomid} 已就位,准备开燥!",
|
||||||
|
(roomid if roomid else sender),
|
||||||
|
sender
|
||||||
|
)
|
||||||
|
|
||||||
|
# 获取用户昵称 (从all_contacts中获取可能不可行,因为这里没有all_contacts参数)
|
||||||
|
# 使用sender作为临时昵称
|
||||||
|
wx_nick_name = sender
|
||||||
|
|
||||||
|
# 添加当前用户为玩家
|
||||||
|
self.encyclopedia_db.add_player(sender, roomid, wx_nick_name)
|
||||||
self.message_util.send_text_msg(
|
self.message_util.send_text_msg(
|
||||||
f"😔 哎呀,群 {roomid} 静悄悄\n"
|
f"🎉 哇塞,{wx_nick_name} 你是第一个玩家!\n"
|
||||||
f"🌟 快拉小伙伴来嗨吧!",
|
f"🌟 已自动为你加入游戏!\n"
|
||||||
|
f"🎈 现在就为你准备题目...",
|
||||||
(roomid if roomid else sender),
|
(roomid if roomid else sender),
|
||||||
sender
|
sender
|
||||||
)
|
)
|
||||||
return
|
|
||||||
|
# 更新玩家列表
|
||||||
|
players = self.encyclopedia_db.get_all_players_in_group(roomid)
|
||||||
|
|
||||||
player_dict = {p['player_id']: p['player_name'] for p in players}
|
player_dict = {p['player_id']: p['player_name'] for p in players}
|
||||||
if sender not in player_dict:
|
if sender not in player_dict:
|
||||||
self.message_util.send_text_msg(
|
self.message_util.send_text_msg(
|
||||||
@@ -212,6 +231,7 @@ class GameTaskPlugin(MessagePluginInterface):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 以下是原有的出题逻辑
|
||||||
task = game_question_json("请出题!")
|
task = game_question_json("请出题!")
|
||||||
category = task["category"]
|
category = task["category"]
|
||||||
question = task["question"]
|
question = task["question"]
|
||||||
|
|||||||
Reference in New Issue
Block a user