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);
bot.on("/start", function (result) {
result.respond("Hello, " + result.message.from.first_name);
});
bot.on("/longstory", function (result) {
bot.sendChatAction({
chat_id: 123456789,
action: typing
}, function (body) {
console.log("Typing…");
});
});
bot.on("_default", console.log);
bot.init();
Roadmap