squad-rotation-bot
db_data
.idea
+database/seed.sql
This is a bot that you can integrate into your gchat spaces to send a message
to indicate who's turn is it to facilitate the daily.
-
-## Configuring
-
-Make sure to configure the following according to your needs:
-
-- **The time at which to run the bot** is configured in `scripts/crontab`.
- Follow the indications in that file.
-- **Set the webhook URL** by setting the `WEB_HOOK_URL` environment variable to
- the value of the gchat webhook URL. You can generate this in the integrations
- settings tab of your gchat space.
-- **Optionally configure the database connection details** by setting the
- environment variables used in the compose file
-
-## Usage
-
-### With docker-compose
-
-1. Clone this repository:
-
-```shell
-git clone https://gitlab.com/latamairlines/lyca/eloyalty/loyalty-program-management/mktplace/mkpl/squad-rotation-bot
-cd squad-rotation-bot
-```
-
-2. Run the services:
-
-```shell
-export WEB_HOOK_URL='...'
-docker compose up -d
-```
-
-## Managing squad members
-
-You basically have 3 options for managing squad members.
-
-### 1. Edit the `databse/seed.sql` file
-
-You can edit the database seeding script to add or remove squad members.
-
-You will need to restart the database server from scratch after doing this.
-
-### 2. Exec into the Postgres container
-
-You can also exec into the running Postgres container to use `psql` to `INSERT` the
-squad members:
-
-```shell
-docker compose exec db psql -U postgres
-```
-
-That command will start a `psql` console where you can issue your database commands.
-
-Make sure to replace `postgres` by whatever value you've configured as the
-database user, if any. `postgres` is the default one.
-
-## License
-MIT
+++ /dev/null
-FROM ubuntu:22.04
-
-WORKDIR /app
-
-RUN apt-get update && apt-get install curl gnupg jq -y
-
-RUN mkdir -p /etc/apt/keyrings && \
- curl -fsSL https://repo.charm.sh/apt/gpg.key | gpg --dearmor -o /etc/apt/keyrings/charm.gpg && \
- echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | tee /etc/apt/sources.list.d/charm.list && \
- apt update && apt install gum
-
-COPY ./cli.sh /app/cli.sh
-
-CMD /app/cli.sh
+++ /dev/null
-#!/bin/bash
-
-API_BASE='http://localhost:3000'
-
-list_members() {
- local members=`curl "$API_BASE/api/v1/rotation/members" 2>/dev/null | jq '.[] | .FullName + "," + .AvatarUrl' | tr -d '"'`
- echo "$members" | gum table --columns="Name,Avatar" --separator="," --print
-}
-
-create_member() {
- gum style \
- --foreground "#00e0ee" \
- --padding '1 1' \
- --bold \
- "Add a squad member"
-
- local full_name=`gum input --placeholder 'Full name' --padding '1 1'`
- local avatar_url=`gum input --placeholder 'Avatar URL' --padding '1 1'`
-
- gum style \
- --foreground "#00e0ee" \
- --padding "1 1" \
- "The squad member '$full_name' is going to be created with avatar: '$avatar_url'"
-
- if gum confirm 'Proceed with creation?'; then
- local result=`curl -X POST -i -s "$API_BASE/api/v1/rotation/members" -d "{ \"FullName\": \"$full_name\", \"AvatarUrl\": \"$avatar_url\" }"`
- local status_code=`echo $result | head -n1 | cut -d' ' -f2`
- if [ "$status_code" = '201' ]; then
- gum style --foreground "#00ff00" --bold --padding "1 1" "User created successfully"
- else
- gum style --foreground "#ff0000" --bold --padding "1 1" "There was an error creating the user"
- fi
- else
- gum style --foreground "#ff0000" --bold --padding "1 1" 'Operation aborted'
- fi
-}
-
-read -r -d '' menu_options <<'EOF'
-1. List squad members
-2. Add squad member
-3. Exit
-EOF
-
-while :; do
- choice=`echo "$menu_options" | gum choose --header "Menu Options" --padding "1 1" --header.bold | cut -d'.' -f1`
- case $choice in
- 1)
- list_members
- ;;
- 2)
- create_member
- ;;
- 3)
- exit 0
- ;;
- esac
-done
+++ /dev/null
-insert into squad_members (full_name, avatar_url)
-values
- ('Kevem Almeida', 'https://lh3.googleusercontent.com/a-/ALV-UjUKnKQmphIYbkiek6ihwValS-iQFnQkxNg8V1Xy4UpFMpEKaHI=s88-w88-h88-c-k-no'),
- ('Adriano Russo', 'https://lh3.googleusercontent.com/a-/ALV-UjULrrlD0iJUVcCzXLmXvdwYorbjcleq2o8SsRCz5IDss4UuUo2J=s88-w88-h88-c-k-no'),
- ('Alexander Goussas', 'https://lh3.googleusercontent.com/a/ACg8ocIUq16oEi0pCdfYhrb1UgdUz4QjIeER1qoHABJ17j88DeyNQxlP=s88-w88-h88-c-k-no'),
- ('Beatriz Proenca', 'https://lh3.googleusercontent.com/a-/ALV-UjWg-gfYqindLufkyGfXxFq8HxehVfv5gPiWRbSnW7ed0B43XN4=s88-w88-h88-c-k-no'),
- ('Bianca Beppler', 'https://lh3.googleusercontent.com/a-/ALV-UjWR6sfgLE51gK2Ss49a-uq_M6CjcYV0WU_8JW7YMtdD-XJm_Nc=s88-w88-h88-c-k-no'),
- ('Carla Lima', 'https://lh3.googleusercontent.com/a-/ALV-UjWY0YUkviICDoCGSxszS4_ZyBlhQNkFMp4FAhuYjPBgqB2gvmE=s88-w88-h88-c-k-no'),
- ('Hugo Lima', 'https://lh3.googleusercontent.com/a/ACg8ocJSa8JM5kfMIEud5nXNlORlymxIBxi-Plnde8vwbW968Up3Rw=s88-w88-h88-c-k-no'),
- ('Ignacio Cisternas', 'https://lh3.googleusercontent.com/a-/ALV-UjVjXZgbziPVal1wM9mClDFQ3mBPQiMHUG0zE9BsNbOUTCEmLYbo=s88-w88-h88-c-k-no'),
- ('Katerina DeAraujo', 'https://lh3.googleusercontent.com/a-/ALV-UjUpmHDk6zVJIMFPipi5TzlbSP6ZsQyXb_OkgSXr7zIDiqD4jyU=s88-w88-h88-c-k-no'),
- ('Lucca Arie Dias', 'https://lh3.googleusercontent.com/a-/ALV-UjX5jU6XlwQpf6Q7TBTGHLvU_iRZjif1C3Dm28wGRPlUUgruqzo=s88-w88-h88-c-k-no'),
- ('Lucinara Fernandes', 'https://lh3.googleusercontent.com/a-/ALV-UjUZdqnyNF8GgdnMUVPhNM8I1YydNcymPRaPOTRGEE0VlPa42LA=s88-w88-h88-c-k-no'),
- ('Raimundo Oyarce', 'https://lh3.googleusercontent.com/a-/ALV-UjUioVhwJuBTbfT_hdfjzkKDMhyV7FZGOeKhkmsszDcz9K0Xp0E=s88-w88-h88-c-k-no'),
- ('Viviane Martins', 'https://lh3.googleusercontent.com/a-/ALV-UjUNkw8JNMm7yP-8c9IiqXb9_YO8GRovXyIZUCgtEAgyx7yAnqY=s88-w88-h88-c-k-no');