Fix
This commit is contained in:
parent
1b7aea4320
commit
f11df72b0b
2 changed files with 12 additions and 13 deletions
|
@ -6,6 +6,7 @@ import card as c
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from telegram import Message, Chat
|
from telegram import Message, Chat
|
||||||
|
from telegram.ext import CallbackContext
|
||||||
|
|
||||||
from config import TIME_REMOVAL_AFTER_SKIP, MIN_FAST_TURN_TIME
|
from config import TIME_REMOVAL_AFTER_SKIP, MIN_FAST_TURN_TIME
|
||||||
from errors import DeckEmptyError, NotEnoughPlayersError
|
from errors import DeckEmptyError, NotEnoughPlayersError
|
||||||
|
@ -205,9 +206,9 @@ def start_player_countdown(bot, game, job_queue):
|
||||||
player.game.job = job
|
player.game.job = job
|
||||||
|
|
||||||
|
|
||||||
def skip_job(bot, job):
|
def skip_job(context: CallbackContext):
|
||||||
player = job.context.player
|
player = context.job.context.player
|
||||||
game = player.game
|
game = player.game
|
||||||
if game_is_running(game):
|
if game_is_running(game):
|
||||||
job_queue = job.context.job_queue
|
job_queue = context.job.context.job_queue
|
||||||
do_skip(bot, player, job_queue)
|
do_skip(context.bot, player, job_queue)
|
||||||
|
|
16
bot.py
16
bot.py
|
@ -299,16 +299,15 @@ def select_game(update: Update, context: CallbackContext):
|
||||||
text=_("Game not found."))
|
text=_("Game not found."))
|
||||||
return
|
return
|
||||||
|
|
||||||
@run_async
|
def selected():
|
||||||
def selected(bot):
|
|
||||||
back = [[InlineKeyboardButton(text=_("Back to last group"),
|
back = [[InlineKeyboardButton(text=_("Back to last group"),
|
||||||
switch_inline_query='')]]
|
switch_inline_query='')]]
|
||||||
context.bot.answerCallbackQuery(update.callback_query.id,
|
dispatcher.run_async(context.bot.answerCallbackQuery, update.callback_query.id,
|
||||||
text=_("Please switch to the group you selected!"),
|
text=_("Please switch to the group you selected!"),
|
||||||
show_alert=False,
|
show_alert=False,
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
|
||||||
context.bot.editMessageText(chat_id=update.callback_query.message.chat_id,
|
dispatcher.run_async(context.bot.editMessageText, chat_id=update.callback_query.message.chat_id,
|
||||||
message_id=update.callback_query.message.message_id,
|
message_id=update.callback_query.message.message_id,
|
||||||
text=_("Selected group: {group}\n"
|
text=_("Selected group: {group}\n"
|
||||||
"<b>Make sure that you switch to the correct "
|
"<b>Make sure that you switch to the correct "
|
||||||
|
@ -318,7 +317,7 @@ def select_game(update: Update, context: CallbackContext):
|
||||||
parse_mode=ParseMode.HTML,
|
parse_mode=ParseMode.HTML,
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
|
||||||
selected(bot)
|
selected()
|
||||||
|
|
||||||
|
|
||||||
@game_locales
|
@game_locales
|
||||||
|
@ -383,15 +382,14 @@ def start_game(update: Update, context: CallbackContext):
|
||||||
multi=game.translate)
|
multi=game.translate)
|
||||||
.format(name=display_name(game.current_player.user)))
|
.format(name=display_name(game.current_player.user)))
|
||||||
|
|
||||||
@run_async
|
|
||||||
def send_first():
|
def send_first():
|
||||||
"""Send the first card and player"""
|
"""Send the first card and player"""
|
||||||
|
|
||||||
context.bot.sendSticker(chat.id,
|
dispatcher.run_async(context.bot.sendSticker, chat.id,
|
||||||
sticker=c.STICKERS[str(game.last_card)],
|
sticker=c.STICKERS[str(game.last_card)],
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
|
||||||
context.bot.sendMessage(chat.id,
|
dispatcher.run_async(context.bot.sendMessage, chat.id,
|
||||||
text=first_message,
|
text=first_message,
|
||||||
reply_markup=InlineKeyboardMarkup(choice),
|
reply_markup=InlineKeyboardMarkup(choice),
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
@ -702,7 +700,7 @@ def process_result(update: Update, context: CallbackContext):
|
||||||
send_async(context.bot, chat.id,
|
send_async(context.bot, chat.id,
|
||||||
text=nextplayer_message,
|
text=nextplayer_message,
|
||||||
reply_markup=InlineKeyboardMarkup(choice))
|
reply_markup=InlineKeyboardMarkup(choice))
|
||||||
start_player_countdown(context.bot, game, job_queue)
|
start_player_countdown(context.bot, game, context.job_queue)
|
||||||
|
|
||||||
|
|
||||||
def reset_waiting_time(bot, player):
|
def reset_waiting_time(bot, player):
|
||||||
|
|
Loading…
Reference in a new issue