Code Monkey home page Code Monkey logo

Comments (21)

arcturial avatar arcturial commented on August 16, 2024

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.

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

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.

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

Do you mean that I could have copy-pasted my bot's token wrong?

I used this post to guide myself through installation.

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

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.

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

Let me know what error code you receive after doing the update and I will try to assist.

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

Of course, sorry, I got busy with work πŸ˜„

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.

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

Is telegrambot on version 0.0.11?

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

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)

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

Yeah, I exported TELEGRAM_TOKEN variable earlier, it echoes back and hubot shows it on initialisation, so no problems there πŸ˜„

I'm just not familiar with npm and I am not exactly sure what I'm doing 😞 I finally reinstalled hubot-telegram to update it dependencies 😊 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?

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

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.

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

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! πŸ‘

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

I have to more questions though:

  • Is there a way to ask bot with @ verylongname by a shorter name, for example @ vln, in a group?
  • Can hubot run constantly in the background (without blocking my command line)?

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024
  • you can run it with the hubot alias flag like ./bin/hubot -a telegram -n original_long_name -l short_name
  • You can run the hubot like ./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.

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024
  • Alias is accepted and bot prints help with its name replaced by alias, but I can't call bot within Telegram by this alias (with or without @ in front).
  • It works, but every time it handles a request it outputs a string. Is there a way to disable logging?

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).

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

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 &

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

OK, thanks a lot! ☺️ πŸ‘

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

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 /

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

Got it, thanks! Prefixing with / works like a charm.

Final question! 😊 Is there an easy way to restrict usage of my bot by other strangers?

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

I currently have the same problem, you can probably deal with it in multiple ways

  • Use Deep Linking to pass /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.
  • Create a custom script that you add first in Hubot, the script will contain a list of chatroom IDs that you can manage via a database/cache/hardcoded...and if the incoming message doesn't belong to a supported chat room (or to a user you previously approved with a password like in step 1) you can block communication.

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!');
        }
    });
}

from hubot-telegram.

idmitrievsky avatar idmitrievsky commented on August 16, 2024

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?

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

Will do, thanks

from hubot-telegram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.