if message.isdigit():
game_index = int(message)
if game_index < 0 or game_index > len(games):
game = “Неизвестная игра’’
else:
# не забываем, что индекс начинается с нуля в списке, а для пользователя - с единицы, поэтому сделаем так
game = games[game_index-1]
else:
game = message
чтобы кнопка появилась, нужно создать такую клавиатуру
reply_markup
, которое может в себе содержать InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply
keyboard
, которое является Array of Array of KeyboardButton
text
, определяющее, как ни странно, текст, и другие, которые меняют поведение кнопки.import requests
CHAT_ID = 123
TOKEN = 123
keyboard = {'keyboard': [[{'text': 'Button 1'}, {'text': 'Button 2', 'request_contact': True}]]}
payload = {'chat_id': CHAT_ID , 'text': 'Hello, world!', 'reply_markup': keyboard}
requests.post(f'https://api.telegram.org/bot{TOKEN}/sendMessage', json=payload)
нужна задержка чтобы сайт прогрузился
prices = input().split()
prices = [int(x) for x in prices]
total_price = 0
cheap_prices = 0
for price in prices:
if price >= 500:
total_price += price - 100
else:
cheap_prices += price
if cheap_prices >= 500:
total_price += cheap_prices-100
else:
total_price += cheap_prices
print(total_price)
span
с классом price money-gold
загружаются динамически, не достанете обычным запросом на страницу.Overriding the default provided on_message forbids any extra commands from running. To fix this, add a bot.process_commands(message) line at the end of your on_message.
on_message
добавить await bot.process_commands(message)