-
Notifications
You must be signed in to change notification settings - Fork 5
Plugin Development
Arnab Paryali edited this page Dec 11, 2021
·
1 revision
Creating a plugin for LazyBot is super easy if you have basic JS and GramJS knowledge.
All plugins are stored inside the plugins (src/plugins) folder. You can create a Typescript/Javascript file. Example : hello.ts , hello.js
// Type Referance
interface LBPlugin extends NewMessageInterface {
handler: (event: NewMessageEvent, client: TelegramClient) => Promise<void>;
commands?: string | string[];
allowArgs?: boolean;
}-
handler: A
handleris a function that accepts two args -eventandclient.-
event :
eventis an object containing the update information of typeNewMessageEvent. -
client :
clientis TelegramClient instance, most powerful object in LazyBot. You can do kinds of stuff that can't be done with theeventobject, everything that is possible with GramJS. (Referenace)
-
event :
-
commands:
- Command can be a single string or array of strings. Example :
'hello',['hello', 'hi']. - Command should not contain command prefix. Example :
'hello'✅ ,'.hello'❌ .
- Command can be a single string or array of strings. Example :
-
allowArgs: Accepts boolean, If your command can accept args or not. Example:
'.afk Hello'will work whenallowArgsistrue, but it won't respond ifallowArgsisfalse -
pattern: Accepts regex. Useful for incoming messages.
Each plugin object should have either `commands` or `pattern`
- You can read about other props in GramJS Docs.