def users(update, _): if update.message.chat.id in sql.get_dev_id(): message = text.USERS_HEADING_TEXT for user_id, nick in sql.get_users_table(): message += text.USERS_TEXT.format(id=user_id, nick=nick) update.message.reply_markdown(text=message) else: update.message.reply_markdown(text=text.ACCESS_DENIED_TEXT)
def msg(update, context): if update.message.chat.id in sql.get_dev_id(): users_id = [user_data[0] for user_data in sql.get_users_table()] for user_id in users_id: try: context.bot.send_message(chat_id=user_id, text=" ".join(context.args), parse_mode=ParseMode.MARKDOWN) except error.BadRequest: pass
def send_letter(update, context): if len(update.message.text) > config.LETTER_MAX_LEN: update.message.reply_markdown(text=text.ERROR_LETTER, reply_markup=menu.show(menu=text.BACK)) return state.LETTER else: developers = sql.get_dev_id() player_nick = sql.get_from_table(telegram_id=update.message.chat.id, table="users", field="nick") for developer in developers: try: context.bot.send_message(chat_id=developer, text=(text.LETTER_HEADING + update.message.text).format(nick=player_nick), parse_mode=ParseMode.MARKDOWN) except TelegramError: continue update.message.reply_markdown(text=text.LETTER_SEND, reply_markup=menu.show(menu=text.INFO)) return state.INFO
def game(update, context): if context.user_data["in_game_flag"]: return state.TWENTY_ONE try: chips_bet = int(update.message.text) except ValueError: update.message.reply_markdown( text=text.ENTER_ERROR_MESSAGE.format(min=text.three_digits(n=config.MIN_CHIPS_FOR_TWENTY_ONE))) return state.TWENTY_ONE_ENTER_BET else: if chips_bet <= 0: update.message.reply_markdown( text=text.ENTER_ERROR_MESSAGE.format(min=text.three_digits(n=config.MIN_CHIPS_FOR_TWENTY_ONE))) return state.TWENTY_ONE_ENTER_BET chips_in_balance = sql.chips_in_balance(telegram_id=update.message.chat.id) if chips_bet > chips_in_balance: update.message.reply_markdown(text=text.FEW_CHIPS_FOR_BET) return state.TWENTY_ONE_ENTER_BET else: context.user_data["in_game_flag"] = True context.user_data["BET"] = chips_bet update.message.reply_markdown(text=text.BET_IS_ACCEPTED) try: context.job_queue.run_once( callback=job_first_cards_message, when=2, context=(update.message.chat.id, context.user_data["data"][1], context.user_data["BET"], context.user_data['BANKER'], context.user_data['YOU'], context.user_data["BOTTOM_CARD"], context.user_data['entry_message_id'])) except TelegramError as mysterious_error: for developer in sql.get_dev_id(): context.bot.send_message(chat_id=developer, text=mysterious_error) return state.TWENTY_ONE
def farm(update, context): if update.message.chat.id in sql.get_dev_id(): args = context.args if len(args) != 1: update.message.reply_text(text=text.FARM_ARGUMENT_ERROR_TEXT) else: try: user_id = int(args[0]) except ValueError: update.message.reply_text(text=text.FARM_INCORRECT_ID_TEXT) else: try: farm_text, ripened_high = generate_farm_text( telegram_id=user_id) except TypeError: update.message.reply_text( text=text.FARM_ID_DOES_NOT_EXIST_TEXT) else: update.message.reply_markdown(text=( text.FARM_BUTTON.join("**") + text.FARM_DESC_START + farm_text + text.FARM_DESC_END.format(all=sum(ripened_high)))) else: update.message.reply_markdown(text=text.ACCESS_DENIED_TEXT)
def players(update, _): if update.message.chat.id in sql.get_dev_id(): update.message.reply_markdown(text=text.PLAYERS_NUMBER_TEXT.format( n=sql.get_players_number())) else: update.message.reply_markdown(text=text.ACCESS_DENIED_TEXT)