mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-08 11:58:34 +02:00
Ignore messages from Slack's official bot (#1703)
* Ignore messages from Slack's official bot * re-added message filter
This commit is contained in:
parent
5d552705aa
commit
8c6cd661f5
@ -56,7 +56,6 @@ from shared_configs.configs import MODEL_SERVER_PORT
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
|
||||
# In rare cases, some users have been experiencing a massive amount of trivial messages coming through
|
||||
# to the Slack Bot with trivial messages. Adding this to avoid exploding LLM costs while we track down
|
||||
# the cause.
|
||||
@ -70,6 +69,9 @@ _SLACK_GREETINGS_TO_IGNORE = {
|
||||
":wave:",
|
||||
}
|
||||
|
||||
# this is always (currently) the user id of Slack's official slackbot
|
||||
_OFFICIAL_SLACKBOT_USER_ID = "USLACKBOT"
|
||||
|
||||
|
||||
def prefilter_requests(req: SocketModeRequest, client: SocketModeClient) -> bool:
|
||||
"""True to keep going, False to ignore this Slack request"""
|
||||
@ -92,6 +94,15 @@ def prefilter_requests(req: SocketModeRequest, client: SocketModeClient) -> bool
|
||||
channel_specific_logger.error("Cannot respond to empty message - skipping")
|
||||
return False
|
||||
|
||||
if (
|
||||
req.payload.setdefault("event", {}).get("user", "")
|
||||
== _OFFICIAL_SLACKBOT_USER_ID
|
||||
):
|
||||
channel_specific_logger.info(
|
||||
"Ignoring messages from Slack's official Slackbot"
|
||||
)
|
||||
return False
|
||||
|
||||
if (
|
||||
msg in _SLACK_GREETINGS_TO_IGNORE
|
||||
or remove_danswer_bot_tag(msg, client=client.web_client)
|
||||
|
Loading…
x
Reference in New Issue
Block a user