Skip to content

Class Stark

This is the main class of PyStark. This guide will explain the usage of important functions in Stark class.


all_commands: dict property readonly

Dictionary of all commands and their descriptions if present else None.

Examples:

{
    "start": "Start the bot"
    "help": "Get help"
    "about": "About this bot"
},

all_plugins: dict property readonly

Dictionary of all plugins and their respective absolute paths.

Examples:

{
    "basic":"C:\Users\....\plugins\basic.py",
    "sample":"D:\Bots\...\sample.py",
    "must_join":"C:\Users\...\pystark\addons\must_join.py"
},

data: dict property readonly

A special dictionary with five keys.

Key Returns
total_plugins number of plugins in bot
all_plugins dictionary of all plugins and their absolute paths
total_commands number of commands in bot
all_commands dictionary of command and their descriptions if passed in Stark.cmd decorator else None
sudo_commands list of all sudo commands available and includes owner_only commands

Examples:

{
    "total_plugins": 2,
    "all_plugins": {
        "basic":"C:\....\plugins\basic.py",
        "sample":"D:\...\sample.py"
    },
    "total_commands": 3,
    "all_commands": {
        "start": "Start the bot"
        "help": "Get help"
        "about": "About this bot"
    },
    "sudo_commands": ["stats", "json", "sudo", "botban"]
}

sudo_commands: list property readonly

List of all sudo commands available. Includes owner_only commands too.

total_commands: int property readonly

Number of total commands loaded.

total_plugins: int property readonly

Number of total plugins loaded.

activate(self)

Main method of Stark class which loads plugins and activates/runs your bot.

list_modules(directory) staticmethod

List all modules in a directory

load_modules(self, plugins)

Load all modules from a directory or a single module as pyrogram handlers

log(message, level=20) staticmethod

Log messages to console.

String Integer
debug 10
info 20
warning 30
error 40
critical 50

Parameters:

Name Type Description Default
message Any

Item to print to console.

required
level optional

Logging level as string or int.

20

log_tg(self, text) async

Log a text message to your log chat as defined in environment variable LOG_CHAT

Parameters:

Name Type Description Default
text

Text that needs to be logged.

required

run(self)

Alias of Stark.activate()

Back to top