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

Configure Feed

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

create Base Message

+21 -16
+7 -6
kefi/routers/helpers.py
··· 27 27 delete_attendance, 28 28 is_attending, 29 29 ) 30 - from kefi.routers.messages import UserJoinedMeet, UserLeftMeet 30 + from kefi.routers.messages import UserJoinedMeetMessage, UserLeftMeetMessage 31 31 from kefi.routers.responses import ( 32 32 ActionResponse, 33 33 HelpResponse, ··· 170 170 InteractionType.VIEW_SUBMISSION: self.interaction_view_submission, 171 171 } 172 172 _type = self.payload["type"] 173 - print(self.payload) 174 173 response = handlers.get(_type, self.not_found)() 175 174 return response 176 175 ··· 199 198 """Joins the plaza.""" 200 199 try: 201 200 create_attendance(user=self.user, session=self.session) 201 + message = UserJoinedMeetMessage() 202 202 self.slack.post_message_user( 203 203 user_id=self.user.slack_user_id, 204 - blocks=UserJoinedMeet.blocks(), 205 - text=UserJoinedMeet.text(), 204 + blocks=message.blocks(), 205 + text=message.text(), 206 206 ) 207 207 except NotEnoughKefi: 208 208 ... ··· 214 214 """Leaves the plaza.""" 215 215 try: 216 216 delete_attendance(user=self.user, session=self.session) 217 + message = UserLeftMeetMessage() 217 218 self.slack.post_message_user( 218 219 user_id=self.user.slack_user_id, 219 - blocks=UserLeftMeet.blocks(), 220 - text=UserLeftMeet.text(), 220 + blocks=message.blocks(), 221 + text=message.text(), 221 222 ) 222 223 except NotAttending: 223 224 ...
+14 -10
kefi/routers/messages.py
··· 12 12 from kefi.constants import Actions 13 13 14 14 15 - class UserJoinedMeet: 16 - @staticmethod 17 - def text() -> str: 15 + class BaseMesage: 16 + def text(self) -> str: 17 + pass 18 + 19 + def blocks(self) -> list[Block]: 20 + pass 21 + 22 + 23 + class UserJoinedMeetMessage(BaseMesage): 24 + def text(self) -> str: 18 25 return ":tada: ¡Genial! ¡Nos vemos el próximo viernes!" 19 26 20 - @staticmethod 21 - def blocks() -> list[Block]: 27 + def blocks(self) -> list[Block]: 22 28 return [ 23 29 SectionBlock( 24 30 text=MarkdownTextObject( ··· 37 43 ] 38 44 39 45 40 - class UserLeftMeet: 41 - @staticmethod 42 - def text() -> str: 46 + class UserLeftMeetMessage(BaseMesage): 47 + def text(self) -> str: 43 48 return ":disappointed: ¡Vaya! ¡Esperamos verte la próxima vez!" 44 49 45 - @staticmethod 46 - def blocks() -> list[Block]: 50 + def blocks(self) -> list[Block]: 47 51 return [ 48 52 SectionBlock( 49 53 text=MarkdownTextObject(