Comments (5)
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.
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.
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 forrobot.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.
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.
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)
- Receiving double messages when polling
- ERROR Error: HTTP status 504 returned. HOT 2
- ERROR TypeError: Cannot read property 'message_id' of undefined HOT 11
- bot no receiving messages from supergroup HOT 5
- API fields have been renamed HOT 2
- Remove bot name when using /command@bot_name HOT 1
- Maximum call stack size exceeded HOT 6
- Slow connectivity causes duplicate messages HOT 2
- Newbie request
- error on help command (and workaround) HOT 11
- Expose reply_to_message from message
- Add `hubot-adapter` topic HOT 1
- / commands in supergroups not working HOT 2
- Proxy issues HOT 1
- CoffeeScript 2.x support HOT 2
- Read the response text of a message HOT 1
- Group Chat Slash Command With Mention HOT 1
- Interval Issue HOT 1
- Markdown with Bad Entities
- Error seeking help HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hubot-telegram.