2015-07-03 23:35:25 +00:00
|
|
|
Telegram Bots
|
|
|
|
=============
|
2015-06-26 22:33:30 +00:00
|
|
|
Create and control [Telegram bots](https://core.telegram.org/bots) easily
|
|
|
|
using the new [Telegram API](https://core.telegram.org/bots/api).
|
2015-06-26 17:20:54 +00:00
|
|
|
|
|
|
|
```
|
2015-06-26 22:33:30 +00:00
|
|
|
npm install telegram-api
|
2015-06-26 17:20:54 +00:00
|
|
|
```
|
|
|
|
|
2015-07-03 23:38:30 +00:00
|
|
|
telegram-api is in beta, your feedback is appreciated, please [fill an issue](https://github.com/mdibaiee/node-telegram-api/issues)
|
|
|
|
for any bugs you find or any suggestions you have.
|
|
|
|
|
2015-06-30 07:47:14 +00:00
|
|
|
If you are cloning this repository, remember to run `npm install` to install dependencies.
|
|
|
|
|
2015-07-09 11:45:44 +00:00
|
|
|
If you are looking for a real-life example of a bot written using this module, see [mdibaiee/webdevrobot](https://github.com/mdibaiee/webdevrobot).
|
2015-07-03 23:38:30 +00:00
|
|
|
|
2015-07-03 23:35:25 +00:00
|
|
|
[Documentation](https://github.com/mdibaiee/node-telegram-api/wiki)
|
|
|
|
==============
|
2015-07-03 23:33:35 +00:00
|
|
|
|
2015-07-03 23:35:25 +00:00
|
|
|
Example
|
|
|
|
=======
|
2015-07-03 23:33:35 +00:00
|
|
|
```javascript
|
2016-03-28 06:08:35 +00:00
|
|
|
// ES6:
|
|
|
|
import Bot, { Message, File } from 'telegram-api';
|
|
|
|
|
|
|
|
// ES5:
|
2016-03-28 07:39:16 +00:00
|
|
|
var Bot = require('telegram-api').default;
|
2015-07-03 23:33:35 +00:00
|
|
|
var Message = require('telegram-api/types/Message');
|
|
|
|
var File = require('telegram-api/types/File');
|
|
|
|
|
|
|
|
var bot = new Bot({
|
|
|
|
token: 'YOUR_TOKEN'
|
|
|
|
});
|
|
|
|
|
|
|
|
bot.start();
|
|
|
|
|
|
|
|
bot.get(/Hi|Hey|Hello|Yo/, function(message) {
|
|
|
|
var answer = new Message().text('Hello, Sir').to(message.chat.id);
|
|
|
|
|
|
|
|
bot.send(answer);
|
|
|
|
});
|
|
|
|
|
|
|
|
bot.command('start', function(message) {
|
2015-07-26 14:25:23 +00:00
|
|
|
var welcome = new File().file('./some_photo.png').caption('Welcome').to(message.chat.id);
|
2015-07-03 23:33:35 +00:00
|
|
|
|
|
|
|
bot.send(welcome);
|
|
|
|
});
|
2015-07-09 22:53:28 +00:00
|
|
|
|
|
|
|
// Arguments, see: https://github.com/mdibaiee/node-telegram-api/wiki/Commands
|
|
|
|
bot.command('weather <city> [date]', function(message) {
|
|
|
|
console.log(message.args.city, message.args.date);
|
|
|
|
})
|
2015-07-03 23:33:35 +00:00
|
|
|
```
|
|
|
|
|
2015-07-03 23:35:25 +00:00
|
|
|
Bots using this module
|
|
|
|
======================
|
2015-06-28 22:42:48 +00:00
|
|
|
|
2015-07-09 11:45:44 +00:00
|
|
|
[@webdevrobot](https://telegram.me/webdevrobot) => [mdibaiee/webdevrobot](https://github.com/mdibaiee/webdevrobot)
|
2017-07-21 19:07:51 +00:00
|
|
|
[@metagon_bot](https://telegram.me/metagon_bot) => [austinhuang0131/metagon](https://github.com/austinhuang0131/metagon)
|
2015-06-28 22:42:48 +00:00
|
|
|
|
2015-07-03 23:35:25 +00:00
|
|
|
Todo
|
|
|
|
====
|
2015-07-03 15:07:40 +00:00
|
|
|
- [x] Webhook support (not tested, see [#4](https://github.com/mdibaiee/node-telegram-api/issues/4))
|
2015-06-30 22:04:44 +00:00
|
|
|
- [x] Forward Type
|
2015-07-03 13:06:07 +00:00
|
|
|
- [x] BulkMessage Type
|
2015-07-02 22:33:22 +00:00
|
|
|
- [x] File Type
|
2015-06-28 22:48:44 +00:00
|
|
|
- [ ] Sticker Type
|
|
|
|
- [ ] Location Type
|
|
|
|
- [ ] Contact Type
|
|
|
|
- [ ] Allow remote control of bots (TCP maybe)
|
2015-06-28 22:54:41 +00:00
|
|
|
- [ ] YOUR IDEAS! [Fill an issue](https://github.com/mdibaiee/node-telegram-api/issues)
|