Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

telekit-cmd

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telekit-cmd

The module that simplifies work with commands in telekit

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
1
Weekly downloads
 
Created
Source

telekit-cmd

The module that simplifies work with commands in telekit

Install

npm:

$ npm install telekit telekit-cmd --save

yarn:

$ yarn add telekit telekit-cmd

Usage

/** Require `telekit` and `telekit-cmd` */
const telekit = require('telekit');
const telecmd = require('telekit-cmd');

/** Create a new `telekit` instance */
const bot = telekit(options);

/** Connect `telekit-cmd` to instance */
bot.use(telecmd);

/** And start listening! */
bot.on('/ping', (context) => {
    context.chat.sendMessage({
        text: 'Pong!',
    });
});

Documentation

Coming soon...

Examples

context.command

/** ... */
const bot = telekit(options);
bot.use(telecmd);

bot.message = (context) => {
    if (context.command.name == 'hello') {
        return context.chat.sendMessage({
            text: 'Glad to see you!',
        });
    }
};

Events

/** ... */
const bot = telekit(options);
bot.use(telecmd);

/** Listen of all commands */
bot.on('command', (context) => {
    context.chat.sendMessage({
        text: `Command ${context.command.name} is not implemented 😞`,
    });
});

/** Listens only a given command */
bot.on('/meow', (context) => {
    context.chat.sendMessage({
        text: 'Woof, woooof-woof! 🐶',
    });
});
/** ... */

Method command for the instance

/** ... */
const bot = telekit(options);
bot.use(telecmd);

bot.command = (context) => {
    if (context.command.name == 'source') {
        context.chat.sendMessage({
            text: '[Source code available on Github](https://github.com/telekits/telekit-cmd) ❤️️',
            parse_mode: 'markdown',
        });
    }
} 
/** ... */

Method command for the custom helpers

/** ... */
const bot = telekit(options);
bot.use(telecmd);

bot.use(class MyBestClassHelper { 
    command(context, next) {
        if (context.command.name == 'start') {
            return context.chat.sendMessage({
                text: 'Welcome to My Super Awesome Bot! 😊',
            });
        }

        next();
    }
});
/** ... */

LICENSE

MIT

Keywords

FAQs

Package last updated on 18 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc