-
Notifications
You must be signed in to change notification settings - Fork 2
TelegramData
Moris Doratiotto edited this page Aug 26, 2021
·
4 revisions
A TelegramData object is the only object your custom functions need to have.
When you define a function, there will always be a single required parameter, a TelegramData instance.
With all the parameters (specified below) you will have access to every Telegram data you will need.
-
autoconv
: Autoconv instance. -
update
,context
: Telegram update and context. -
telegram_id
: Telegram ID of the user. -
udata
:context.user_data
of the user. -
sdata
: data for every state of the user. -
message
: message info, if possibile, of the user. -
exception
: last Python exception occurred. -
users
: list of current authorized users.
Usage example: tdata.py
# save key:values in context.user_data, works as Dict.update
TelegramData.save(
*args,
**kwargs
)
-
args
ekwargs
: it works as Dict.update().
Usage example: tdata.py
# add a value to an existing key in context.user_data
TelegramData.add(
key: str,
value: Any
) → Any
-
key
: key incontext.user_data
dictionary -
value
: value to add to the corresponding value in dictionary (need to be compatible with+
operator) - It returns the value after the operation
Usage example: tdata.py
TelegramData.get_or_set(
key: str,
set_value: Any
) → Any
-
key
: key incontext.user_data
dictionary -
set_value
: value to set ifkey
doesn't exist in dictionary - It returns the value in dictionary after the operation