Skip to content

Bot fails to respond with copied ping if username is capitalized #521

Description

@joshuaboniface

Describe the bug
The bot does not respond to pings that were copied if the bots name ends up capitalized. For instance, if you have the bot @bot, but it has a "nice" name of @Bot, copying a message that contains the nice @Bot fails to trigger a requires_mention action.

How To Reproduce

  1. Create a bot with a lowercase name (e.g. @bot).
  2. Give the bot a name case nice name (e.g. Bot).
  3. Create a requires_mention plugin/task called mytask.
  4. Send a ping to the bot manually (@bot mytask)
  5. Copy the resulting text which should be @Bot mytask).
  6. Send the resulting text.
  7. Task fails to trigger.

Expected behavior
The bot should respond to a ping with either name format, @bot or @Bot, as Mattermost treats these as equivalent.

Operating Environment (please complete the following information):

  • mmpy_bot Version: 2.1.4
  • mattermostdriver/mattermostautodriver Version: 1.2.2
  • Mattermost Server Version: 7.8.4
  • Python Version: 3.8
  • OS: Ubuntu Linux 20.04

Additional context
It looks like the problem is with https://github.com/attzonko/mmpy_bot/blob/main/mmpy_bot/event_handler.py#L31. This doesn't ignore case, so when the message with a capitalized ping comes in, it doesn't match and get stripped out. I was looking for a later point to try to fix this but don't see the obvious path for what triggers needs_mention to be True, so this seems like the simplest solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions