Skip to content

Plugins

Martin edited this page Sep 18, 2023 · 6 revisions

Plugins let you extend the bot with new functionality without touching the source code of the bot.

Using plugins

To use a plugin, put it in the /plugins directory and add its name to plugins array in config.js.

If plugins is undefined, no plugins are loaded. However, this behaviour may change, don't rely on it. If you want no plugins to be loaded, explicitly set it to an empty array.

Creating a plugin

A plugin is basically "requirable" (TS or JS file, or directory with index.js) which exports a valid Telegraf handler (usually function or Composer instance).

Plugins are similar to [micro-bot] bots.

A simple /ping command

'use strict';
const { Composer } = require('telegraf');

module.exports = Composer.command('ping', (ctx, next) =>
  ctx.reply('Pong!'));

Get Plugins

See the the-guard-bot-plugins repository for examples

Clone this wiki locally