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

Function ask_color

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

Source from the content-addressed store, hash-verified

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