NimarkoGram Docs
RU
Docs/API reference

API reference

BasePlugin methods, built-in modules and multi-account usage.

On this pageAccount contextBasePlugin methodsBuilt-in modulesFiles

Account context

Request and update callbacks receive an account argument. It identifies an account slot in the client. Pass it explicitly to client_utils.get_messages_controller(account) and client_utils.get_user_config(account). The user may switch accounts before a deferred task finishes.

Python
from client_utils import get_user_config

def account_user_id(account):
    return get_user_config(account).getClientUserId()

BasePlugin methods

Method Purpose
self.log(message) Prefixes a log message with the plugin ID.
self.get_setting(key, default) Reads a plugin preference.
self.set_setting(key, value) Writes a plugin preference.
self.add_menu_item(item) Adds a menu action and returns its ID.
self.remove_menu_item(item_id) Removes a registered action.
self.register_cleanup(fn) Associates a cleanup callback with the current plugin instance.

Built-in modules

Import Use
base_plugin Base class, menu types and app events.
ui.settings Rows returned from create_settings().
ui.bulletin.BulletinHelper Short notices with show_info, show_success and show_error.
android_utils Check the UI thread and schedule UI work.
client_utils Queues, controllers and account context.
file_utils Locate client directories and work with files.

Files

file_utils.get_cache_dir() returns the client cache path. Give temporary files their own subdirectory named after the plugin ID. The user can clear the cache. Store user preferences with the settings API.