hbot.core package#
Submodules#
hbot.core.base_plugin module#
- class hbot.core.base_plugin.BasePlugin(app: Client)[source]#
Bases:
ABCThe core to every plugins in this bot.
When
load_plugins()is called to load plugins, it finds plugin in the plugins/ directory, and calls theregister_handler()method in any class that inherit this class. If you do not inherit this class, the loader will assume it as an ordinary class that should not be touched.issubclass()is used to determine if a class inherits this class.- name#
(class attribute) The name of the plugin.
- Type:
str
- description#
(class attribute) The description of the attribute.
- Type:
str
- config#
(class attribute) The jsondb config attached, this is used to store global prefixes.
- app#
The app (pyrogram
Client) instance.
- final change_global_prefix(prefixes: list[str]) None[source]#
This method is used to change the global prefixes for commands of the bot.
- config = <jsondb.database.JsonDB object>#
- description: str = 'Not supposed to be instantiated.'#
- name: str = 'Base Plugin'#
- prefixes: list[str] = ['.']#
- abstractmethod register_handlers() list[Handler] | Awaitable[list[Handler]][source]#
This is the abstract method that must be implemented by subclasses for the bot to work.
The plugin loader will call this method. The default implementation will raise NotImplementedError exception.
- Raises:
NotImplementedError – This is abstract method. Please provide your own implementation.
hbot.core.coloured_logging_setup module#
hbot.core.main module#
- async hbot.core.main.get_loaded_plugins() dict[BasePlugin, list[Handler]][source]#
hbot.core.plugins_loader module#
- async hbot.core.plugins_loader.load_plugins(app: Client, plugins_dir: PathLike | str = PosixPath('/home/hakimi/github-repo/hbot/.venv/lib64/python3.14t/site-packages/hbot/plugins')) dict[BasePlugin, list[Handler]]#
This function loads every plugin under hbot/plugins/* (PLUGINS_DIR) directory.
Note that this loader will look for classes that inherits the BasePlugin abstract class, and calls the
hbot.core.base_plugin.BasePlugin.register_handlers()method.- Parameters:
app – The Client instance of pyrogram.
plugins_dir – PathLike object of the directory containing plugins to load. Defaults to
hbot.PLUGINS_DIR.
- Returns:
A dictionary where the instance of the subclass of BasePlugin is the key, and the list of the handlers returned by the
hbot.core.base_plugin.BasePlugin.register_handlers()method is the value.- Raises:
ValueError – When the
hbot.core.base_plugin.BasePlugin.register_handlers()method does notreturn list of handlers. –