def out_fielder_update_listner(match_id, chat_id, request, fielder): bot = BotDatabase(match_id) response = bot.out_fielder_update(fielder) if response["type"] == 'ask_next_batsman': batsman_list = bot.get_available_batsman() TelegramHelper.send_keyboard_message(chat_id, "Next Batsman?", batsman_list) return json.dumps({}) elif response["type"] == "end": BotDatabase.set_match_status(match_id=match_id, from_status="live", to_status="end") clear = Helper.clear_contexts(match_id, request) TelegramHelper.remove_keyboard(chat_id) return clear elif response["type"] == "change": TelegramHelper.send_keyboard_general(chat_id, "change innings?", [[{ "text": "change" }, { "text": "Undo" }]]) return json.dumps({}) return json.dumps(response['response'])
def match_innings_change(): match_id = Helper.get_match_params(request)['match_id'] chat_id = request['originalDetectIntentRequest']['payload']['data'][ 'chat']['id'] bot = BotDatabase(match_id) batsman_list = bot.get_available_batsman() TelegramHelper.send_keyboard_message(chat_id, "strike-batsman name?", batsman_list)
def add_players_action(team_name, team_players_list, match_id, chat_id, intent_name): bot = BotDatabase(match_id) bot.add_players(team_name, team_players_list) if intent_name == 'match.team2players': batsman_list = bot.get_available_batsman() TelegramHelper.send_keyboard_message(chat_id, "strike-batsman name?", batsman_list) return json.dumps({})
def update_on_strike_batsmen_listener(batsman, match_id, chat_id, batsman_type): bot = BotDatabase(match_id) bot.on_strike_batsmen_update(batsman, batsman_type) player_list = [] if batsman_type == "strike_batsman": player_list = bot.get_available_batsman() TelegramHelper.send_keyboard_message(chat_id, "non-strike batsman?", player_list) else: player_list = bot.get_available_bowlers() TelegramHelper.send_keyboard_message(chat_id, "Opening Bowler?", player_list) return json.dumps({})