Code Monkey home page Code Monkey logo

Comments (5)

arcturial avatar arcturial commented on August 16, 2024

The bot will treat /hello and hello the same only when you are having a one on one chat with the bot. If you are in a group chat (with privacy mode enabled), the bot will not respond to "hello" and will wait until it receives a message like "@bot hello" or "/hello". It has been implemented this way so that the behaviour is similar between different hubot adapters.

The script you write shouldn't listen for /\/hello/i and instead should listen for /hello/i. The getUpdates command will only return commands that were meant for the bot (ie. all messages in private chat...only mentions of slash commands in group chat).

If you have privacy mode disabled in a group chat, all messages will be treated as potential bot commands and this can in turn cause a problem with common words. I would suggest making sure privacy mode is turned on, it will also make sure your bot does less processing.

from hubot-telegram.

Fedcomp avatar Fedcomp commented on August 16, 2024

Thanks for response.
I am depend on bot.hear functionality, so i had to turn privacy mode off. Well, i guess turning it back on will solve my issues. Is there anyway could be possibility to process slash messages with bot.respond while privacy mode turned off? maybe environment variable? honestly i dont know how hard that would be to implement.

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

Hey

Please try branch: https://github.com/lukefx/hubot-telegram/tree/issue-25

You can include it in your package.json file like hubot-telegram: lukefx/hubot-telegram#issue-25. This branch contains an environment variable called TELEGRAM_PRIVACY which will be 1 by default. If you make this variable 0, your messages will be processed without stripping out any slashes.

Please beware that this will affect all chats. If you turn this feature off...it will forward the messages directly to the handlers, the only modification to them will be to make sure the robot name is added to messages originating from a private chat.

I would suggest you rather use robot.respond for the specific slash commands you need instead of relying on hear. Doing so should eliminate accidental triggers since a user would have to mention the robot or add a / in front.

Example (group chat):

robot.respond(/hello/)

  • will trigger for /hello
  • will trigger for @bot hello
  • will trigger for @botAlias hello
  • won't trigger for hello

Example (private chat):

robot.respond(/hello/)

  • will trigger for hello
  • will trigger for @bot hello
  • will trigger for /hello (if you turn off TELEGRAM_PRIVACY, this will no longer trigger as the message will be evaluated WITH the forward slash and will only trigger for robot.respond(/\/hello/i))

Please let me know if this will work for you and if you can provide some more detail on your use case I would appreciate it...I am still not sure why you would need to make the adapter aware of privacy mode.

from hubot-telegram.

arcturial avatar arcturial commented on August 16, 2024

You should now be able to support this with the pull request #34

You can add the bot alias "/" and the bot will respond to commands in a group chat like "/hello"

from hubot-telegram.

Fedcomp avatar Fedcomp commented on August 16, 2024

hello, sorry for delay, had no time to test it, but thank you for your great work! glad it's merged into master now.

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.