API Index¶
Subpackages¶
- tgram_dnd.actions package
- tgram_dnd.blocks package
- tgram_dnd.caching package
- tgram_dnd.enums package
- tgram_dnd.flows package
- tgram_dnd.conditions package
Submodules¶
tgram_dnd.app module¶
- class tgram_dnd.app.App(bot: TgBot, flows: List[MessageFlow | CallbackFlow] = [], config: BotConfig = None, cache: BaseCache = None)[source]¶
Bases:
objectThe main class used to run your Flows
- add_flows(flows: List[MessageFlow | CallbackFlow] | MessageFlow | CallbackFlow)[source]¶
add flows to current app
tgram_dnd.config module¶
- class tgram_dnd.config.BotConfig(strings: Dict[str, Dict[TypeAliasForwardRef('tgram_dnd.enums.language_codes.LANGUAGE_CODES'), str]] = None, keyboards: Dict[str, Dict[TypeAliasForwardRef('tgram_dnd.enums.language_codes.LANGUAGE_CODES'), InlineKeyboardMarkup]] = None, default_lang: tgram_dnd.enums.language_codes.LANGUAGE_CODES = 'en', bot_commands: List[BotCommandInput] = None, config_file: str = None)[source]¶
Bases:
objectInit BotConfig
# Importing data manually config = BotConfig( strings={ "start": ... }, keyboards=..., commands=... ) # importing from a file config = BotConfig(config_file="data.json")
- Parameters:
strings (dict[str, dict[
tgram_dnd.enums.language_codes.LANGUAGE_CODES, str]], optinal) – the pre-made textkeyboards (dict[str, dict[
tgram_dnd.enums.language_codes.LANGUAGE_CODES,tgram.types.InlineKeyboardMarkup]], optinal) – the pre-made keyboardsdefault_lang (
tgram_dnd.enums.language_codes.LANGUAGE_CODES, optinal) – the default language to fetch if the user language is not supportedbot_commands (list[
tgram_dnd.enums.bot_command_input.BotCommandInput], optinal) – pre-made bot menu buttons/commandsconfig_file (str, optinal) – The path to the configuration file which contains all the strings,keyboards,bot_commands etc
- Returns:
None
- configure(bot: TgBot) None[source]¶
used to apply the configurations
- Parameters:
bot (
tgram.client.TgBot)- Returns:
None
- keyboard(key: str, force_language: tgram_dnd.enums.language_codes.LANGUAGE_CODES = None) Callable[source]¶
used to return a keyboard based on the user language
- Parameters:
key (string) – the keyboard key
force_language (
tgram_dnd.enums.language_codes.LANGUAGE_CODES) – a specfic language to force it on the keyboard (despite user language)
- Returns:
a decorator to get the keyboard based on user language
- Return type:
Decorator
- load_file_data(file: str) None[source]¶
Loads data from ConfigFile
- Parameters:
file (string) – file path
- Returns:
None
- string(key: str, force_language: tgram_dnd.enums.language_codes.LANGUAGE_CODES = None) Callable[source]¶
used to return a string based on the user language
- Parameters:
key (string) – the string key
force_language (
tgram_dnd.enums.language_codes.LANGUAGE_CODES) – a specfic language to force it on the string (despite user language)
- Returns:
a decorator to get the string based on user language
- Return type:
Decorator
tgram_dnd.errors module¶
tgram_dnd.utils module¶
- tgram_dnd.utils.get_target_function(obj: object, function_name: str) Callable | None[source]¶
used to get a specific function from obj by getting its attribuites
# example with first class method obj = Message target = "reply_text" method = get_target_function(obj, target) print(method) # <function Message.reply_text at 0xSomeAddress> # example with indented method obj = Message target = "user.mention" method = get_target_function(obj, target) print(method) # <funtion Message.User.mention at 0xSomeAddress>
- Parameters:
obj (object)
function_name (str) – the wanted method seperated by dots, eg: obj_property.method_x
- Returns:
Callable