Closed idmitrievsky closed 9 years ago
Are you running the latest version of the bot? It looks like the telegrambot library is not passing the error message up to the hubot adapter, I will have a look at that.
I encountered this before when I used the wrong telegram authentication token or possibly when you are running your bot in "poll" mode while you have a webhook active.
Found the issue, it happens when you are receiving a normal HTTP error instead of a Telegram error. This is most likely related to the wrong auth token, I will update the underlying library.
Do you mean that I could have copy-pasted my bot's token wrong?
I used this post to guide myself through installation.
Yes, try and do an npm update
to update the telegrambot dependency. It should now show the HTTP status code of non-Telegram errors. If the status code is 403, it means the auth token is wrong.
Let me know what error code you receive after doing the update and I will try to assist.
Of course, sorry, I got busy with work :smile:
I updated telegrambot
as you said, now hubot prints
[Wed Jul 22 2015 13:57:40 GMT-0400 (EDT)] INFO Telegram Adapter Started...
[Wed Jul 22 2015 13:57:41 GMT-0400 (EDT)] 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)`
[Wed Jul 22 2015 13:57:41 GMT-0400 (EDT)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Wed Jul 22 2015 13:57:41 GMT-0400 (EDT)] ERROR Error:
at Function.TelegramBot.error (/home/bot/ddbot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (/home/bot/ddbot/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:47:88)
at Request.self.callback (/home/bot/ddbot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:198:22)
at Request.emit (events.js:110:17)
at Request.<anonymous> (/home/bot/ddbot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1057:14)
at Request.emit (events.js:129:20)
at IncomingMessage.<anonymous> (/home/bot/ddbot/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1003:12)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
The ERROR
part loops until I kill it. I can't really see any error codes.
Is telegrambot on version 0.0.11?
also, do you run the bot like this:
TELEGRAM_TOKEN=asdb12341414141 bin/hubot -a telegram -n botname
without wrapping the token in <> (stupid question, just checking)
Yeah, I exported TELEGRAM_TOKEN
variable earlier, it echoes back and hubot shows it on initialisation, so no problems there :smile:
I'm just not familiar with npm
and I am not exactly sure what I'm doing :disappointed: I finally reinstalled hubot-telegram
to update it dependencies :blush: Now there is a new info in error explanations:
[Wed Jul 22 2015 14:21:32 GMT-0400 (EDT)] ERROR Error: HTTP status 403 returned.
You were right. What should I do?
That means that your token isn't authenticating properly.
Try hitting this url:
https://api.telegram.org/bot[token]/getUpdates
Replace the [token] part with your token and see if you get a decent response back, if that doesn't work it means the token you exported is not valid.
I am sorry, turns out :
in my token got replaced by ;
and I didn't notice because of a bad font. All is working properly now. Thanks for your help! :+1:
I have to more questions though:
./bin/hubot -a telegram -n original_long_name -l short_name
./bin/hubot -a telegram -n original_name &
. The & will ask Linux to the process in the background.For a more complete process mangement approach, look at something like forever.js
from npm. It will keep your processes alive forever and start them up if they fail.
I feel maybe these questions should be in separate issues. However, they aren't really about hubot-telegram (well, maybe aliases problem is about Telegram).
I will have a look at the alias issue, as for the process problem...you can pipe the output to a log file like so bin/hubot -a telegram -n name > log.file &
OK, thanks a lot! :relaxed: :+1:
I found it, the issue you are running into with aliases is because of the https://core.telegram.org/bots#privacy-mode
It means that Telegram wont deliver messages unless it is directly send to the Telegram Bot user (when privacy mode is enabled). You can test this theory by running your command like this:
/@short_name help
The /
character also works with privacy mode to indicate that bots should respond to the message. You can fix the problem by turning off privacy mode using their BotFather or prefixing all your instructions to the bot with /
Got it, thanks! Prefixing with /
works like a charm.
Final question! :blush: Is there an easy way to restrict usage of my bot by other strangers?
I currently have the same problem, you can probably deal with it in multiple ways
/start password
to your bot where the password is only known to internal people. Your bot will have to have a custom script that listens for the password and then adds your user to a "safe" list.I wrote a custom "firewall" script for my personal needs, it blocks chats that don't belong to a predefined list of chatrooms.
module.exports = function (robot) {
robot.hear(/(.*)/, function (res) {
if (supportedRooms.indexOf(res.message.room) < 0) {
res.message.done = true // <- stops other listeners from responding
res.reply('you suck...I don't know you!');
}
});
}
OK, I see. It's not that hard after all, thanks! I think this info about privacy will be interesting to a lot of people – maybe add it to readme or something?
Will do, thanks
Hi,
I keep getting an error:
Do you have any ideas how to fix it?