Skip to content

Commit

Permalink
Update NestBot handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Jan 19, 2025
1 parent 22994be commit a7da60a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion backend/apps/slack/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@

FEEDBACK_CHANNEL_MESSAGE = (
f"💬 You can share feedback on your {NEST_BOT_NAME} experience "
f"in the <#{OWASP_PROJECT_NEST_CHANNEL_ID}|project-nest> channel.{NL}"
f"in the <{OWASP_PROJECT_NEST_CHANNEL_ID}|project-nest> channel.{NL}"
)
12 changes: 11 additions & 1 deletion backend/apps/slack/events/member_joined_channel/catch_all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Slack member joined any other channel handler."""

from apps.slack.apps import SlackConfig
from apps.slack.constants import OWASP_CONTRIBUTE_CHANNEL_ID, OWASP_GSOC_CHANNEL_ID


def catch_all_handler(event, client, ack): # noqa: ARG001
Expand All @@ -9,4 +10,13 @@ def catch_all_handler(event, client, ack): # noqa: ARG001


if SlackConfig.app:
SlackConfig.app.event("member_joined_channel")(catch_all_handler)
SlackConfig.app.event(
"member_joined_channel",
matchers=[
lambda event: f"#{event['channel']}"
not in {
OWASP_CONTRIBUTE_CHANNEL_ID,
OWASP_GSOC_CHANNEL_ID,
}
],
)(catch_all_handler)
12 changes: 4 additions & 8 deletions backend/apps/slack/events/member_joined_channel/contribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ def contribute_handler(event, client, ack):


if SlackConfig.app:

def check_contribute_handler(event):
"""Check if the event is a member_joined_channel in #contribute."""
return f"#{event['channel']}" == OWASP_CONTRIBUTE_CHANNEL_ID

SlackConfig.app.event("member_joined_channel", matchers=[check_contribute_handler])(
contribute_handler
)
SlackConfig.app.event(
"member_joined_channel",
matchers=[lambda event: f"#{event['channel']}" == OWASP_CONTRIBUTE_CHANNEL_ID],
)(contribute_handler)
10 changes: 4 additions & 6 deletions backend/apps/slack/events/member_joined_channel/gsoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def gsoc_handler(event, client, ack):


if SlackConfig.app:

def check_gsoc_handler(event):
"""Check if the event is a member_joined_channel in #gsoc."""
return f"#{event['channel']}" == OWASP_GSOC_CHANNEL_ID

SlackConfig.app.event("member_joined_channel", matchers=[check_gsoc_handler])(gsoc_handler)
SlackConfig.app.event(
"member_joined_channel",
matchers=[lambda event: f"#{event['channel']}" == OWASP_GSOC_CHANNEL_ID],
)(gsoc_handler)

0 comments on commit a7da60a

Please sign in to comment.