How to listen /command@bot in supergroup?
In supergroup, I can use /command trigger the bot, but /command@bot cannot trigger the bot.
@iVanilla does your bot receive /command@bot message at all?
Could you check in you logs?
@ivanovaleksey No, only received /command.
Where is the logs file path?
Hi @ivanovaleksey, messages are coming. But now bot doesn't triggered by them :( Is there only one way to fix it? (by adding /command@bot_name to our cases)
@iVanilla i think you should set the bot as the admin of the group ... it should works
@eVanilla didn't help :( Incoming messages still coming like /command@bot_name may be we talking about different problems :)
I don't have very much experience about using bots in groups. But the situation seems pretty clear. Let's look at the official documentation on commands:
If multiple bots are in a group, it is possible to add bot usernames to commands in order to avoid confusion: /start@TriviaBot /start@ApocalypseBot This is done automatically when commands are selected via the list of suggestions. Please remember that your bot needs to be able to process commands that are followed by its username.
So, it is totally up to developer how to trigger on a message. If your bot is in a group and you just check command name (and don't check which bot the command is addressed to) it might be ambiguous situation.
As about ways of "fixing" it. Yes, the most obvious would be to add switches with explicit bot name. I guess In Ruby you can even create a nice little wrapper for it.
Also please note that you can check chat's type. For instance
#<Telegram::Bot::Types::Message:0x00007fb1efc264a8
@audio=nil,
@author_signature=nil,
@caption=nil,
@channel_chat_created=nil,
@chat=
#<Telegram::Bot::Types::Chat:0x00007fb1efc25c88
@all_members_are_administrators=true,
@description=nil,
@first_name=nil,
@id=-101746809,
@invite_link=nil,
@last_name=nil,
@photo=nil,
@pinned_message=nil,
@title="Home chat",
@type="group", # for direct messages it would be "private"
@username=nil>,
@contact=nil,
@date=1509222289,
....
Maybe I can use it somehow.
@GanjMonk hmmm can you show us your source code ?(i mean a little bit ...) maybe you typed something wrong .. because i had this problem before and that cause i was banned from telegram and i couldn't even make an channel and i said to my friend to make a bot for me and it worked for me
@eVanilla, sure.
This code doesn't work if command sent from Group Chat /start@bot_name
Telegram::Bot::Client.run(token, logger: Logger.new($stdout)) do |bot|
begin
bot.listen do |message|
case message.text
when '/start'
message_text = "Hi #{message.from.first_name}, here is a list of commands: \n
/calls - _List of calls_ \n
/duty - _Duty list_ \n
/requests - _Requests statistic_"
bot.api.sendMessage(chat_id: message.chat.id, text: message_text, parse_mode: 'Markdown')
This code works if command sent from Group Chat /start@bot_name
Telegram::Bot::Client.run(token, logger: Logger.new($stdout)) do |bot|
begin
bot.listen do |message|
case message.text
when '/start', '/start@bot_name'
message_text = "Hi #{message.from.first_name}, here is a list of commands: \n
/calls - _List of calls_ \n
/duty - _Duty list_ \n
/requests - _Requests statistic_"
bot.api.sendMessage(chat_id: message.chat.id, text: message_text, parse_mode: 'Markdown')
@GanjMonk hmmm weird... use this send_message instead of this sendMessage
@eVanilla it works the same. As @ivanovaleksey said it's up to developer how to trigger on a message, so I think we can close this issue. Thx for help.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.