Skip to content

Plugins

Simon Schürrle edited this page Apr 22, 2019 · 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" (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/composer');

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

Known Plugins

Code Detection Plugin
Plugin adding /delete command

Clone this wiki locally