Python backend for a Slack's kudos plugin.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add error messages

+55 -7
+28 -4
kefi/routers/helpers.py
··· 27 27 delete_attendance, 28 28 is_attending, 29 29 ) 30 - from kefi.routers.messages import UserJoinedMeetMessage, UserLeftMeetMessage 30 + from kefi.routers.messages import ( 31 + AlreadyAttendingMessage, 32 + BaseMessage, 33 + NotAttendingMessage, 34 + NotEnoughKefiMessage, 35 + UserJoinedMeetMessage, 36 + UserLeftMeetMessage, 37 + ) 31 38 from kefi.routers.responses import ( 32 39 ActionResponse, 33 40 HelpResponse, ··· 196 203 197 204 def _view_submission_meet_join(self, view_id: str) -> list | dict: 198 205 """Joins the plaza.""" 206 + message: BaseMessage 199 207 try: 200 208 create_attendance(user=self.user, session=self.session) 201 209 message = UserJoinedMeetMessage() ··· 205 213 text=message.text(), 206 214 ) 207 215 except NotEnoughKefi: 208 - ... 216 + message = NotEnoughKefiMessage() 217 + self.slack.post_message_user( 218 + user_id=self.user.slack_user_id, 219 + blocks=message.blocks(), 220 + text=message.text(), 221 + ) 209 222 except AlreadyAttending: 210 - ... 223 + message = AlreadyAttendingMessage() 224 + self.slack.post_message_user( 225 + user_id=self.user.slack_user_id, 226 + blocks=message.blocks(), 227 + text=message.text(), 228 + ) 211 229 return {"response_action": "clear"} 212 230 213 231 def _view_submission_meet_leave(self, view_id: str) -> list | dict: 214 232 """Leaves the plaza.""" 233 + message: BaseMessage 215 234 try: 216 235 delete_attendance(user=self.user, session=self.session) 217 236 message = UserLeftMeetMessage() ··· 221 240 text=message.text(), 222 241 ) 223 242 except NotAttending: 224 - ... 243 + message = NotAttendingMessage() 244 + self.slack.post_message_user( 245 + user_id=self.user.slack_user_id, 246 + blocks=message.blocks(), 247 + text=message.text(), 248 + ) 225 249 return {"response_action": "clear"} 226 250 227 251 def interaction_view_submission(self) -> list | dict:
+27 -3
kefi/routers/messages.py
··· 12 12 from kefi.constants import Actions 13 13 14 14 15 - class BaseMesage: 15 + class BaseMessage: 16 16 def text(self) -> str: 17 17 pass 18 18 ··· 20 20 pass 21 21 22 22 23 - class UserJoinedMeetMessage(BaseMesage): 23 + class UserJoinedMeetMessage(BaseMessage): 24 24 def text(self) -> str: 25 25 return ":tada: ¡Genial! ¡Nos vemos el próximo viernes!" 26 26 ··· 43 43 ] 44 44 45 45 46 - class UserLeftMeetMessage(BaseMesage): 46 + class UserLeftMeetMessage(BaseMessage): 47 47 def text(self) -> str: 48 48 return ":disappointed: ¡Vaya! ¡Esperamos verte la próxima vez!" 49 49 ··· 55 55 ) 56 56 ), 57 57 ] 58 + 59 + 60 + class NotEnoughKefiMessage(BaseMessage): 61 + def text(self) -> str: 62 + return "" 63 + 64 + def blocks(self) -> list[Block]: 65 + return [] 66 + 67 + 68 + class AlreadyAttendingMessage(BaseMessage): 69 + def text(self) -> str: 70 + return "" 71 + 72 + def blocks(self) -> list[Block]: 73 + return [] 74 + 75 + 76 + class NotAttendingMessage(BaseMessage): 77 + def text(self) -> str: 78 + return "" 79 + 80 + def blocks(self) -> list[Block]: 81 + return []