Open a-gerhard opened 2 years ago
For posterity as I'm sure @a-gerhard has moved on from this issue, but it seems like the requirement for a bot to be hard-coded to a specific team is not any sort of technical requirement, but a design decision that's enforced by a single if
statement.
If you know what you're doing (which is essentially giving this bot access to every team, which may have unacceptable security implications for your use case), you can bypass it. Here's my workaround:
In err-backend-mattermost.py
, I found this line:
# In some cases (direct messages) team_id is an empty string
if data["team_id"] != "" and self.teamid != data["team_id"]:
log.info(
"Message came from another team ({}), ignoring...".format(
data["team_id"]
)
)
return
and above that, I added this line of code:
# Adding this to bypass the following check.
# Hacky, but had to make sure the bot can respond to messages across teams.
self.teamid = data["team_id"]
So now, over in config.py, just put any existing team for BOT_IDENTITY
. No matter where an event comes from, that check will think it came from the configured team.
We run a chat bot that only messages users. There is no need for the bot to be in a team on our mattermost server.