MCPcopy Create free account
hub / github.com/eternnoir/pyTelegramBotAPI / ask_color

Function ask_color

examples/asynchronous_telebot/custom_states.py:55–70  ·  view source on GitHub ↗
(message: types.Message, state: StateContext)

Source from the content-addressed store, hash-verified

53# Handler for age input
54@bot.message_handler(state=MyStates.age, is_digit=True)
55async def ask_color(message: types.Message, state: StateContext):
56 await state.set(MyStates.color)
57 await state.add_data(age=message.text)
58
59 # Define reply keyboard for color selection
60 keyboard = types.ReplyKeyboardMarkup(row_width=2)
61 colors = ["Red", "Green", "Blue", "Yellow", "Purple", "Orange", "Other"]
62 buttons = [types.KeyboardButton(color) for color in colors]
63 keyboard.add(*buttons)
64
65 await bot.send_message(
66 message.chat.id,
67 "What is your favorite color? Choose from the options below.",
68 reply_markup=keyboard,
69 reply_parameters=ReplyParameters(message_id=message.message_id),
70 )
71
72
73# Handler for color input

Callers

nothing calls this directly

Calls 5

addMethod · 0.95
ReplyParametersClass · 0.90
setMethod · 0.45
add_dataMethod · 0.45
send_messageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…