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

Function ask_hobby

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

Source from the content-addressed store, hash-verified

74# Handler for color input
75@bot.message_handler(state=MyStates.color)
76def ask_hobby(message: types.Message, state: StateContext):
77 state.set(MyStates.hobby)
78 state.add_data(color=message.text)
79
80 # Define reply keyboard for hobby selection
81 keyboard = types.ReplyKeyboardMarkup(row_width=2)
82 hobbies = ["Reading", "Traveling", "Gaming", "Cooking"]
83 buttons = [types.KeyboardButton(hobby) for hobby in hobbies]
84 keyboard.add(*buttons)
85
86 bot.send_message(
87 message.chat.id,
88 "What is one of your hobbies? Choose from the options below.",
89 reply_markup=keyboard,
90 reply_parameters=ReplyParameters(message_id=message.message_id),
91 )
92
93
94# Handler for hobby 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…