Skip to content

Commit 527e232

Browse files
committed
feat: give group admins the ability to stop games in their group
fixes #41
1 parent c0f2aa2 commit 527e232

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

blackjackbot/commands/game/commands.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,16 @@ def stop_cmd(update, context):
8181

8282
game = GameStore().get_game(chat.id)
8383

84+
user_id = user.id
8485
try:
85-
game.stop(user.id)
86+
if chat.type == "group" or chat.type == "supergroup":
87+
# If yes, get the chat admins
88+
admins = context.bot.get_chat_administrators(chat_id=chat.id)
89+
# if user.id in chat admin IDs, let them end the game with admin powers
90+
if user.id in [x.user.id for x in admins]:
91+
user_id = -1
92+
93+
game.stop(user_id)
8694
update.effective_message.reply_text(translator("game_ended"))
8795
except errors.InsufficientPermissionsException:
8896
update.effective_message.reply_text(translator("mp_only_creator_can_end"))

0 commit comments

Comments
 (0)