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

Method set

telebot/states/sync/context.py:30–55  ·  view source on GitHub ↗

Set state for current user. :param state: State object or state name. :type state: Union[State, str] .. code-block:: python3 @bot.message_handler(commands=['start']) def start_ex(message: types.Message, state_context: StateContext):

(self, state: Union[State, str])

Source from the content-addressed store, hash-verified

28 self.bot_id = self.bot.bot_id
29
30 def set(self, state: Union[State, str]) -> bool:
31 """
32 Set state for current user.
33
34 :param state: State object or state name.
35 :type state: Union[State, str]
36
37 .. code-block:: python3
38
39 @bot.message_handler(commands=['start'])
40 def start_ex(message: types.Message, state_context: StateContext):
41 state_context.set(MyStates.name)
42 bot.send_message(message.chat.id, 'Hi, write me a name', reply_to_message_id=message.message_id)
43 """
44
45 chat_id, user_id, business_connection_id, bot_id, message_thread_id = resolve_context(self.message, self.bot.bot_id)
46 if isinstance(state, State):
47 state = state.name
48 return self.bot.set_state(
49 chat_id=chat_id,
50 user_id=user_id,
51 state=state,
52 business_connection_id=business_connection_id,
53 bot_id=bot_id,
54 message_thread_id=message_thread_id
55 )
56
57 def get(self) -> str:
58 """

Callers 15

fake_process_new_updatesFunction · 0.45
start_exFunction · 0.45
name_getFunction · 0.45
ask_colorFunction · 0.45
ask_hobbyFunction · 0.45
start_exFunction · 0.45
name_getFunction · 0.45
ask_colorFunction · 0.45
ask_hobbyFunction · 0.45
pre_processMethod · 0.45
__threaded_pollingMethod · 0.45

Calls 2

resolve_contextFunction · 0.90
set_stateMethod · 0.45

Tested by 1

fake_process_new_updatesFunction · 0.36