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 show give kudos modal

+56 -1
+4
kefi/constants.py
··· 16 16 class ViewType: 17 17 JOIN_MEET: str = "meet_join" 18 18 LEAVE_MEET: str = "meet_leave" 19 + GIVE_KUDOS: str = "give_kudos" 19 20 20 21 21 22 class Actions: 22 23 LEAVE_MEET: str = "meet_leave" 23 24 SHOW_MEETS_MODAL: str = "show_meets_modal" 25 + SHOW_GIVE_KUDOS_MODAL: str = "show_give_kudos_modal" 26 + USER_SELECT: str = "user_select" 27 + PLAIN_TEXT_INPUT: str = "plain_text_input" 24 28 25 29 26 30 class EventBodyType:
+8 -1
kefi/routers/helpers.py
··· 46 46 SlackResponse, 47 47 WalletResponse, 48 48 ) 49 - from kefi.routers.views import HomeView, JoinMeetView, LeaveMeetView 49 + from kefi.routers.views import GiveKudosView, HomeView, JoinMeetView, LeaveMeetView 50 50 from kefi.slack import Slack 51 51 52 52 ··· 288 288 handlers: dict[str, Callable] = { 289 289 Actions.LEAVE_MEET: self.action_leave_meet, 290 290 Actions.SHOW_MEETS_MODAL: self.action_show_meets_modal, 291 + Actions.SHOW_GIVE_KUDOS_MODAL: self.action_show_give_kudos_modal, 291 292 } 292 293 handlers.get(action["action_id"], self.not_found)() 293 294 ··· 323 324 self.slack.open_view( 324 325 trigger_id=trigger_id, view=LeaveMeetView(session=self.session) 325 326 ) 327 + 328 + def action_show_give_kudos_modal(self): 329 + trigger_id = self.payload["trigger_id"] 330 + self.slack.open_view( 331 + trigger_id=trigger_id, view=GiveKudosView(session=self.session) 332 + ) 326 333 327 334 328 335 class EventHandler:
+44
kefi/routers/views.py
··· 5 5 DividerBlock, 6 6 HeaderBlock, 7 7 ImageElement, 8 + InputBlock, 8 9 MarkdownTextObject, 10 + PlainTextInputElement, 9 11 PlainTextObject, 10 12 SectionBlock, 13 + UserSelectElement, 11 14 ) 12 15 from slack_sdk.models.views import View 13 16 ··· 127 130 alt_text="Congrats", 128 131 ), 129 132 ), 133 + ActionsBlock( 134 + elements=[ 135 + ButtonElement( 136 + text=PlainTextObject(text="Kefi Enhorabuena"), 137 + action_id=Actions.SHOW_GIVE_KUDOS_MODAL, 138 + ) 139 + ] 140 + ), 130 141 ContextBlock( 131 142 elements=[PlainTextObject(text="/kefi congrats @user [mensaje]")] 132 143 ), ··· 182 193 ContextBlock(elements=[PlainTextObject(text="/kefi help")]), 183 194 ], 184 195 ) 196 + 197 + 198 + class GiveKudosView(View): 199 + def __init__(self, *args, **kwargs): 200 + session = kwargs.get("session") 201 + 202 + super().__init__( 203 + callback_id=ViewType.GIVE_KUDOS, 204 + type="modal", 205 + title=PlainTextObject(text="¡Gracias!"), 206 + close=PlainTextObject(text="Cancelar"), 207 + submit=PlainTextObject(text="Enviar Kefis"), 208 + blocks=[ 209 + SectionBlock( 210 + text=MarkdownTextObject(text="¿A quien quieres felicitar?"), 211 + accessory=UserSelectElement( 212 + placeholder=PlainTextObject(text="Selecciona un usuario"), 213 + action_id=Actions.USER_SELECT, 214 + ), 215 + ), 216 + InputBlock( 217 + element=PlainTextInputElement( 218 + multiline=True, action_id=Actions.PLAIN_TEXT_INPUT 219 + ), 220 + label="Déjale un mensaje", 221 + ), 222 + ContextBlock( 223 + elements=[ 224 + PlainTextObject(text=f"Valor: {settings.KUDOS_PRICE} Kefis") 225 + ] 226 + ), 227 + ], 228 + )