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

Configure Feed

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

feat: replaced init command by help command

+42 -8
+1 -1
kefi/constants.py
··· 1 1 class Command: 2 - INIT: str = "init" 2 + HELP: str = "help" 3 3 WALLET: str = "wallet" 4 4 KUDOS: str = "kudos" 5 5 CONGRATS: str = "congrats"
+4 -4
kefi/routers/helpers.py
··· 3 3 4 4 from sqlmodel import Session 5 5 6 - from kefi import slack 7 6 from kefi.constants import Command 8 7 from kefi.dependencies import SlashCommandParams 9 8 from kefi.models.helpers import ( ··· 19 18 ) 20 19 from kefi.routers.responses import ( 21 20 ActionResponse, 21 + HelpResponse, 22 22 NotFoundResponse, 23 23 SimpleResponse, 24 24 SlackResponse, ··· 48 48 except IndexError: 49 49 return SimpleResponse("No he entenido el comando").render() 50 50 handlers: Dict[str, Callable] = { 51 - Command.INIT: self.command_init, 51 + Command.HELP: self.command_help, 52 52 Command.WALLET: self.command_wallet, 53 53 Command.KUDOS: self.command_action, 54 54 Command.CONGRATS: self.command_action, ··· 60 60 ).render() 61 61 return response 62 62 63 - def command_init(self, *args, **kwargs) -> SlackResponse: 64 - return SimpleResponse("¡Bienvenido a la comunidad Kefi de Deka!") 63 + def command_help(self, *args, **kwargs) -> SlackResponse: 64 + return HelpResponse() 65 65 66 66 def command_wallet(self, *args, **kwargs) -> SlackResponse: 67 67 remaining_amount = available_balance(user=self.user, session=self.session)
+31
kefi/routers/responses.py
··· 136 136 ) 137 137 ) 138 138 self.response = Response(blocks=[section]) 139 + 140 + 141 + class HelpResponse(SlackResponse): 142 + def __init__(self) -> None: 143 + super().__init__() 144 + first_header = Header(text=PlainText(text="Enviar agradecimientos")) 145 + first_section = Section( 146 + text=MarkDown( 147 + text="¡Es momento de repartir tus Kefis!\n\n*:one: Primer paso:* disponer de suficientes Kefis para " 148 + "enviar el agradecimiento que se desee.\n\n*:two: Segundo paso:* elegir el canal de Slack por " 149 + "donde quieres enviarlo.\n\n*:three: Tercer paso:* elige tipo de agradecimiento, usuario al que " 150 + "le darás los Kefis y escribe un mensaje personalizado que lo acompañe\n\nEl comando que debes " 151 + "colocar en el campo de mensajes de Slack es el siguiente:\n`/kefi [kudos|congrats|highfive] " 152 + "@user [message]`\n\nPresiona intro y tus Kefis se enviarán a tu compañero, que será notificado " 153 + "directamente por Kefi, además de que se publicará un mensaje en el canal donde se realice la " 154 + "acción." 155 + ) 156 + ) 157 + second_header = Header(text=PlainText(text="Consulta de saldo")) 158 + second_section = Section( 159 + text=MarkDown( 160 + text="Podrás consultar tu saldo de Kefis pendientes de gastar así como el acumulado en la hucha de " 161 + "recibidos cuantas veces quieras.\n\nPara hacerlo deberás ingresar en el campo de texto de Slack " 162 + "el comando:\n`/kefi wallet`\n\nEs importante que tengas en cuenta que el saldo pendiente de " 163 + "gastar no será acumulable al siguiente mes, por lo que no los pierdas y aprovecha para enviar " 164 + "tus Kefis." 165 + ) 166 + ) 167 + self.response = Response( 168 + blocks=[first_header, first_section, second_header, second_section] 169 + )
+6 -3
kefi/tests/test_commands.py
··· 27 27 assert response.status_code == 422 28 28 29 29 30 - def test_init_commad(session: Session, client: TestClient): 31 - """Test command /kefi init""" 30 + def test_help_commad(session: Session, client: TestClient): 31 + """Test command /kefi help""" 32 32 33 - response = client.post("/command/", data=generate_command(text="init")) 33 + response = client.post("/command/", data=generate_command(text="help")) 34 34 assert response.status_code == 200 35 35 users = session.exec(select(User)).all() 36 36 assert len(users) == 1 37 + data = response.json() 38 + assert "blocks" in data 39 + assert len(data["blocks"]) == 4 37 40 38 41 39 42 def test_wallet_commad(session: Session, client: TestClient):