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

Configure Feed

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

chore: merge

+159 -33
+3 -3
.travis.yml
··· 2 2 dist: focal 3 3 language: python 4 4 python: 5 - - "3.10.0" 5 + - "3.9" 6 6 env: 7 7 global: 8 8 - PROJECT_NAME=deko ··· 32 32 --password-stdin 33 33 - docker push $IMAGE_ID:latest 34 34 - stage: deploy staging 35 - if: branch = develop 36 35 script: 37 - - curl -X POST $PORTAINER_HOOK 36 + - curl -X POST $PORTAINER_HOOK_DEKO 37 + - curl -X POST $PORTAINER_HOOK_TASKS 38 38
+3 -2
Dockerfile
··· 1 - FROM python:3.10-slim-buster 1 + FROM python:3.9-slim-buster 2 2 3 - RUN apt-get update 3 + RUN apt-get update \ 4 + && apt-get install -y gcc 4 5 5 6 # Installing dependencies using Poetru 6 7 RUN pip install poetry
+9 -23
kefi/routers/commands.py
··· 3 3 from fastapi import APIRouter, Depends 4 4 5 5 from kefi.dependencies import SlashCommandParams 6 - 6 + from kefi.templates import template_command_not_found, template_command_wallet 7 7 router = APIRouter() 8 8 9 9 10 + class Commands: 11 + WALLET: str = "wallet" 12 + 13 + 10 14 @router.post("/command/", tags=["command"]) 11 15 async def handle_command(command: SlashCommandParams = Depends(SlashCommandParams)): 12 - if "wallet" in command.text: 16 + if Commands.WALLET in command.text: 13 17 amount = random.randint(1, 100) 14 - return { 15 - "blocks": [ 16 - { 17 - "type": "header", 18 - "text": { 19 - "type": "plain_text", 20 - "text": f"Cartera de @{command.user_name}", 21 - }, 22 - }, 23 - { 24 - "type": "section", 25 - "fields": [ 26 - { 27 - "type": "mrkdwn", 28 - "text": f"*Pendiente gastar:*\n {amount} dekas", 29 - } 30 - ], 31 - }, 32 - ] 33 - } 34 - return "Comando no reconocido" 18 + return template_command_wallet(command.user_name, amount) 19 + return template_command_not_found() 20 +
kefi/tasks/__init__.py

This is a binary file and will not be displayed.

