lukefx / hubot-telegram Goto Github PK
View Code? Open in Web Editor NEWHubot adapter for Telegram
License: MIT License
Hubot adapter for Telegram
License: MIT License
ERROR Error: HTTP status 504 returned.
2016-04-05T20:56:20.680438+00:00 app[web.1]: at Function.TelegramBot.error (/app/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:26:15)
2016-04-05T20:56:20.680440+00:00 app[web.1]: at Request._callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:48:62)
2016-04-05T20:56:20.680441+00:00 app[web.1]: at Request.self.callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:200:22)
2016-04-05T20:56:20.680442+00:00 app[web.1]: at Request.emit (events.js:98:17)
2016-04-05T20:56:20.680443+00:00 app[web.1]: at Request.<anonymous> (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1041:10)
2016-04-05T20:56:20.680443+00:00 app[web.1]: at Request.emit (events.js:117:20)
2016-04-05T20:56:20.680444+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:968:12)
2016-04-05T20:56:20.680445+00:00 app[web.1]: at IncomingMessage.emit (events.js:117:20)
2016-04-05T20:56:20.680446+00:00 app[web.1]: at _stream_readable.js:944:16
2016-04-05T20:56:20.680447+00:00 app[web.1]: at process._tickCallback (node.js:458:13)
2016-04-05T20:56:20.680448+00:00 app[web.1]:
There are a few breaking changes in 2.x that impacts the telegram adaptor: https://coffeescript.org/#breaking-changes.
ERROR Cannot load adapter telegram - /app/node_modules/hubot-telegram/src/telegram.coffee:7:10: error: unexpected newline
super
^
A potential fix might be to replace super
with super()
.
I'm using hubot to do logging of messages and when a message is an inline reply, it can be confusing, if the reply is not noted. So it would be great if I could get access somehow to the reply_to_message
field.
For example, the code I wanted to write:
messageFromTelegramMessage = (telegramMessage) ->
message = ""
if telegramMessage.reply_to_message?
user = userFromTelegramUser telegramMessage.reply_to_message
message += "> #{user.username}: \n> #{telegramMessage.reply_to_message.text}"
message += telegramMessage.text
return message
Not a real issue but just an important thing, while sending messages to channels without a response or hear, all extra parameters should be strings or it will cause an exception.
Example:
post_to_channel = (message) ->
envelope =
room: "@mychannel"
telegram:
reply_markup: "Markdown"
disable_web_page_preview: 'true'
robot.send envelope, message
We can't use disable_web_page_preview: true
Could we modify the applyExtraOptions
function to encode extra params to strings?
Bot treats private message as public messages and requires name prepending for all commands that require it. Normal hubot behaviour (from Slack, that is my experience) is that private message do not require name prepending.
Is there a way to distinguish between group and private messages?
Hi,
When a message is received i see the following in the terminal until hubot exits.
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
[Fri Nov 27 2015 19:15:51 GMT+0330 (IRST)] INFO Receiving message_id: 140
FATAL ERROR: Evacuation Allocation failed - process out of memory
[1] 16269 abort ./bin/hubot -a telegram
Thanks
I'm pretty sure that this is not the adapter's fault but I would like to know if someone has similar problems:
[Sun Oct 11 2015 21:01:19 GMT+0200 (CEST)] ERROR Error: HTTP status 502 returned.
at Function.TelegramBot.error (/home/rene/Development/hubot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (/home/rene/Development/hubot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:48:62)
at Request.self.callback (/home/rene/Development/hubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/rene/Development/hubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1063:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/rene/Development/hubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1009:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)
I have this problem on my local machine as well as on my remote server. I also noticed that this occures multiple times.
Any ideas how to solve this?
I'm using hubot under a proxy and i'm receiving polling conflicts.
When I set interval > 6000 works but is a too high value...
[Sat Jun 30 2018 18:15:45 GMT-0300 (-03)] ERROR TypeError: Cannot read property 'length' of null
at Telegram.apiSend (/home/bot_test/bot_test/node_modules/hubot-telegram/src/telegram.coffee:122:51)
at Telegram.send (/home/bot_test/bot_test/node_modules/hubot-telegram/src/telegram.coffee:147:6)
at /home/bot_test/bot_test/node_modules/hubot/src/response.coffee:82:7
at allDone (/home/bot_test/bot_test/node_modules/hubot/src/middleware.coffee:44:37)
at /home/bot_test/bot_test/node_modules/async/lib/async.js:274:13
at Object.async.eachSeries (/home/bot_test/bot_test/node_modules/async/lib/async.js:142:20)
at Object.async.reduce (/home/bot_test/bot_test/node_modules/async/lib/async.js:268:15)
at /home/bot_test/bot_test/node_modules/hubot/src/middleware.coffee:49:13
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
[Sat Jun 30 2018 18:15:52 GMT-0300 (-03)] ERROR Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
at Function.TelegramBot.error (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:33:15)
at Request._callback (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:54:66)
at Request.self.callback (/home/bot_test/bot_test/node_modules/request/request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/home/bot_test/bot_test/node_modules/request/request.js:1157:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (/home/bot_test/bot_test/node_modules/request/request.js:1079:12)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
[Sat Jun 30 2018 18:15:57 GMT-0300 (-03)] ERROR Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
at Function.TelegramBot.error (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:33:15)
at Request._callback (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:54:66)
at Request.self.callback (/home/bot_test/bot_test/node_modules/request/request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/home/bot_test/bot_test/node_modules/request/request.js:1157:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (/home/bot_test/bot_test/node_modules/request/request.js:1079:12)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
[Sat Jun 30 2018 18:15:58 GMT-0300 (-03)] ERROR Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
at Function.TelegramBot.error (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:33:15)
at Request._callback (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:54:66)
at Request.self.callback (/home/bot_test/bot_test/node_modules/request/request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/home/bot_test/bot_test/node_modules/request/request.js:1157:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (/home/bot_test/bot_test/node_modules/request/request.js:1079:12)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
[Sat Jun 30 2018 18:16:02 GMT-0300 (-03)] ERROR Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
at Function.TelegramBot.error (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:33:15)
at Request._callback (/home/bot_test/bot_test/node_modules/telegrambot/lib/telegrambot.js:54:66)
at Request.self.callback (/home/bot_test/bot_test/node_modules/request/request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/home/bot_test/bot_test/node_modules/request/request.js:1157:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (/home/bot_test/bot_test/node_modules/request/request.js:1079:12)
at IncomingMessage.g (events.js:292:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
Telegram recommends using a secret webhook endpoint, such as https://www.example.com/<token>
for security reasons. Would it be possible to implement something like that?
Upon receiving any message since 0.0.5 (I think) on all versions:
ERROR Error: Error: Bad Request: text is empty
at Function.TelegramBot.error (node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:47:88)
at Request.self.callback (node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:198:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1057:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1003:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
I started like this:
"TELEGRAM_TOKEN=xxx:xxx TELEGRAM_INTERVAL=3500 bin/hubot -a telegram"
But there is such an error
[root@work-sys myhubot]# TELEGRAM_TOKEN=xxx:xxx TELEGRAM_INTERVAL=3500 bin/hubot -a telegram
audited 136 packages in 0.757s
1 package is looking for funding
run npm fund
for details
found 0 vulnerabilities
[Sun Jul 12 2020 10:03:26 GMT+0800 (Hong Kong Standard Time)] INFO Telegram Adapter Bot 1370169281:AAEPoSUaBBTZNsd_R5azp0W8MPGH93f_wA4 Loaded...
[Sun Jul 12 2020 10:03:26 GMT+0800 (Hong Kong Standard Time)] INFO Telegram Adapter Started...
[Sun Jul 12 2020 10:03:26 GMT+0800 (Hong Kong Standard Time)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (github/hubot-scripts#1113) in favor of packages for each script.
Your hubot-scripts.json is empty, so you just need to remove it.
[Sun Jul 12 2020 10:03:26 GMT+0800 (Hong Kong Standard Time)] ERROR Error: listen EADDRINUSE: address already in use 0.0.0.0:8080
at Server.setupListenHandle [as _listen2] (net.js:1280:14)
at listenInCluster (net.js:1328:12)
at doListen (net.js:1461:7)
at process._tickCallback (internal/process/next_tick.js:63:19)
[Sun Jul 12 2020 10:03:26 GMT+0800 (Hong Kong Standard Time)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Sun Jul 12 2020 10:03:27 GMT+0800 (Hong Kong Standard Time)] ERROR hubot-heroku-keepalive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web.url | cut -d= -f2)
[Sun Jul 12 2020 10:03:27 GMT+0800 (Hong Kong Standard Time)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Sun Jul 12 2020 10:03:29 GMT+0800 (Hong Kong Standard Time)] INFO Telegram Bot Identified: devopstest
[Sun Jul 12 2020 10:03:29 GMT+0800 (Hong Kong Standard Time)] WARNING It is advised to use the same bot name as your Telegram Bot: bobdevopstest_bot
[Sun Jul 12 2020 10:03:29 GMT+0800 (Hong Kong Standard Time)] WARNING Having a different bot name can result in an inconsistent experience when using @mentions
[Sun Jul 12 2020 10:03:35 GMT+0800 (Hong Kong Standard Time)] ERROR Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
at Function.TelegramBot.error (/data/myhubot/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (/data/myhubot/node_modules/telegrambot/lib/telegrambot.js:47:66)
at Request.self.callback (/data/myhubot/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request. (/data/myhubot/node_modules/request/request.js:1154:10)
at Request.emit (events.js:198:13)
at IncomingMessage. (/data/myhubot/node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:286:20)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
This happens when i try to call my bot using @
syntax in a group
while it works fine for direct chat with bot
eg. mybot help
-> works great in direct chat with the bot
@mybot_username help
-> sucks in group chat
ERROR TypeError: Cannot read property 'message_id' of undefined
2016-04-05T21:35:09.531315+00:00 app[web.1]: at Telegram.handleUpdate (/app/node_modules/hubot-telegram/src/telegram.coffee:176:28, <js>:217:64)
2016-04-05T21:35:09.531316+00:00 app[web.1]: at Function.<anonymous> (/app/node_modules/hubot-telegram/src/telegram.coffee:251:29, <js>:288:36)
2016-04-05T21:35:09.531317+00:00 app[web.1]: at Request._callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:51:12)
2016-04-05T21:35:09.531318+00:00 app[web.1]: at Request.self.callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:200:22)
2016-04-05T21:35:09.531319+00:00 app[web.1]: at Request.emit (events.js:98:17)
2016-04-05T21:35:09.531320+00:00 app[web.1]: at Request.<anonymous> (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1041:10)
2016-04-05T21:35:09.531320+00:00 app[web.1]: at Request.emit (events.js:117:20)
2016-04-05T21:35:09.531321+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:968:12)
2016-04-05T21:35:09.531322+00:00 app[web.1]: at IncomingMessage.emit (events.js:117:20)
2016-04-05T21:35:09.531323+00:00 app[web.1]: at _stream_readable.js:944:16
2016-04-05T21:35:09.531324+00:00 app[web.1]: at process._tickCallback (node.js:458:13)
Users that change or add a username still have either their id or their old username in the msg.message.user properties.
Is this a problem with the telegram api?
I've having trouble getting the TELEGRAM_WEBHOOK configured on Heroku. Everything I try gets 404's so I'm not sure where at app is actually listening. Here's what I'm seeing:
When TELEGRAM_WEBHOOK is set to https://<app>.herokuapp.com/
I see requets being made via the Heroku router but to /
and not to /<token>/
. This returns a 404.
2016-02-05T09:54:05.193209+00:00 heroku[router]: at=info method=POST path="/" host=teabee.herokuapp.com request_id=b0478df8-e6c2-4e4e-b0f8-e613c1098d8b fwd="149.154.167.198" dyno=web.1 connect=0ms service=5ms status=404 bytes=225
I've tried appending parts to the path, like /webhook/
and the webhook to Telegram is set to that still without the token. The Heroku logs are showing be debug statements so I'm missing the log line that prints where hubot is listening. I've also manually set the webhook within Telegram to include the token but without knowing where it is listening I'm not sure what value to set it to. So far I haven't had luck with it.
Several seconds after startup a HTTP 504 also appears within the logs. I'm not sure if this is related yet.
2016-02-05T10:07:26.371621+00:00 app[web.1]: [Fri Feb 05 2016 10:07:26 GMT+0000 (UTC)] ERROR Error: HTTP status 504 returned.
2016-02-05T10:07:26.371627+00:00 app[web.1]: at Request._callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:48:62)
2016-02-05T10:07:26.371628+00:00 app[web.1]: at Request.self.callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:199:22)
2016-02-05T10:07:26.371628+00:00 app[web.1]: at Request.emit (events.js:98:17)
2016-02-05T10:07:26.371629+00:00 app[web.1]: at Request. (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1036:10)
2016-02-05T10:07:26.371630+00:00 app[web.1]: at Request.emit (events.js:117:20)
2016-02-05T10:07:26.371631+00:00 app[web.1]: at IncomingMessage.emit (events.js:117:20)
2016-02-05T10:07:26.371632+00:00 app[web.1]: at _stream_readable.js:944:16
2016-02-05T10:07:26.371633+00:00 app[web.1]: at process._tickCallback (node.js:448:13)
This is my first deployment on Heroku so I'm still getting ahold on how things work. The code (which is basically still the Yeoman example) is here.
I've noticed the following error:
ERROR Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
when TELEGRAM_INTERVAL
is less than 3500 or not set.
Not sure if this is some environment problem since it seems such an 'obvious' error, but when I use with the webhook I get lots of:
TypeError: Cannot read property 'length' of undefined
at /home/danp/bot/node_modules/hubot-telegram/src/telegram.coffee:153:17, <js>:189:36
at callbacks (/home/danp/bot/node_modules/hubot/node_modules/express/lib/router/index.js:164:37)
at param (/home/danp/bot/node_modules/hubot/node_modules/express/lib/router/index.js:138:11)
at pass (/home/danp/bot/node_modules/hubot/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/home/danp/bot/node_modules/hubot/node_modules/express/lib/router/index.js:173:5)
at Object.router (/home/danp/bot/node_modules/hubot/node_modules/express/lib/router/index.js:33:10)
at next (/home/danp/bot/node_modules/hubot/node_modules/express/node_modules/connect/lib/proto.js:169:15)
at Object.multipart [as handle] (/home/danp/bot/node_modules/hubot/node_modules/connect-multiparty/index.js:42:27)
at next (/home/danp/bot/node_modules/hubot/node_modules/express/node_modules/connect/lib/proto.js:169:15)
at Object.urlencodedParser [as handle] (/home/danp/bot/node_modules/hubot/node_modules/express/node_modules/connect/node_modules/body-parser/lib/types/urlencoded.js:69:27)
at next (/home/danp/bot/node_modules/hubot/node_modules/express/node_modules/connect/lib/proto.js:169:15)
at /home/danp/bot/node_modules/hubot/node_modules/express/node_modules/connect/node_modules/body-parser/lib/read.js:107:5
at IncomingMessage.onEnd (/home/danp/bot/node_modules/hubot/node_modules/express/node_modules/connect/node_modules/body-parser/node_modules/raw-body/index.js:136:7)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
My node version:
node -v
v0.10.26
I want to read the text of the response of the text of a message, for example:
p1: hi, what is your name?
p2 replay: p1 "hi, what is your name?"
Gustavo
And I need to get "hi, what is your name?"
I think that the best way is to add a property to message
constructor (user, text, id, reponseText = null) {
super(user)
this.text = text
this.id = id
+ this.reponseText = reponseText
}
Someone have a better idea?
Hey
With regards to hubotio/hubot#993, do you want to merge your code with mine or how do you want to go about doing this? I would like to make use of the telegrambot npm module instead of doing the HTTP directly in the Hubot adapter. This will help with future extendibility. I am also in the progress of adding different message types like "Leave" and "Join".
When the bot sends a message that has unclosed/invalid markdown and parse_mode
is set to Markdown
. An error is raised from the telegram api and the message is never sent.
This is a problem, as the message delivery should be our number 1 concern.
My proposal is that a check be made in the send
function:
###*
# Send a message to a specific room via the Telegram API
###
send: (envelope, strings...) ->
self = @
text = strings.join()
data = @applyExtraOptions({chat_id: envelope.room, text: text}, envelope.telegram);
@apiSend data, (err, message) =>
if (err)
@robot.logger.debug "Error received: " + err
found = err.search /entities/
if (found > 0)
# send the message again without markdown set
...
self.emit 'error', err
else
self.robot.logger.info "Sending message to room: " + envelope.room
Please look over and add to this code if you think it is an acceptable way, if not let me know ways to improve it.
Also, @gburgett if you have a minute please let me know your thoughts.
I had set up the adapter using the instructions provided in the Readme, but I've been getting HTTP Error 409. Telegram's error handling documentation doesn't seem to have any explanation for this error code.
Here is the console output :
[Wed Jul 15 2015 11:37:36 GMT+0530 (IST)] ERROR Error: HTTP status 409 returned.
at Function.TelegramBot.error (/Users/nevin/myhubot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:25:15)
at Request._callback (/Users/nevin/myhubot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:45:62)
at Request.self.callback (/Users/nevin/myhubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:197:22)
at Request.emit (events.js:110:17)
at Request.<anonymous> (/Users/nevin/myhubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1050:14)
at Request.emit (events.js:129:20)
at IncomingMessage.<anonymous> (/Users/nevin/myhubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:996:12)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
I also tested the same by deploying to Heroku (in case it's a network issue) but the logs show me the same output. Here's the instructions I followed.
I added the Hubot to a group chat, and registered bot commands.
Now when I type /
slash, it will automatically suggest available slash commands like:
/hi
However, after I click on the suggestion, it will populate chat box as /hi@botname
.
My bot can't respond to slash command followed by bot name.
How to handle this use case?
Hi, I can't understand how to use telegram specific functionality using the example on the readme, It would be great if someone can create a working coffee script (which sends a picture or a sticker) so I can learn from it. sorry for being such a noob 😅
Thanks.
Wanted to see if there was a way to add a self-signed certificate, since telegram only communicates fully over https. I'm collaborating with a team that is looking at options to move an existing bot to interface with hubot so that it can be more easily used on different chat platforms.
Does something like this exist for hubot-telegram?
Depending on how long a request to Telegram and it's processing takes (potentially a slow plugin), the setInterval method can call a new getUpdates
before the previous handleUpdate
has finished. This results in the same messages being delivered as the offset has yet to be updated.
can you give some guidance how to extend this API to send stickers?
i'm looking at the way other APIs are called:
https://github.com/lukefx/hubot-telegram/blob/master/src/telegram.coffee#L94
send: (envelope, strings...) ->
self = @
@api.invoke 'sendMessage', { chat_id: envelope.room, text: strings.join() }, (err, message) =>
so then this part would be easy enough to extend as
https://core.telegram.org/bots/api#sendsticker
@api.invoke 'sendSticker', { chat_id: envelope.room, sticker: "someFileId" }
but how do i tell Hubot to understand how to connect to this non-standard adapter message?
I tried with a script as
robot.hear /sticker/i, (res) ->
res.sendSticker "sticker!"
but get the beloved: undefined is not a function
UPDATE
I see a readme in the node_module that doesn't seem to be in the repo itself...
## Available Methods
All methods available on the API can be access using this library. The list of methods and expected results can be found in the [Bot API document](https://core.telegram.org/bots/api).
The methods can be used like this:
``` nodejs
var TelegramBot = require('telegrambot');
...
api.sendSticker(opts, callback);
so is an api
object available to the scripts?
Hello,
I've encountered the same problem as #41. I almost gave up on the idea to make hubot work with telegram but accidentally found a workaround.
If the bot name has an underscore in it, then the help command doesn't work (but all other commands work fine). See the debug log below.
All Telegram bots have _bot in the end of their names. Also if you want to address the bot in the group chat, its (hubot) name must be the same as Telegram bot name. And here is the problem, underscore characters in the name makes the help command fail.
The workaround I found is to have the (hubot) name without underscore and provide a convenient alias for addressing the bot from the chat. For example, use / character as alias, start the hubot like this
bin/hubot -a telegram -l /
and in the group chat type /command
instead of @botname command
I hope this helps.
My setup:
vagrant@u1604:~/gttest003_bot$ uname -a
Linux u1604 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
vagrant@u1604:~/gttest003_bot$ node --version
v6.9.1
vagrant@u1604:~/gttest003_bot$ npm --version
3.10.8
Debug log showing unsuccessful help and successful ping commands:
vagrant@u1604:~/gttest003_bot$ HUBOT_LOG_LEVEL="debug" TELEGRAM_TOKEN=XXX bin/hubot -a telegram
[Sat Nov 26 2016 17:36:46 GMT+0000 (UTC)] DEBUG Loading adapter telegram
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO Telegram Adapter Bot XXX Loaded...
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO Telegram Adapter Started...
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading scripts from /home/vagrant/gttest003_bot/scripts
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/scripts/example.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading scripts from /home/vagrant/gttest003_bot/src/scripts
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading hubot-scripts from /home/vagrant/gttest003_bot/node_modules/hubot-scripts/src/scripts
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.
Your hubot-scripts.json is empty, so you just need to remove it.
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading external-scripts from npm packages
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-diagnostics/src/diagnostics.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-help/src/help.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web-url | cut -d= -f2)`
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-heroku-keepalive/src/heroku-keepalive.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-google-images/src/google-images.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-google-translate/src/google-translate.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-pugme/src/pugme.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-maps/src/maps.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-redis-brain/src/redis-brain.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-rules/src/rules.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-shipit/src/shipit.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG hubot-redis-brain: Successfully connected to Redis
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO Telegram Bot Identified: gttest003_bot
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG { update_id: 364844667,
message:
{ message_id: 31,
from:
{ id: 157896654,
first_name: 'Gennady',
last_name: 'Trafimenkov',
username: 'gtrafimenkov' },
chat:
{ id: 157896654,
first_name: 'Gennady',
last_name: 'Trafimenkov',
username: 'gtrafimenkov',
type: 'private' },
date: 1480181826,
text: 'help' } }
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] INFO Receiving message_id: 31
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Received message: gtrafimenkov said 'gttest003_bot help'
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Message 'gttest003_bot help' matched regex //^\s*[@]?gttest003_bot[:,]?\s*(?:help(?:\s+(.*))?$)/i/; listener.options = { id: null }
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'gttest003_bot help'
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Message length: 1212
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Message parts: 1
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] ERROR Error: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 1027
at Function.TelegramBot.error (/home/vagrant/gttest003_bot/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (/home/vagrant/gttest003_bot/node_modules/telegrambot/lib/telegrambot.js:47:66)
at Request.self.callback (/home/vagrant/gttest003_bot/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/home/vagrant/gttest003_bot/node_modules/request/request.js:1081:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/home/vagrant/gttest003_bot/node_modules/request/request.js:1001:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG { update_id: 364844668,
message:
{ message_id: 32,
from:
{ id: 157896654,
first_name: 'Gennady',
last_name: 'Trafimenkov',
username: 'gtrafimenkov' },
chat:
{ id: 157896654,
first_name: 'Gennady',
last_name: 'Trafimenkov',
username: 'gtrafimenkov',
type: 'private' },
date: 1480181831,
text: 'ping' } }
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] INFO Receiving message_id: 32
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Received message: gtrafimenkov said 'gttest003_bot ping'
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Message 'gttest003_bot ping' matched regex //^\s*[@]?gttest003_bot[:,]?\s*(?:PING$)/i/; listener.options = { id: null }
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'gttest003_bot ping'
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Message length: 4
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Message parts: 1
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] INFO Sending message to room: 157896654
"Renamed the fields new_chat_participant and left_chat_participant of the Message object to new_chat_member and left_chat_member."
Somehow, with the new feature merge, the bot started with bin/hubot -a telegram -n CoolNameBot -l CoolBotName
doesn't answer to @CoolNameBot anymore, only to @CoolBotName, CoolBotName or CoolNameBot queries.
Doesn't react when the @ is prepended to its name.
When using /command@bot_name in a chat (for when multiple bots are present, the bot name needs to be removed so Hubot can recognize the command.
[Mon Jun 13 2016 10:19:30 GMT+0200 (SAST)] DEBUG Executing listener callback for Message '/help@bot_name'
^ This won't recognize the correct command, only the / is currently being stripped
When I send the text "help" to my bot, the log shows:
2016-03-18T22:21:56.138903+00:00 app[web.1]: [Fri Mar 18 2016 22:21:56 GMT+0000 (UTC)] INFO Receiving message_id: 74
2016-03-18T22:21:56.552791+00:00 app[web.1]: [Fri Mar 18 2016 22:21:56 GMT+0000 (UTC)] ERROR Error: [Error]: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 1042
2016-03-18T22:21:56.552805+00:00 app[web.1]: at Function.TelegramBot.error (/app/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:26:15)
2016-03-18T22:21:56.552806+00:00 app[web.1]: at Request._callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:47:66)
2016-03-18T22:21:56.552807+00:00 app[web.1]: at Request.self.callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:199:22)
2016-03-18T22:21:56.552808+00:00 app[web.1]: at Request.emit (events.js:98:17)
2016-03-18T22:21:56.552809+00:00 app[web.1]: at Request. (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1036:10)
2016-03-18T22:21:56.552810+00:00 app[web.1]: at Request.emit (events.js:117:20)
2016-03-18T22:21:56.552810+00:00 app[web.1]: at IncomingMessage. (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:963:12)
2016-03-18T22:21:56.552811+00:00 app[web.1]: at IncomingMessage.emit (events.js:117:20)
2016-03-18T22:21:56.552812+00:00 app[web.1]: at _stream_readable.js:944:16
2016-03-18T22:21:56.552813+00:00 app[web.1]: at process._tickCallback (node.js:458:13)
2016-03-18T22:21:56.552814+00:00 app[web.1]:
I'm not sure if it's a problem in hubot, the telegram plugin or heroku. But as the error starts pointing to telegram I decided to start here. I'm new to this, so please let me know if I can provide more information.
input /help in the chat with my bot, it working well.
when input /help in the group with my bot
i can see the log:INFO Receiving message_id: 91
but it doesn't sending message to room: xxxxxxx, where is wrong?
Started receiving this error once I upgraded to 0.1.1
ERROR RangeError: Maximum call stack size exceeded
at Object.stringify (native)
at TelegramBot.request (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:75:53)
at TelegramBot.invoke (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:95:32)
at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/src/telegram.coffee:143:14
at Telegram.apiSend (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/src/telegram.coffee:150:5)
at Telegram.reply (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot-telegram/src/telegram.coffee:179:6)
at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/src/response.coffee:82:7
at allDone (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/src/middleware.coffee:44:37)
at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/node_modules/async/lib/async.js:274:13
at Object.async.eachSeries (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/node_modules/async/lib/async.js:142:20)
at Object.async.reduce (/home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/node_modules/async/lib/async.js:268:15)
at /home/gitlab-runner/builds/8720be54/0/webservices/bot/node_modules/hubot/src/middleware.coffee:49:13
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
[RangeError: Maximum call stack size exceeded]
Haven't had time to debug in detail yet, rolling back to 0.1.0 solved the problem...so I am assuming it's something in the new release.
according to latest api changes please add inline query support to your api
https://core.telegram.org/bots/inline
tnx!
I think we should change the polling mechanism from setInterval
to setTimeout
If the bot experiences slow internet connectivity, the setInterval
function will trigger the callback multiple times before the first callback is complete and the message offset is updated. This results in the same messages being handled multiple times.
If we change this to be setTimeout
and recreate a new timeout once the old one completes, this problem should not occur anymore.
The bot will then effectively "lag" until the getUpdates
call is complete or fails. Thoughts, @lukefx?
Hi My hubot doesn't listen to slash commands in supergroups. privacy mode on or off no change. only mentions are working. Debug:
[Tue Jun 27 2017 08:40:23 GMT+0000 (UTC)] DEBUG { update_id: 615849531,
message:
{ message_id: 234,
from:
{ id: SECRET,
first_name: 'SECRET',
username: 'mtrnord',
language_code: 'de' },
chat:
{ id: -SECRET,
title: 'SECRET',
type: 'supergroup' },
date: 1498552821,
text: '/help',
entities: [ [Object] ] } }
[Tue Jun 27 2017 08:40:23 GMT+0000 (UTC)] INFO Receiving message_id: 234
[Tue Jun 27 2017 08:40:23 GMT+0000 (UTC)] DEBUG Received message: mtrnord said '/help'
[Tue Jun 27 2017 08:40:23 GMT+0000 (UTC)] DEBUG No listeners executed; falling back to catch-all
[Tue Jun 27 2017 08:40:23 GMT+0000 (UTC)] DEBUG Executing listener callback for Message '[object Object]'
I have a hubot bot with this telegram backend ( https://github.com/jaquerespeis/eljaqueado )
Today we migrated our group chat to a supergroup, and now the bot is not receiving any messages from the group. Direct message still work fine.
Hello,
Sorry for the silly request but being a newbie and not so savvy with code I would like to kindly request your help on a simple .coffee script that downloads any image, audio or voice clip sent via Telegram to hubot on the filesystem. I honestly do not know where or how to start. Is this even possible?
Thank you very much and sorry for the inconvenience.
The list of hubot adapters in the hubot documentation is being replaced with a link to a GitHub topic search. Add the hubot-adapter
topic to your repository on GitHub to include it in this list.
Would it be possible to expand the normal msg.message.room (for telegram it is really just a number and barely useful) information in some (probably convoluted) way?
I tried some packages which require mentioning people in a room, and they don't work.
Is it possible to get usernames from telegram API to hubot?
Let's say i added command /hello to my bot. Now i try to catch it and i cant find how. Apparently bot threat /hello and hello the same.
Bot should treat registered slash commands as a mention + message. I dont want hello (without slash) to be processed at all (as common words may interfere with commands) but /hello should work like i mentioned the bot.
Is there a way to achieve that? so say i can make robot.respond //hello/i and it will work?
hi, got "message is too long" error
[Mon Aug 31 2015 01:01:55 GMT+0000 (UTC)] INFO Receiving message_id: 4
[Mon Aug 31 2015 01:01:55 GMT+0000 (UTC)] ERROR Error: Error: Message is too long
at Function.TelegramBot.error (/hubot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (/hubot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:47:66)
at Request.self.callback (/hubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:198:22)
at Request.emit (events.js:110:17)
at Request.<anonymous> (/hubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1073:14)
at Request.emit (events.js:129:20)
at IncomingMessage.<anonymous> (/hubot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1019:12)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
Same bot works well with Slack
back-end.
$ wc ~/temp/hubot-help.txt
72 915 5565 /Users/n0mer/temp/hubot-help.txt
So my /help
mesage contains 72 lines, 915 words and 5565 chars
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.