Deprecated: A simple API to create and control Telegram bots
Go to file
Mahdi Dibaiee 714ffa9458 Fix promises getting rejected silently - Thanks to @joepie91
Fix bot not working properly in groups
Fix bot not answering properly
Bump to version 0.2.2
2015-06-29 05:30:29 +04:30
build Fix promises getting rejected silently - Thanks to @joepie91 2015-06-29 05:30:29 +04:30
classes V2 - Big update 2015-06-29 03:12:48 +04:30
lib Fix promises getting rejected silently - Thanks to @joepie91 2015-06-29 05:30:29 +04:30
types V2 - Big update 2015-06-29 03:12:48 +04:30
.gitignore initial commit 2015-06-26 21:50:54 +04:30
demo.gif smaller GIF 2015-06-27 04:50:25 +04:30
demo.js Fix promises getting rejected silently - Thanks to @joepie91 2015-06-29 05:30:29 +04:30
esdoc.json V2 - Big update 2015-06-29 03:12:48 +04:30
Gruntfile.js V2 - Big update 2015-06-29 03:12:48 +04:30
index.js V2 - Big update 2015-06-29 03:12:48 +04:30
LICENSE Initial commit 2015-06-26 03:04:01 +04:30
package.json Fix promises getting rejected silently - Thanks to @joepie91 2015-06-29 05:30:29 +04:30
README.md Better demo 2015-06-29 04:22:22 +04:30

Telegram Bots

Create and control Telegram bots easily using the new Telegram API.

telegram-api is in beta, your feedback is appreciated, please fill an issue for any bugs you find or any suggestions you have.

npm install telegram-api

The code is well documented. I'm trying to integrate JSDoc / ESDoc into our repository for an easy to access documentation.

Example

@JavaScriptBot runs on demo.js, you can test it.

var Bot = require('telegram-api');

// only require the message types you need, more coming soon!
var Message = require('telegram-api/types/Message');
var Question = require('telegram-api/types/Question');

var bot = new Bot({
  token: 'YOUR_KEY'
});

bot.start().then(() => {
  console.log(bot.info);
});

// polling
bot.on('update', update => {
  console.log('Polled\n', update);
});

const question = new Question({
  text: 'How should I greet you?',
  answers: [['Hey'], ['Hello, Sir'], ['Yo bro']]
});

bot.get(/Hi\sBot/, message => {
  const id = message.chat.id;

  question.to(id).reply(message.message_id);

  bot.send(question).then(answer => {
    const msg = new Message().to(id).text('Your answer: ' + answer);
    bot.send(msg);
  }, () => {
    const msg = new Message().to(id).text('Invalid answer');
    bot.send(msg);
  });
});

const hello = new Message().text('Hello');
bot.command('start', message => {
  bot.send(hello.to(message.chat.id));
});

const test = new Message().text('Test Command');
bot.command('test', message => {
  bot.send(test.to(message.chat.id));
});

This will result in:

@JavaScriptBot

Bots using this module

@JavaScriptBot

Todo

  • BulkMessage Type
  • File Type
  • Sticker Type
  • Location Type
  • Contact Type
  • Allow remote control of bots (TCP maybe)
  • YOUR IDEAS! Fill an issue