We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the bot responds as expected to /start, but nothing responds to button clicks in the message
`from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup from telegram.ext import Updater, CommandHandler, CallbackContext, CallbackQueryHandler, Application import telegram.ext import random
current_number = 0 game_active = False
async def start(update: Update, context: CallbackContext) -> None: global current_number global game_active
current_number = random.randint(1, 100) game_active = True keyboard = [ [InlineKeyboardButton("Больше", callback_data='more')], [InlineKeyboardButton("Меньше", callback_data='less')] ] reply_markup = InlineKeyboardMarkup(keyboard) await update.message.reply_text(f"Загадано число {current_number} Больше или меньше?", reply_markup=reply_markup)
async def check_guess(update: Update, context: CallbackContext) -> None: global current_number global game_active
query = update.callback_query choice = query.data new_number = random.randint(1, 100) if (choice == 'more' and new_number > current_number) or (choice == 'less' and new_number < current_number): message = "Вы выиграли! Вот следующее число: {}".format(new_number) else: message = "Вы проиграли. Попробуйте снова. Вот следующее число: {}".format(new_number) current_number = new_number game_active = False await query.edit_message_text(text=message)
def main() -> None: application = Application.builder().token('token').build() application.add_handler(CommandHandler('start', start)) application.run_polling()
if name == 'main': import asyncio asyncio.run(main())`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
the bot responds as expected to /start, but nothing responds to button clicks in the message
`from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, CallbackContext, CallbackQueryHandler, Application
import telegram.ext
import random
current_number = 0
game_active = False
async def start(update: Update, context: CallbackContext) -> None:
global current_number
global game_active
async def check_guess(update: Update, context: CallbackContext) -> None:
global current_number
global game_active
def main() -> None:
application = Application.builder().token('token').build()
application.add_handler(CommandHandler('start', start))
application.run_polling()
if name == 'main':
import asyncio
asyncio.run(main())`
The text was updated successfully, but these errors were encountered: