@@ -1,6 +1,6 @@ |
||
1 | 1 |
{ |
2 | 2 |
"name": "hubot-multi-adapter", |
3 |
- "version": "0.1.3", |
|
3 |
+ "version": "0.1.4", |
|
4 | 4 |
"description": "A Hubot adapter that can receive messages thru socket.io or telegram", |
5 | 5 |
"main": "src/multi-adapter", |
6 | 6 |
"scripts": { |
@@ -10,8 +10,9 @@ |
||
10 | 10 |
"license": "ISC", |
11 | 11 |
"dependencies": { |
12 | 12 |
"express": "^4.15.2", |
13 |
- "socket.io": "^1.4.5", |
|
14 |
- "parent-require": "^1.0.0" |
|
13 |
+ "node-telegram-bot-api": "^0.27.1", |
|
14 |
+ "parent-require": "^1.0.0", |
|
15 |
+ "socket.io": "^1.4.5" |
|
15 | 16 |
}, |
16 | 17 |
"peerDependencies": { |
17 | 18 |
"hubot": ">=2.0" |
@@ -5,13 +5,20 @@ catch |
||
5 | 5 |
{Robot,Adapter,TextMessage,User} = prequire 'hubot' |
6 | 6 |
|
7 | 7 |
port = parseInt process.env.HUBOT_SOCKETIO_PORT or 9090 |
8 |
-console.log("socket.io server on port " + port); |
|
9 |
- |
|
10 | 8 |
io = require('socket.io').listen port |
9 |
+console.log("socket.io server on port " + port); |
|
11 | 10 |
|
12 | 11 |
express = require('express') |
13 | 12 |
app = express() |
14 | 13 |
|
14 |
+app.listen(3000, function () { |
|
15 |
+ console.log('HTTP server on port 3000') |
|
16 |
+}) |
|
17 |
+ |
|
18 |
+var TelegramBot = require('node-telegram-bot-api'); |
|
19 |
+#Telegram bot token (given when you create a new bot using the BotFather); |
|
20 |
+var telegramBot = new TelegramBot(process.env.TELEGRAM_TOKEN, {polling: false}); |
|
21 |
+ |
|
15 | 22 |
class MultiAdapter extends Adapter |
16 | 23 |
|
17 | 24 |
constructor: (@robot) -> |
@@ -48,6 +55,9 @@ class MultiAdapter extends Adapter |
||
48 | 55 |
@robot.brain.remove 'log_id_' + socket.id |
49 | 56 |
delete @sockets[socket.id] |
50 | 57 |
|
58 |
+ app.post '/telegram-api', (req, res) => |
|
59 |
+ console.log(req.param('message')) |
|
60 |
+ |
|
51 | 61 |
@emit 'connected' |
52 | 62 |
|
53 | 63 |
exports.use = (robot) -> |