korone package¶
- korone.create_i18n_instance(locales_dir)[source]¶
Create an instance of the I18n class.
This function creates an instance of the I18n class using the specified locales directory. If the locales directory does not exist, the function will compile the locales using pybabel before creating the I18n instance.
- Parameters:
locales_dir (
Path
) – The path to the locales directory.- Returns:
I18n
– An instance of the I18n class.
Subpackages¶
Submodules¶
- class korone.client.AppParameters(api_id, api_hash, bot_token, ipv6=True, name='Korone', workers=24)[source]¶
Bases:
object
Parameters for
hydrogram.Client
.This class represents the parameters for initializing the bot.
- name¶
The name of the
hydrogram.Client
.- Type:
- workers¶
The number of workers to be used by the
hydrogram.Client
.- Type:
- class korone.client.Korone(parameters)[source]¶
Bases:
Client
Represent Korone.
This class represents Korone. It inherits from
hydrogram.Client
.- Parameters:
parameters (
AppParameters
) – The parameters for initializing the bot.
- exception korone.config.ConfigError[source]¶
Bases:
Exception
Represents an error that occurs while loading or saving the configuration.
This exception is raised when an error occurs while loading or saving the configuration.
- class korone.config.ConfigManager(*args, **kwargs)[source]¶
Bases:
object
Configuration manager class.
This class is responsible for managing the configuration settings of the application.
- Parameters:
cfgpath (
str
, optional) – The path to the configuration file, by default constants.CONFIG_PATH.
- config¶
The configuration template used to create the configuration file if it does not exist.
- Type:
dict[str
,typing.Any]
- korone.constants.XDG_CONFIG_HOME = '/home/docs/.config'¶
The XDG_CONFIG_HOME environment variable. Where user-specific configurations should be written (analogous to /etc).
- Type:
- korone.constants.XDG_DATA_HOME = '/home/docs/.local/share'¶
The XDG_DATA_HOME environment variable. Where user-specific data files should be written (analogous to /usr/share).
- Type:
- korone.constants.DEFAULT_CONFIG_PATH = '/home/docs/.config/korone/korone.toml'¶
The default path to the config file.
- Type:
- korone.constants.DEFAULT_CONFIG_TEMPLATE = {'hydrogram': {'API_HASH': '', 'API_ID': '', 'BOT_TOKEN': '', 'USE_IPV6': False, 'WORKERS': 24}, 'korone': {'PROXY': '', 'SUDOERS': [918317361]}}¶
The default config template.
Examples
>>> from korone import constants >>> print(constants.DEFAULT_CONFIG_TEMPLATE) { "hydrogram": { "API_ID": "", "API_HASH": "", "BOT_TOKEN": "", "USE_IPV6": False, "WORKERS": 24, }, "korone": { "SUDOERS": [918317361], }, }
- korone.constants.DEFAULT_DBFILE_PATH = '/home/docs/.local/share/korone/korone.sqlite'¶
The default path to the database file.
- Type:
- korone.constants.SQLITE3_TABLES = '\nCREATE TABLE IF NOT EXISTS Users (\n id INTEGER PRIMARY KEY,\n username TEXT,\n language VARCHAR(2) NOT NULL DEFAULT "en",\n registry_date INTEGER NOT NULL\n);\nCREATE TABLE IF NOT EXISTS Groups (\n id INTEGER PRIMARY KEY,\n username TEXT,\n type TEXT,\n language VARCHAR(2) NOT NULL DEFAULT "en",\n registry_date INTEGER NOT NULL\n);\nCREATE TABLE IF NOT EXISTS Afk (\n id INTEGER PRIMARY KEY,\n state BIT,\n reason TEXT\n);\nCREATE TABLE IF NOT EXISTS Commands (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n chat_id INTEGER,\n command TEXT,\n state BIT,\n FOREIGN KEY(chat_id) REFERENCES Groups(id)\n);\n'¶
The default SQLite3 tables.
- Type:
- korone.constants.SQLITE3_PARAMS = '\nPRAGMA journal_mode=WAL;\nPRAGMA foreign_keys=ON;\nVACUUM;\n'¶
The default SQLite3 parameters.
- Type:
- korone.constants.CROWDIN_URL = 'https://crowdin.com/project/pykorone'¶
The URL to the Crowdin project.
- Type:
- korone.constants.GITHUB_URL = 'https://github.com/HitaloM/PyKorone'¶
The URL to the GitHub repository.
- Type: