def chat_stats(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message if (not is_group): sendtext = other.proc(other.getl(lang).error_onlyGroup) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return text = other.proc( other.getl(lang).command_chat_stats, [f'{message.chat.title}']) i = 0 for item in sorted(variables.groups[ind].chatMembers, key=lambda e: e.balance, reverse=True): i += 1 text += other.proc( other.getl(lang).per_group, [f'{i}', f'{item.name}', f'{item.balance}']) if (i == 11): break context.bot.send_message(message.chat.id, text, parse_mode='HTML')
def global_stats(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message text = other.proc(other.getl(lang).command_global_stats) i = 0 for item in sorted(variables.users, key=lambda e: e.balance, reverse=True): i += 1 text += other.proc( other.getl(lang).per_group, [f'{i}', f'{item.name}', f'{item.balance}']) if (i == 11): break context.bot.send_message(message.chat.id, text, parse_mode='HTML')
def randomNumber(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message ab = message.text.split(' ') if (len(ab) == 1): sendtext = other.proc(other.getl(lang).error_random_noNumbers) context.bot.send_message(message.chat.id, sendtext) return numbers = [int(item) for item in ab[1].split('-')] sendtext = other.proc( other.getl(lang).command_random, [ f'{numbers[0]}', f'{numbers[1]}', f'{random.randint(numbers[0], numbers[1])}' ]) context.bot.send_message(message.chat.id, sendtext, parse_mode='HTML')
def help(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message sendtext = other.proc(other.getl(lang).command_help) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id, parse_mode='HTML')
def flip(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message ab = message.text.split(' ') coins = ('орёл', 'решка') sendtext = other.proc( other.getl(lang).command_flip, [f'{coins[random.randint(0,1)]}']) context.bot.send_message(message.chat.id, sendtext, parse_mode='HTML')
def bonus(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message if (not variables.users[uind].bonusReady): sendtext = other.proc( other.getl(lang).error_bonus_notReady, [f'{variables.BONUS_DELAY}']) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (variables.users[uind].balance > variables.BONUS_VALUE): sendtext = other.proc( other.getl(lang).error_bonus_tooManyCoins, [f'{variables.BONUS_VALUE}']) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return def bonusTick(context: CallbackContext): uind = int(context.job.context) variables.users[uind].bonusReady = True variables.users[uind].bonusReady = False variables.users[uind].balance += variables.BONUS_VALUE context.bot.send_message(message.chat.id, other.proc( other.getl(lang).command_bonus, [f'{variables.BONUS_VALUE}']), reply_to_message_id=message.message_id, parse_mode='HTML') context.job_queue.run_once(bonusTick, 60 * variables.BONUS_DELAY, name=f'bonus{variables.users[uind].id}', context=f'{uind}') from db import datab datab.InsertOrUpdateUsersTable(variables.users[uind].id, variables.users[uind].name, variables.users[uind].username, variables.users[uind].balance, variables.users[uind].gamesplayed)
def gachi(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message ab = message.text.split(' ') if (len(ab) == 1): joinchar = '\n' sendtext = other.proc( other.getl(lang).error_gachi_noText, [ f'{joinchar.join([f"<b>{item}</b>" for item in variables.gachi.keys()])}' ]) context.bot.send_message(message.chat.id, sendtext, parse_mode='HTML') return file_path = '' for item in variables.gachi.keys(): if (item.startswith(' '.join(ab[1:]))): file_path = variables.gachi[item] break if (file_path == ''): sendtext = other.proc(other.getl(lang).error_gachi_notFound) context.bot.send_message(message.chat.id, sendtext) return context.bot.send_audio(message.chat.id, open(file_path, 'rb'))
def rock(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message ab = message.text.split(' ') if (not is_group): sendtext = other.proc(other.getl(lang).error_onlyGroup) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (len(ab) == 1): sendtext = other.proc(other.getl(lang).error_bandit_coinsNotEntered) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (int(ab[1]) <= 0): sendtext = other.proc(other.getl(lang).error_bandit_wrongNumberOfCoins) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (int(ab[1]) > variables.users[uind].balance): sendtext = other.proc(other.getl(lang).error_noCoins) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (variables.groups[ind].isPlaying): sendtext = other.proc(other.getl(lang).error_alreadyPlaying) context.bot.send_message(message.chat.id, sendtext) return variables.groups[ind].rock.coins = int(ab[1]) print(''.join(sorted(variables.groups[ind].rock.icons))) ik = InlineKeyboardMarkup([[ InlineKeyboardButton( text='✂', callback_data=f'{variables.groups[ind].id} rock 1'), InlineKeyboardButton( text='🕳', callback_data=f'{variables.groups[ind].id} rock 2'), InlineKeyboardButton( text='📄', callback_data=f'{variables.groups[ind].id} rock 3') ]]) variables.groups[ind].rock.isPlaying = True variables.groups[ind].isPlaying = True sendtext = other.proc( other.getl(lang).command_rock, [ f'{variables.groups[ind].rock.players[0][1] if variables.groups[ind].rock.players[0] is not None else None}', f'{variables.groups[ind].rock.players[0][2] if variables.groups[ind].rock.players[0] is not None else None}', f'{variables.groups[ind].rock.players[1][1] if variables.groups[ind].rock.players[1] is not None else None}', f'{variables.groups[ind].rock.players[1][2] if variables.groups[ind].rock.players[1] is not None else None}' ]) context.bot.send_message(variables.groups[ind].id, sendtext, reply_markup=ik)
def pic(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message ab = message.text.split(' ') if (len(ab) == 1): sendtext = other.proc(other.getl(lang).error_pic_noTag) context.bot.send_message(message.chat.id, sendtext, parse_mode='HTML') return client = Danbooru('danbooru') temp = None if (ab[1] == 'hentai'): temp = client.post_list(tags='rating:e', page=random.randint(1, 200), limit=1)[0] elif (ab[1] == 'anime'): temp = client.post_list(tags='rating:s', page=random.randint(1, 200), limit=1)[0] elif (ab[1] == 'ecchi'): temp = client.post_list(tags='rating:q', page=random.randint(1, 200), limit=1)[0] elif (ab[1] == 'yuri'): temp = client.post_list(tags='yuri', page=random.randint(1, 200), limit=1)[0] elif (ab[1] == 'uncensored'): temp = client.post_list(tags='uncensored', page=random.randint(1, 200), limit=1)[0] elif (ab[1] == 'neko'): temp = client.post_list(tags='cat_ears', page=random.randint(1, 200), limit=1)[0] elif (ab[1] == 'wallpaper'): temp = client.post_list(tags='wallpaper', page=random.randint(1, 200), limit=1)[0] context.bot.send_photo(message.chat.id, temp['file_url'], caption='Tags: ' + temp['tag_string']) print('done')
def checkCallback(update: Update, context: CallbackContext): while(True): #for #break # ab[0] = id чата, который инициировал запрос # ab[1] = тип запроса # ab[x>=2] = доп данные запроса callbackAnswer = '' callback = update.callback_query ab = callback.data.split(' ') ind = other.getGroupIndexFromGroupsList(int(ab[0])) uind = other.getUserIndexFromUsersList(callback.from_user.id) lang = variables.groups[ind].language # checking, do we have this user if (uind is None): variables.users.append( variables.User(id=callback.from_user.id, name=callback.from_user.first_name, username=callback.from_user.username)) uind = len(variables.users)-1 if (variables.users[uind] not in variables.groups[ind].chatMembers): variables.groups[ind].chatMembers.append(variables.users[uind]) #xo if(variables.groups[ind].xo.isPlaying): if(ab[1] == 'xo'): index = int(ab[2])-1 ik = callback.message.reply_markup flag = False if(None in variables.groups[ind].xo.players): if(variables.groups[ind].xo.field[index] == 0): flag = True if (variables.users[uind].balance < variables.groups[ind].rock.coins): callbackAnswer += other.proc(other.getl(lang).error_noCoins) + '\n' break if(variables.groups[ind].xo.steps % 2 == 0) and (variables.groups[ind].xo.players[0] is None): variables.groups[ind].xo.field[index] = 1 variables.groups[ind].xo.players[0] = [callback.from_user.id, callback.from_user.full_name] elif(variables.groups[ind].xo.steps % 2 == 1) and (variables.groups[ind].xo.players[1] is None): variables.groups[ind].xo.field[index] = 2 variables.groups[ind].xo.players[1] = [callback.from_user.id, callback.from_user.full_name] else: if(variables.groups[ind].xo.field[index] == 0): flag = True if(variables.groups[ind].xo.steps % 2 == 0) and (callback.from_user.id == variables.groups[ind].xo.players[0][0]): variables.groups[ind].xo.field[index] = 1 elif(variables.groups[ind].xo.steps % 2 == 1) and (callback.from_user.id == variables.groups[ind].xo.players[1][0]): variables.groups[ind].xo.field[index] = 2 if(flag): variables.groups[ind].xo.steps += 1 sendtext = other.proc(other.getl(variables.groups[ind].language).command_xo, [f'{variables.groups[ind].xo.players[0][1] if variables.groups[ind].xo.players[0] is not None else None}', f'{variables.groups[ind].xo.players[1][1] if variables.groups[ind].xo.players[1] is not None else None}', f'{variables.groups[ind].xo.steps}', f'{"❌" if variables.groups[ind].xo.steps % 2 == 0 else "⭕"}']) for i in range(len(ik.inline_keyboard)): for j in range(len(ik.inline_keyboard[i])): ik.inline_keyboard[i][j].text = '❌' if variables.groups[ind].xo.field[3*i+j] == 1 else '⭕' if variables.groups[ind].xo.field[3*i+j] == 2 else '✨' win = None if(variables.groups[ind].xo.steps >= 4): for i in range(3): if(variables.groups[ind].xo.field[i+(i*2)] == variables.groups[ind].xo.field[i+1+(i*2)] == variables.groups[ind].xo.field[i+2+(i*2)] == 1)\ or (variables.groups[ind].xo.field[i] == variables.groups[ind].xo.field[i+3] == variables.groups[ind].xo.field[i+6] == 1): win = variables.groups[ind].xo.players[0] elif(variables.groups[ind].xo.field[i+(i*2)] == variables.groups[ind].xo.field[i+1+(i*2)] == variables.groups[ind].xo.field[i+2+(i*2)] == 2)\ or (variables.groups[ind].xo.field[i] == variables.groups[ind].xo.field[i+3] == variables.groups[ind].xo.field[i+6] == 2): win = variables.groups[ind].xo.players[1] if(variables.groups[ind].xo.field[0] == variables.groups[ind].xo.field[4] == variables.groups[ind].xo.field[8] == 1)\ or (variables.groups[ind].xo.field[6] == variables.groups[ind].xo.field[4] == variables.groups[ind].xo.field[2] == 1): win = variables.groups[ind].xo.players[0] elif(variables.groups[ind].xo.field[0] == variables.groups[ind].xo.field[4] == variables.groups[ind].xo.field[8] == 2)\ or (variables.groups[ind].xo.field[6] == variables.groups[ind].xo.field[4] == variables.groups[ind].xo.field[2] == 2): win = variables.groups[ind].xo.players[1] if(win is None) and (variables.groups[ind].xo.steps < 9): context.bot.edit_message_text(sendtext, callback.message.chat.id, callback.message.message_id, reply_markup = ik) else: field = '' for item in variables.groups[ind].xo.field: if(item == 1): field += '❌' elif(item==2): field+= '⭕' elif(item == 0): field += '✨' if(len(field.replace('\n', '')) % 3 == 0): field+='\n' from db import datab uind1 = other.getUserIndexFromUsersList(variables.groups[ind].xo.players[0][0]) uind2 = other.getUserIndexFromUsersList(variables.groups[ind].xo.players[1][0]) variables.users[uind1].gamesplayed += 1 variables.users[uind2].gamesplayed += 1 if(win is not None): variables.users[uind1].balance += variables.groups[ind].xo.coins if win == variables.groups[ind].xo.players[0] else -variables.groups[ind].xo.coins variables.users[uind2].balance += variables.groups[ind].xo.coins if win == variables.groups[ind].xo.players[1] else -variables.groups[ind].xo.coins datab.InsertOrUpdateUsersTable(variables.users[uind1].id, variables.users[uind1].name, variables.users[uind1].username, variables.users[uind1].balance, variables.users[uind1].gamesplayed) datab.InsertOrUpdateUsersTable(variables.users[uind2].id, variables.users[uind2].name, variables.users[uind2].username, variables.users[uind2].balance, variables.users[uind2].gamesplayed) variables.groups[ind].gamesplayed += 1 variables.groups[ind].xo = variables.xo() variables.groups[ind].isPlaying = False datab.InsertOrUpdateGroupsTable(variables.groups[ind].id, variables.groups[ind].name, context.bot.get_chat_members_count(variables.groups[ind].id), variables.groups[ind].chatMembers) context.bot.edit_message_text(sendtext + f'\n\nПобедитель: <b>{win[1] if win is not None else other.proc(other.getl(variables.groups[ind].language).draw)}</b>\n{field}', callback.message.chat.id, callback.message.message_id, parse_mode='HTML') #rock if(variables.groups[ind].rock.isPlaying): if(ab[1] == 'rock'): if(None in variables.groups[ind].rock.players): if (variables.users[uind].balance < variables.groups[ind].rock.coins): callbackAnswer += other.proc(other.getl(lang).error_noCoins) + '\n' break if(variables.groups[ind].rock.players[0] is None): variables.groups[ind].rock.players[0] = [callback.from_user.id, callback.from_user.full_name, variables.groups[ind].rock.icons[int(ab[2])-1]] variables.groups[ind].rock.chosen += variables.groups[ind].rock.icons[int(ab[2])-1] elif(variables.groups[ind].rock.players[1] is None): variables.groups[ind].rock.players[1] = [callback.from_user.id, callback.from_user.full_name, variables.groups[ind].rock.icons[int(ab[2])-1]] variables.groups[ind].rock.chosen += variables.groups[ind].rock.icons[int(ab[2])-1] if(None not in variables.groups[ind].rock.players): sendtext = other.proc(other.getl(variables.groups[ind].language).command_rock, [ f'{variables.groups[ind].rock.players[0][1] if variables.groups[ind].rock.players[0] is not None else None}', f'{variables.groups[ind].rock.players[0][2] if variables.groups[ind].rock.players[0] is not None else None}', f'{variables.groups[ind].rock.players[1][1] if variables.groups[ind].rock.players[1] is not None else None}', f'{variables.groups[ind].rock.players[1][2] if variables.groups[ind].rock.players[1] is not None else None}']) win = None #'✂🕳📄' variables.groups[ind].rock.chosen = ''.join(sorted(variables.groups[ind].rock.chosen)) text = '' if(variables.groups[ind].rock.chosen == '✂📄'): win = variables.groups[ind].rock.players[0] if variables.groups[ind].rock.players[0][2] == '✂' else variables.groups[ind].rock.players[1] text = 'Ножницы режут бумагу!' elif (variables.groups[ind].rock.chosen == '✂🕳'): win = variables.groups[ind].rock.players[0] if variables.groups[ind].rock.players[0][ 2] == '🕳' else variables.groups[ind].rock.players[1] text = 'Дыра захватывает ножницы!' elif (variables.groups[ind].rock.chosen == '📄🕳'): win = variables.groups[ind].rock.players[0] if variables.groups[ind].rock.players[0][ 2] == '📄' else variables.groups[ind].rock.players[1] text = 'Бумага закрывает собой дыру!' elif(variables.groups[ind].rock.chosen[0] == variables.groups[ind].rock.chosen[1]): text = 'Эээээ...' from db import datab uind1 = other.getUserIndexFromUsersList(variables.groups[ind].rock.players[0][0]) uind2 = other.getUserIndexFromUsersList(variables.groups[ind].rock.players[1][0]) variables.users[uind1].gamesplayed += 1 variables.users[uind2].gamesplayed += 1 if(win is not None):#win 1 - win 2 if (win[0] == variables.groups[ind].rock.players[0][0]): variables.users[uind1].balance += variables.groups[ind].rock.coins variables.users[uind2].balance -= variables.groups[ind].rock.coins else: variables.users[uind1].balance -= variables.groups[ind].rock.coins variables.users[uind2].balance += variables.groups[ind].rock.coins datab.InsertOrUpdateUsersTable(variables.users[uind1].id, variables.users[uind1].name, variables.users[uind1].username, variables.users[uind1].balance, variables.users[uind1].gamesplayed) datab.InsertOrUpdateUsersTable(variables.users[uind2].id, variables.users[uind2].name, variables.users[uind2].username, variables.users[uind2].balance, variables.users[uind2].gamesplayed) variables.groups[ind].gamesplayed += 1 variables.groups[ind].rock = variables.rock() variables.groups[ind].isPlaying = False datab.InsertOrUpdateGroupsTable(variables.groups[ind].id, variables.groups[ind].name, context.bot.get_chat_members_count(variables.groups[ind].id), variables.groups[ind].chatMembers) context.bot.edit_message_text(sendtext + f'\n\nПобедитель: <b>{win[1] if win is not None else other.proc(other.getl(variables.groups[ind].language).draw)}</b>\n<i>{text}</i>', variables.groups[ind].id, callback.message.message_id, parse_mode='HTML') break context.bot.answer_callback_query(callback.id, callbackAnswer, show_alert=True)
def xo(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message ab = message.text.split(' ') if (not is_group): sendtext = other.proc(other.getl(lang).error_onlyGroup) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (len(ab) == 1): sendtext = other.proc(other.getl(lang).error_bandit_coinsNotEntered) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (int(ab[1]) <= 0): sendtext = other.proc(other.getl(lang).error_bandit_wrongNumberOfCoins) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (int(ab[1]) > variables.users[uind].balance): sendtext = other.proc(other.getl(lang).error_noCoins) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (variables.groups[ind].isPlaying): sendtext = other.proc(other.getl(lang).error_alreadyPlaying) context.bot.send_message(message.chat.id, sendtext) return variables.groups[ind].xo.coins = int(ab[1]) ik = InlineKeyboardMarkup( [[ InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 1'), InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 2'), InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 3') ], [ InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 4'), InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 5'), InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 6') ], [ InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 7'), InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 8'), InlineKeyboardButton( text='✨', callback_data=f'{variables.groups[ind].id} xo 9') ]]) sendtext = other.proc( other.getl(variables.groups[ind].language).command_xo, [ f'{variables.groups[ind].xo.players[0][1] if variables.groups[ind].xo.players[0] is not None else None}', f'{variables.groups[ind].xo.players[1][1] if variables.groups[ind].xo.players[1] is not None else None}', f'{variables.groups[ind].xo.steps}', f'{"❌" if variables.groups[ind].xo.steps % 2 == 0 else "⭕"}' ]) context.bot.send_message(message.chat.id, sendtext, reply_markup=ik) variables.groups[ind].isPlaying = True variables.groups[ind].xo.isPlaying = True
def banditTick(context: CallbackContext): data = context.job.context chat_id = int(data[0]) user_id = int(data[1]) message_id = int(data[2]) money = int(data[3]) step = int(data[5]) coff = 1 smile = variables.BANDIT_SMILES[random.randint( 0, len(variables.BANDIT_SMILES) - 1)] if (smile == '🌕'): coff *= 2 elif (smile == '🌑'): coff *= 0.5 elif (smile == '🍄'): coff *= 0.7 elif (smile == '🌖'): coff *= 1.25 elif (smile == '🌒'): coff *= 0.75 elif (smile == '💥'): coff *= 1.75 elif (smile == '🐞'): coff *= 1.3 elif (smile == '🎢'): coff *= 0.4 elif (smile == '⚡'): coff *= random.randint(0, 40) elif (smile == '🎱'): coff *= 8 elif (smile == '🐴'): coff *= 0.8 elif (smile == '🦆'): coff *= 1.15 elif (smile == '🐭'): coff *= 0.85 elif (smile == '👻'): coff *= coff**0.5 elif (smile == '🤡'): coff *= 0.67 elif (smile == '🤡'): coff *= 0.67 elif (smile == '💊'): if (random.randint(1, 2) == 1): coff *= 0 else: coff *= 2 text = data[4].replace('🌫', smile, 1) money = int(money * coff) context.job.context = [ chat_id, user_id, message_id, money, text, step + 1 ] if (step == 2): uind = other.getUserIndexFromUsersList(user_id) ind = other.getGroupIndexFromGroupsList(chat_id) variables.users[uind].balance += money variables.users[uind].gamesplayed += 1 variables.groups[ind].isPlaying = False variables.groups[ind].gamesplayed += 1 sendtext = other.proc( other.getl(variables.groups[ind].language).command_bandit_end, [f'{money}']) text += f'\n{sendtext}' from db import datab datab.InsertOrUpdateUsersTable(variables.users[uind].id, variables.users[uind].name, variables.users[uind].username, variables.users[uind].balance, variables.users[uind].gamesplayed) datab.InsertOrUpdateGroupsTable(variables.groups[ind].id, variables.groups[ind].name, variables.groups[ind].count, variables.groups[ind].chatMembers) context.bot.edit_message_text(text, chat_id, message_id, parse_mode='HTML')
def bandit(update: Update, context: CallbackContext, ind: int, uind: int, is_group: bool, lang: str): message = update.effective_message ab = message.text.split(' ') if (not is_group): sendtext = other.proc(other.getl(lang).error_onlyGroup) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (len(ab) == 1): sendtext = other.proc(other.getl(lang).error_bandit_coinsNotEntered) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (int(ab[1]) <= 0): sendtext = other.proc(other.getl(lang).error_bandit_wrongNumberOfCoins) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (int(ab[1]) > variables.users[uind].balance): sendtext = other.proc(other.getl(lang).error_noCoins) context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id) return if (variables.groups[ind].isPlaying): sendtext = other.proc(other.getl(lang).error_alreadyPlaying) context.bot.send_message(message.chat.id, sendtext) return coins = int(ab[1]) def banditTick(context: CallbackContext): data = context.job.context chat_id = int(data[0]) user_id = int(data[1]) message_id = int(data[2]) money = int(data[3]) step = int(data[5]) coff = 1 smile = variables.BANDIT_SMILES[random.randint( 0, len(variables.BANDIT_SMILES) - 1)] if (smile == '🌕'): coff *= 2 elif (smile == '🌑'): coff *= 0.5 elif (smile == '🍄'): coff *= 0.7 elif (smile == '🌖'): coff *= 1.25 elif (smile == '🌒'): coff *= 0.75 elif (smile == '💥'): coff *= 1.75 elif (smile == '🐞'): coff *= 1.3 elif (smile == '🎢'): coff *= 0.4 elif (smile == '⚡'): coff *= random.randint(0, 40) elif (smile == '🎱'): coff *= 8 elif (smile == '🐴'): coff *= 0.8 elif (smile == '🦆'): coff *= 1.15 elif (smile == '🐭'): coff *= 0.85 elif (smile == '👻'): coff *= coff**0.5 elif (smile == '🤡'): coff *= 0.67 elif (smile == '🤡'): coff *= 0.67 elif (smile == '💊'): if (random.randint(1, 2) == 1): coff *= 0 else: coff *= 2 text = data[4].replace('🌫', smile, 1) money = int(money * coff) context.job.context = [ chat_id, user_id, message_id, money, text, step + 1 ] if (step == 2): uind = other.getUserIndexFromUsersList(user_id) ind = other.getGroupIndexFromGroupsList(chat_id) variables.users[uind].balance += money variables.users[uind].gamesplayed += 1 variables.groups[ind].isPlaying = False variables.groups[ind].gamesplayed += 1 sendtext = other.proc( other.getl(variables.groups[ind].language).command_bandit_end, [f'{money}']) text += f'\n{sendtext}' from db import datab datab.InsertOrUpdateUsersTable(variables.users[uind].id, variables.users[uind].name, variables.users[uind].username, variables.users[uind].balance, variables.users[uind].gamesplayed) datab.InsertOrUpdateGroupsTable(variables.groups[ind].id, variables.groups[ind].name, variables.groups[ind].count, variables.groups[ind].chatMembers) context.bot.edit_message_text(text, chat_id, message_id, parse_mode='HTML') sendtext = other.proc( other.getl(lang).command_bandit, [f'{variables.users[uind].name}', f'{coins}']) message = context.bot.send_message(message.chat.id, sendtext, reply_to_message_id=message.message_id, parse_mode='HTML') context.job_queue.run_repeating(banditTick, 3, 3, 9, context=[ variables.groups[ind].id, variables.users[uind].id, message.message_id, coins, sendtext, 0 ]) variables.groups[ind].isPlaying = True variables.users[uind].balance -= coins