Skip to content

Modules

Protocol Corporation edited this page Nov 26, 2024 · 10 revisions

Requirements

  1. The namespace must be ProtocolLive\StbModules for single bot;
  2. Must implements the interface ProtocolLive\SimpleTelegramBot\StbInterfaces\StbModuleInterface
  3. Must call function DebugTrace() in first line of every method;
  4. The file structure must be: modules/MODULE_NAME/index.php
  5. Global module must have an install and uninstall script in Composer bin folder; (Example with TalkAs module);

Notes

  • There is a parent class called ProtocolLive\SimpleTelegramBot\StbObjects\StbModuleHelper with helpers;

Methods

Command

public static function Command(
  TelegramBotLibrary $Bot,
  TblCmd $Webhook,
  StbDatabase $Db,
  StbLanguageSys $Lang
):void;

That method are called when the user use a command.

Cron

public static function Cron(
  TelegramBotLibrary $Bot,
  StbDatabase $Db,
  TblData $BotData
):void;

Method used with cron jobs

Install

public static function Install(
  TelegramBotLibrary $Bot,
  TgCallback $Webhook,
  StbDatabase $Db,
  StbLanguageSys $Lang
):void;

That method are called by admin menu to install the module.

Tips

  • Run parent::InstallCmd before parent::InstallHelper;

Listeners

public static function Listener(
  TelegramBotLibrary $Bot,
  TgEventInterface $Webhook,
  StbDatabase $Db,
  StbLanguageSys $Lang
):void;

That method are called when a event registered in datababase occurs.

Uninstall

public static function Uninstall(
  TelegramBotLibrary $Bot,
  TgCallback $Webhook,
  StbDatabase $Db,
  StbLanguageSys $Lang
):void;

That method are called by admin menu to uninstall the module.

Plugin

See session Plugin - Buttons

Clone this wiki locally