New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

bub

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bub

A framework to build Telegram bots with Node

Source
npmnpm
Version
0.4.1
Version published
Weekly downloads
25
316.67%
Maintainers
1
Weekly downloads
 
Created
Source

bub

Telegram bot framework

Please go through the Telegram Bot API first.

Get

npm install bub --save

Set

I recommend that you store your config (which contains the API token) in a separate JSON file, say bub.json. That way, if you want to share your code, you can simply omit the file.

{
  "token": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
  "timeout": 3600
}

If your bot doesn't receive any messages for timeout number of seconds, it will stop checking for more. Default is 10 days.

Go

var config = require("./bub.json");
var Bub = require("bub");
var bot = new Bub(config);

// User commands are handled with `on()`
bot.on("/start", function (result) {
  // Quick responses are easy-peasy
  result.respond("Hello, " + result.message.from.first_name);
});

bot.on("/longstory", function (result) {
  // Plain old API methods
  bot.sendChatAction({
    chat_id: 123456789,
    action: typing
  }, function (body) {
    console.log("Typing…");
  });
});

// Anything without handlers goes here
bot.on("_default", console.log);

// Start checking for updates and handle them
bot.init();

Roadmap

  • Add a convenience method respond() for quick responses
  • Improve respond() to send any kind of message based on the argument, e.g. URL to a png sends a photo
  • Integrate Gulp and ESLint
  • Add webhook support
  • Somewhere down the road: integrate a proper test framework and manage it with Gulp

Keywords

bot

FAQs

Package last updated on 03 Jul 2015

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