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

Configure Feed

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

Merge pull request #8 from Dekalabs/feature/messges

feat(messages): update messages

authored by

Marcos Gabarda and committed by
GitHub
441f464c 67ebbdda

+46 -9
+3 -1
kefi/routers/helpers.py
··· 27 27 from kefi.models.plazas.helpers import ( 28 28 create_attendance, 29 29 delete_attendance, 30 + get_or_create_current_plaza, 30 31 is_attending, 31 32 ) 32 33 from kefi.routers.messages import ( ··· 212 213 def _view_submission_meet_join(self, view_id: str) -> list | dict: 213 214 """Joins the plaza.""" 214 215 message: BaseMessage 216 + next_plaza = get_or_create_current_plaza(session=self.session) 215 217 try: 216 218 create_attendance(user=self.user, session=self.session) 217 - message = UserJoinedMeetMessage() 219 + message = UserJoinedMeetMessage(plaza=next_plaza) 218 220 self.slack.post_message_user( 219 221 user_id=self.user.slack_user_id, 220 222 blocks=message.blocks(),
+41 -6
kefi/routers/messages.py
··· 2 2 Block, 3 3 ButtonElement, 4 4 DividerBlock, 5 + ImageElement, 5 6 MarkdownTextObject, 6 7 PlainTextObject, 7 8 SectionBlock, 8 9 ) 9 10 10 11 from kefi.constants import Actions 12 + from kefi.models.database import Plaza 11 13 12 14 13 15 class BaseMessage: ··· 19 21 20 22 21 23 class UserJoinedMeetMessage(BaseMessage): 24 + def __init__(self, plaza: Plaza): 25 + self.plaza = plaza 26 + 22 27 def text(self) -> str: 23 28 return ":tada: ¡Genial! ¡Nos vemos el próximo viernes!" 24 29 25 30 def blocks(self) -> list[Block]: 31 + date = self.plaza.local_date() 32 + 26 33 return [ 27 34 SectionBlock( 28 35 text=MarkdownTextObject( ··· 31 38 ), 32 39 DividerBlock(), 33 40 SectionBlock( 41 + text=MarkdownTextObject( 42 + text=f"*Próximo encuentro*\n{date.strftime('%A, %-d %B')}\n{date.strftime('%H:%M')}\n" 43 + ), 44 + accessory=ImageElement( 45 + image_url="https://storage.staging.dekaside.com/kefi/static/images/kefi_plaza.png", 46 + alt_text="Kefi Plaza imagen", 47 + ), 48 + ), 49 + DividerBlock(), 50 + SectionBlock( 34 51 text=MarkdownTextObject(text="¿Cambio de planes?"), 35 52 accessory=ButtonElement( 36 53 text=PlainTextObject(text="No asistiré"), ··· 57 74 58 75 class NotEnoughKefiMessage(BaseMessage): 59 76 def text(self) -> str: 60 - return "NotEnoughKefiMessage" 77 + return ":money_with_wings: ¡Vaya! No tienes suficientes kefis para apuntarte." 61 78 62 79 def blocks(self) -> list[Block]: 63 - return [SectionBlock(text="NotEnoughKefiMessage")] 80 + return [ 81 + SectionBlock( 82 + text=MarkdownTextObject( 83 + text=":money_with_wings: ¡Vaya! No tienes suficientes kefis para apuntarte." 84 + ) 85 + ) 86 + ] 64 87 65 88 66 89 class AlreadyAttendingMessage(BaseMessage): 67 90 def text(self) -> str: 68 - return "AlreadyAttendingMessage" 91 + return "¡Ei! Estás intentando apuntarte al próximo evento pero ya estas apuntado. ¡Nos vemos el próximo viernes!" 69 92 70 93 def blocks(self) -> list[Block]: 71 - return [SectionBlock(text="AlreadyAttendingMessage")] 94 + return [ 95 + SectionBlock( 96 + text=MarkdownTextObject( 97 + text="¡Ei! Estás intentando apuntarte al próximo evento pero ya estas apuntado. ¡Nos vemos el próximo viernes!" 98 + ) 99 + ) 100 + ] 72 101 73 102 74 103 class NotAttendingMessage(BaseMessage): 75 104 def text(self) -> str: 76 - return "NotAttendingMessage" 105 + return "Has intentado desapuntarte del próximo evento pero ya lo habías hecho antes. ¡Esperamos verte en los próximos eventos!" 77 106 78 107 def blocks(self) -> list[Block]: 79 - return [SectionBlock(text="NotAttendingMessage")] 108 + return [ 109 + SectionBlock( 110 + text=MarkdownTextObject( 111 + text="Has intentado desapuntarte del próximo evento pero ya lo habías hecho antes. ¡Esperamos verte en los próximos eventos!" 112 + ) 113 + ) 114 + ]
+2 -2
kefi/routers/views.py
··· 39 39 text=f"*Próximo encuentro*\n{date.strftime('%A, %-d %B')}\n{date.strftime('%H:%M')}\n" 40 40 ), 41 41 accessory=ImageElement( 42 - image_url="https://api.slack.com/img/blocks/bkb_template_images/notifications.png", 43 - alt_text="calendar thumbnail", 42 + image_url="https://storage.staging.dekaside.com/kefi/static/images/kefi_plaza.png", 43 + alt_text="Kefi Plaza imagen", 44 44 ), 45 45 ), 46 46 ],