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.

api_id

The Telegram API ID.

Type:

str

api_hash

The Telegram API Hash.

Type:

str

bot_token

The Telegram bot token.

Type:

str

ipv6

Whether to use IPv6 to connect to Telegram servers.

Type:

bool

name

The name of the hydrogram.Client.

Type:

str

workers

The number of workers to be used by the hydrogram.Client.

Type:

int

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.

async start()[source]

Start the client.

This function starts the client and logs a message to the console.

async stop()[source]

Stop the client.

This function stops the client and logs a message to the console.

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]

classmethod get(section, option, fallback='')[source]

Retrieve a configuration option.

This function retrieves a configuration option from the configuration file.

Parameters:
  • section (str) – The name of the section in the configuration file.

  • option (str) – The name of the option within the section.

  • fallback (str, optional) – The default value to be returned if the option is not found, defaults to “”.

Returns:

Any – The value of the specified option. If the option is not found, returns the default value.

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:

str

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:

str

korone.constants.DEFAULT_CONFIG_PATH = '/home/docs/.config/korone/korone.toml'

The default path to the config file.

Type:

str

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.

Type:

dict[str, Any]

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:

str

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:

str

korone.constants.SQLITE3_PARAMS = '\nPRAGMA journal_mode=WAL;\nPRAGMA foreign_keys=ON;\nVACUUM;\n'

The default SQLite3 parameters.

Type:

str

korone.constants.CROWDIN_URL = 'https://crowdin.com/project/pykorone'

The URL to the Crowdin project.

Type:

str

korone.constants.GITHUB_URL = 'https://github.com/HitaloM/PyKorone'

The URL to the GitHub repository.

Type:

str

korone.constants.TELEGRAM_URL = 'https://t.me/PyKorone'

The URL to the Telegram channel.

Type:

str