1- from enum import IntEnum
1+ import logging
22
33from sirbot import SirBot
44from slack import methods
55from slack .actions import Action
6+ from slack .exceptions import SlackAPIError
67
78from pybot .endpoints .slack .message_templates .mentor_volunteer import MentorVolunteer
89from pybot .endpoints .slack .utils import MENTOR_CHANNEL
910
10-
11- class VolunteerBlockIndex (IntEnum ):
12- SKILLSET_OPTIONS = 2
13- SELECTED_SKILLSETS = 3
14- SUBMIT = 5
11+ logger = logging .getLogger (__name__ )
1512
1613
1714async def add_volunteer_skillset (action : Action , app : SirBot ) -> None :
@@ -37,7 +34,6 @@ async def submit_mentor_volunteer(action: Action, app: SirBot) -> None:
3734 slack = app .plugins ["slack" ].api
3835 admin_slack = app .plugins ["admin_slack" ].api
3936 airtable = app .plugins ["airtable" ].api
40- bot_user_id = action ["user" ]["id" ]
4137
4238 request = MentorVolunteer (action )
4339
@@ -58,13 +54,14 @@ async def submit_mentor_volunteer(action: Action, app: SirBot) -> None:
5854 request .airtable_error (airtable_response )
5955 else :
6056
61- # checks if the user submitting the form owns the admin token used for the bot
62- # stops an exception being being raised if a user tries to invite themselves to a channel
63- if bot_user_id != user_id :
57+ try :
6458 await admin_slack .query (
6559 methods .CONVERSATIONS_INVITE ,
6660 {"channel" : MENTOR_CHANNEL , "users" : [user_id ]},
6761 )
62+ except SlackAPIError as error :
63+ logger .debug ("Error during mentor channel invite %s" , error .data ["errors" ])
64+
6865 request .on_submit_success ()
6966
7067 await request .update_message (slack )
0 commit comments