Skip to content

Bot is responding to commands for other bots in group chats when privacy option is turned off #319

@blueset

Description

@blueset

Steps to reproduce

  1. Get a bot, turn off privacy option in @botfather, and drag it in a group with other bots (which should respond to /start command in a group).
  2. Set up the bot with the following code:
import telegram, telegram.ext
tb = telegram.ext.Updater("TOKEN")
def a(bot, update):
    bot.sendMessage(update.message.chat_id, "responding to /start cmd")

tb.dispatcher.add_handler(telegram.ext.CommandHandler("start", b))
tb.start_polling()
  1. Send command /start@some_other_bot to the group, and your bot will respond to it.
  2. Send command /start to the group and your bot (and in fact many other bots) will respond to it too.

Expected behaviour

Bot should not respond to cmds not pointing to it, and better give an option not to respond to cmd with no target in a group.

Configuration

Operating System:
Mac OS X El Capitan

Version of Python:

$ python3 -V

Python 3.5.1

Version of python-telegram-bot:

$ python3 -c 'import telegram; print(telegram.__version__)'

4.1.1

Logs

Insert logs here (if necessary)

Where the issue happens

update.message.text[1:].split(' ')[0].split('@')[0] == self.command

on line 45 of telegram/ext/commandhandler.py
It is not checking for the target of command issued by user.

Suggested changes

  1. Check for commands with @ for whether it's pointed to the bot.
  2. Add a parameter to CommandHandler: toggle whether if the bot should respond to simple commands (command without @name_of_the_bot) in a group, and default it to True. (for backward compatibility, and behaviour consistancy)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy