Callback data factory

callback_data file

Callback data factory’s file.

class telebot.callback_data.CallbackData(*parts, prefix: str, sep=':')

Bases: object

Callback data factory This class will help you to work with CallbackQuery

filter(**config) CallbackDataFilter

Generate filter

Parameters:

config – specified named parameters will be checked with CallbackQuery.data

Returns:

CallbackDataFilter class

new(*args, **kwargs) str

Generate callback data

Parameters:
  • args – positional parameters of CallbackData instance parts

  • kwargs – named parameters

Returns:

str

parse(callback_data: str) Dict[str, str]

Parse data from the callback data

Parameters:

callback_data – string, use to telebot.types.CallbackQuery to parse it from string to a dict

Returns:

dict parsed from callback data

class telebot.callback_data.CallbackDataFilter(factory, config: Dict[str, str])

Bases: object

Filter for CallbackData.

check(query) bool

Checks if query.data appropriates to specified config

Parameters:

query (telebot.types.CallbackQuery) – telebot.types.CallbackQuery

Returns:

True if query.data appropriates to specified config

Return type:

bool