+11
kefi/tasks/main.py
··· 1 + from arq import cron 2 + from arq.connections import RedisSettings 3 + 4 + 5 + async def dummy_task(ctx): 6 + pass 7 + 8 + 9 + class WorkerSettings: 10 + redis_settings = RedisSettings(host="redis") 11 + cron_jobs = [cron(dummy_task, minute=30)] # type: ignore
+25
kefi/templates.py
··· 1 + from typing import Dict 2 + 3 + 4 + def template_command_wallet(user_name: str, amount: int) -> Dict: 5 + return { 6 + "blocks": [ 7 + { 8 + "type": "header", 9 + "text": {"type": "plain_text", "text": f"Cartera de @{user_name}"}, 10 + }, 11 + { 12 + "type": "section", 13 + "fields": [ 14 + { 15 + "type": "mrkdwn", 16 + "text": f"*Pendiente gastar:*\n {amount} dekas", 17 + } 18 + ], 19 + }, 20 + ] 21 + } 22 + 23 + 24 + def template_command_not_found() -> str: 25 + return "Comando no reconocido"
+107 -5
poetry.lock
··· 1 + [[package]] 2 + name = "aioredis" 3 + version = "1.3.1" 4 + description = "asyncio (PEP 3156) Redis support" 5 + category = "main" 6 + optional = false 7 + python-versions = "*" 8 + 9 + [package.dependencies] 10 + async-timeout = "*" 11 + hiredis = "*" 12 + 1 13 [[package]] 2 14 name = "anyio" 3 15 version = "3.3.4" ··· 22 34 category = "main" 23 35 optional = false 24 36 python-versions = "*" 37 + 38 + [[package]] 39 + name = "arq" 40 + version = "0.22" 41 + description = "Job queues in python with asyncio and redis" 42 + category = "main" 43 + optional = false 44 + python-versions = ">=3.6" 45 + 46 + [package.dependencies] 47 + aioredis = ">=1.1.0,<2.0.0" 48 + click = ">=6.7" 49 + pydantic = ">=1" 50 + 51 + [package.extras] 52 + watch = ["watchgod (>=0.4)"] 25 53 26 54 [[package]] 27 55 name = "asgiref" ··· 48 76 wrapt = ">=1.11,<1.14" 49 77 50 78 [[package]] 79 + name = "async-timeout" 80 + version = "4.0.0" 81 + description = "Timeout context manager for asyncio programs" 82 + category = "main" 83 + optional = false 84 + python-versions = ">=3.6" 85 + 86 + [package.dependencies] 87 + typing-extensions = ">=3.6.5" 88 + 89 + [[package]] 51 90 name = "atomicwrites" 52 91 version = "1.4.0" 53 92 description = "Atomic file writes." ··· 202 241 python-versions = ">=3.6" 203 242 204 243 [[package]] 244 + name = "hiredis" 245 + version = "2.0.0" 246 + description = "Python wrapper for hiredis" 247 + category = "main" 248 + optional = false 249 + python-versions = ">=3.6" 250 + 251 + [[package]] 205 252 name = "idna" 206 253 version = "3.3" 207 254 description = "Internationalized Domain Names in Applications (IDNA)" ··· 425 472 426 473 [[package]] 427 474 name = "py" 428 - version = "1.10.0" 475 + version = "1.11.0" 429 476 description = "library with cross-python path, ini-parsing, io, code, log facilities" 430 477 category = "dev" 431 478 optional = false 432 - python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 479 + python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 433 480 434 481 [[package]] 435 482 name = "pydantic" ··· 740 787 [metadata] 741 788 lock-version = "1.1" 742 789 python-versions = "^3.9" 743 - content-hash = "6207e36971576a6079fe4920d63d2e767ef1b8fce3381fee8c052ceee0113d08" 790 + content-hash = "51457b5e3fdbed641eeaa839d9db35b5d8f196bc7ff673caf6d53f473d790879" 744 791 745 792 [metadata.files] 793 + aioredis = [ 794 + {file = "aioredis-1.3.1-py3-none-any.whl", hash = "sha256:b61808d7e97b7cd5a92ed574937a079c9387fdadd22bfbfa7ad2fd319ecc26e3"}, 795 + {file = "aioredis-1.3.1.tar.gz", hash = "sha256:15f8af30b044c771aee6787e5ec24694c048184c7b9e54c3b60c750a4b93273a"}, 796 + ] 746 797 anyio = [ 747 798 {file = "anyio-3.3.4-py3-none-any.whl", hash = "sha256:4fd09a25ab7fa01d34512b7249e366cd10358cdafc95022c7ff8c8f8a5026d66"}, 748 799 {file = "anyio-3.3.4.tar.gz", hash = "sha256:67da67b5b21f96b9d3d65daa6ea99f5d5282cb09f50eb4456f8fb51dffefc3ff"}, ··· 750 801 appnope = [ 751 802 {file = "appnope-0.1.2-py2.py3-none-any.whl", hash = "sha256:93aa393e9d6c54c5cd570ccadd8edad61ea0c4b9ea7a01409020c9aa019eb442"}, 752 803 {file = "appnope-0.1.2.tar.gz", hash = "sha256:dd83cd4b5b460958838f6eb3000c660b1f9caf2a5b1de4264e941512f603258a"}, 804 + ] 805 + arq = [ 806 + {file = "arq-0.22-py3-none-any.whl", hash = "sha256:55a0f933636c804b82c366a0e3710e9e5ed26a716251fa6742777d0b039f7f30"}, 807 + {file = "arq-0.22.tar.gz", hash = "sha256:c7bd98151cc83cec941ce5f660ede4bee888effd9a4692258ec8a9a0aff2f9f9"}, 753 808 ] 754 809 asgiref = [ 755 810 {file = "asgiref-3.4.1-py3-none-any.whl", hash = "sha256:ffc141aa908e6f175673e7b1b3b7af4fdb0ecb738fc5c8b88f69f055c2415214"}, ··· 758 813 astroid = [ 759 814 {file = "astroid-2.8.4-py3-none-any.whl", hash = "sha256:0755c998e7117078dcb7d0bda621391dd2a85da48052d948c7411ab187325346"}, 760 815 {file = "astroid-2.8.4.tar.gz", hash = "sha256:1e83a69fd51b013ebf5912d26b9338d6643a55fec2f20c787792680610eed4a2"}, 816 + ] 817 + async-timeout = [ 818 + {file = "async-timeout-4.0.0.tar.gz", hash = "sha256:7d87a4e8adba8ededb52e579ce6bc8276985888913620c935094c2276fd83382"}, 819 + {file = "async_timeout-4.0.0-py3-none-any.whl", hash = "sha256:f3303dddf6cafa748a92747ab6c2ecf60e0aeca769aee4c151adfce243a05d9b"}, 761 820 ] 762 821 atomicwrites = [ 763 822 {file = "atomicwrites-1.4.0-py2.py3-none-any.whl", hash = "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197"}, ··· 859 918 {file = "h11-0.12.0-py3-none-any.whl", hash = "sha256:36a3cb8c0a032f56e2da7084577878a035d3b61d104230d4bd49c0c6b555a9c6"}, 860 919 {file = "h11-0.12.0.tar.gz", hash = "sha256:47222cb6067e4a307d535814917cd98fd0a57b6788ce715755fa2b6c28b56042"}, 861 920 ] 921 + hiredis = [ 922 + {file = "hiredis-2.0.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b4c8b0bc5841e578d5fb32a16e0c305359b987b850a06964bd5a62739d688048"}, 923 + {file = "hiredis-2.0.0-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:0adea425b764a08270820531ec2218d0508f8ae15a448568109ffcae050fee26"}, 924 + {file = "hiredis-2.0.0-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:3d55e36715ff06cdc0ab62f9591607c4324297b6b6ce5b58cb9928b3defe30ea"}, 925 + {file = "hiredis-2.0.0-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:5d2a48c80cf5a338d58aae3c16872f4d452345e18350143b3bf7216d33ba7b99"}, 926 + {file = "hiredis-2.0.0-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:240ce6dc19835971f38caf94b5738092cb1e641f8150a9ef9251b7825506cb05"}, 927 + {file = "hiredis-2.0.0-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:5dc7a94bb11096bc4bffd41a3c4f2b958257085c01522aa81140c68b8bf1630a"}, 928 + {file = "hiredis-2.0.0-cp36-cp36m-win32.whl", hash = "sha256:139705ce59d94eef2ceae9fd2ad58710b02aee91e7fa0ccb485665ca0ecbec63"}, 929 + {file = "hiredis-2.0.0-cp36-cp36m-win_amd64.whl", hash = "sha256:c39c46d9e44447181cd502a35aad2bb178dbf1b1f86cf4db639d7b9614f837c6"}, 930 + {file = "hiredis-2.0.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:adf4dd19d8875ac147bf926c727215a0faf21490b22c053db464e0bf0deb0485"}, 931 + {file = "hiredis-2.0.0-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:0f41827028901814c709e744060843c77e78a3aca1e0d6875d2562372fcb405a"}, 932 + {file = "hiredis-2.0.0-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:508999bec4422e646b05c95c598b64bdbef1edf0d2b715450a078ba21b385bcc"}, 933 + {file = "hiredis-2.0.0-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:0d5109337e1db373a892fdcf78eb145ffb6bbd66bb51989ec36117b9f7f9b579"}, 934 + {file = "hiredis-2.0.0-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:04026461eae67fdefa1949b7332e488224eac9e8f2b5c58c98b54d29af22093e"}, 935 + {file = "hiredis-2.0.0-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:a00514362df15af041cc06e97aebabf2895e0a7c42c83c21894be12b84402d79"}, 936 + {file = "hiredis-2.0.0-cp37-cp37m-win32.whl", hash = "sha256:09004096e953d7ebd508cded79f6b21e05dff5d7361771f59269425108e703bc"}, 937 + {file = "hiredis-2.0.0-cp37-cp37m-win_amd64.whl", hash = "sha256:f8196f739092a78e4f6b1b2172679ed3343c39c61a3e9d722ce6fcf1dac2824a"}, 938 + {file = "hiredis-2.0.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:294a6697dfa41a8cba4c365dd3715abc54d29a86a40ec6405d677ca853307cfb"}, 939 + {file = "hiredis-2.0.0-cp38-cp38-manylinux1_i686.whl", hash = "sha256:3dddf681284fe16d047d3ad37415b2e9ccdc6c8986c8062dbe51ab9a358b50a5"}, 940 + {file = "hiredis-2.0.0-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:dcef843f8de4e2ff5e35e96ec2a4abbdf403bd0f732ead127bd27e51f38ac298"}, 941 + {file = "hiredis-2.0.0-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:87c7c10d186f1743a8fd6a971ab6525d60abd5d5d200f31e073cd5e94d7e7a9d"}, 942 + {file = "hiredis-2.0.0-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:7f0055f1809b911ab347a25d786deff5e10e9cf083c3c3fd2dd04e8612e8d9db"}, 943 + {file = "hiredis-2.0.0-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:11d119507bb54e81f375e638225a2c057dda748f2b1deef05c2b1a5d42686048"}, 944 + {file = "hiredis-2.0.0-cp38-cp38-win32.whl", hash = "sha256:7492af15f71f75ee93d2a618ca53fea8be85e7b625e323315169977fae752426"}, 945 + {file = "hiredis-2.0.0-cp38-cp38-win_amd64.whl", hash = "sha256:65d653df249a2f95673976e4e9dd7ce10de61cfc6e64fa7eeaa6891a9559c581"}, 946 + {file = "hiredis-2.0.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ae8427a5e9062ba66fc2c62fb19a72276cf12c780e8db2b0956ea909c48acff5"}, 947 + {file = "hiredis-2.0.0-cp39-cp39-manylinux1_i686.whl", hash = "sha256:3f5f7e3a4ab824e3de1e1700f05ad76ee465f5f11f5db61c4b297ec29e692b2e"}, 948 + {file = "hiredis-2.0.0-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:e3447d9e074abf0e3cd85aef8131e01ab93f9f0e86654db7ac8a3f73c63706ce"}, 949 + {file = "hiredis-2.0.0-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:8b42c0dc927b8d7c0eb59f97e6e34408e53bc489f9f90e66e568f329bff3e443"}, 950 + {file = "hiredis-2.0.0-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:b84f29971f0ad4adaee391c6364e6f780d5aae7e9226d41964b26b49376071d0"}, 951 + {file = "hiredis-2.0.0-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:0b39ec237459922c6544d071cdcf92cbb5bc6685a30e7c6d985d8a3e3a75326e"}, 952 + {file = "hiredis-2.0.0-cp39-cp39-win32.whl", hash = "sha256:a7928283143a401e72a4fad43ecc85b35c27ae699cf5d54d39e1e72d97460e1d"}, 953 + {file = "hiredis-2.0.0-cp39-cp39-win_amd64.whl", hash = "sha256:a4ee8000454ad4486fb9f28b0cab7fa1cd796fc36d639882d0b34109b5b3aec9"}, 954 + {file = "hiredis-2.0.0-pp36-pypy36_pp73-macosx_10_9_x86_64.whl", hash = "sha256:1f03d4dadd595f7a69a75709bc81902673fa31964c75f93af74feac2f134cc54"}, 955 + {file = "hiredis-2.0.0-pp36-pypy36_pp73-manylinux1_x86_64.whl", hash = "sha256:04927a4c651a0e9ec11c68e4427d917e44ff101f761cd3b5bc76f86aaa431d27"}, 956 + {file = "hiredis-2.0.0-pp36-pypy36_pp73-manylinux2010_x86_64.whl", hash = "sha256:a39efc3ade8c1fb27c097fd112baf09d7fd70b8cb10ef1de4da6efbe066d381d"}, 957 + {file = "hiredis-2.0.0-pp36-pypy36_pp73-win32.whl", hash = "sha256:07bbf9bdcb82239f319b1f09e8ef4bdfaec50ed7d7ea51a56438f39193271163"}, 958 + {file = "hiredis-2.0.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:807b3096205c7cec861c8803a6738e33ed86c9aae76cac0e19454245a6bbbc0a"}, 959 + {file = "hiredis-2.0.0-pp37-pypy37_pp73-manylinux1_x86_64.whl", hash = "sha256:1233e303645f468e399ec906b6b48ab7cd8391aae2d08daadbb5cad6ace4bd87"}, 960 + {file = "hiredis-2.0.0-pp37-pypy37_pp73-manylinux2010_x86_64.whl", hash = "sha256:cb2126603091902767d96bcb74093bd8b14982f41809f85c9b96e519c7e1dc41"}, 961 + {file = "hiredis-2.0.0-pp37-pypy37_pp73-win32.whl", hash = "sha256:f52010e0a44e3d8530437e7da38d11fb822acfb0d5b12e9cd5ba655509937ca0"}, 962 + {file = "hiredis-2.0.0.tar.gz", hash = "sha256:81d6d8e39695f2c37954d1011c0480ef7cf444d4e3ae24bc5e89ee5de360139a"}, 963 + ] 862 964 idna = [ 863 965 {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, 864 966 {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, ··· 977 1079 {file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"}, 978 1080 ] 979 1081 py = [ 980 - {file = "py-1.10.0-py2.py3-none-any.whl", hash = "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a"}, 981 - {file = "py-1.10.0.tar.gz", hash = "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3"}, 1082 + {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, 1083 + {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, 982 1084 ] 983 1085 pydantic = [ 984 1086 {file = "pydantic-1.8.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:05ddfd37c1720c392f4e0d43c484217b7521558302e7069ce8d318438d297739"},
+1
pyproject.toml
··· 16 16 python-dotenv = "^0.19.1" 17 17 ipython = "^7.29.0" 18 18 requests = "^2.26.0" 19 + arq = "^0.22" 19 20 20 21 [tool.poetry.dev-dependencies] 21 22 black = "^21.10b0"