Skip to main content
Version: Latest

@mod.on_ready

@mod.on_ready - This is a decorator that triggers when the bot starts. You can use it, for example, to launch workers.

danger

Workers or any other long-running processes must not be launched directly in the on_ready body. Use mod.add_task() to start workers.

Examples

SomeModule
from utils import *

async def main(app: Client, mod: Module):

@mod.on_ready
async def _onr(app: Client):
mod.logger.info("RimTUB has started!")


info

The following example is taken from the MineEvoMiner module (version 2.5) by a third-party developer @Kotcananacom.

warning

This example was written for RimTUB 2.1, so the HelpList in this example is outdated!

MineEvoMiner/__init__.py
from utils import *
from .miner import *
from .stats.stat import *
from .helplist import module_help # Note: RimTUB 2.2 uses a different HelpList system!



async def main(app: Client, mod: Module):

cmd = mod.cmd
module_help(mod) # Note: RimTUB 2.2 uses a different HelpList system!

@mod.on_ready
async def _onr(app): await stats_ready(app, mod)

...
MineEvoMiner/miner/mine.py, lines 25-32
# When the client is running
async def stats_ready(app: Client, mod: Module):
AutoStopTimer(app, mod)
mod.add_task(miner(app, mod))
if await mod.db.get('mine', False):
await mod.db.set('start_mine', time.time())
await mod.db.sql("CREATE TABLE IF NOT EXISTS mineevo_stats (type_case TEXT, type_bust TEXT, count INTEGER, timee TEXT)")
await initialization_found(app, mod)