All Projects → armand1m → gringobot

armand1m / gringobot

Licence: other
Bot with utilities for the Telegram Group Programando na Gringa (https://go.d1m.dev/png)

Programming Languages

typescript
32286 projects

gringobot

Bot with utilities for the Telegram Group Programando na Gringa

This bot offer features that make the management of a large international group easier. We use it to add common questions and features that make the experience of our members more delightful.

All content is managed in markdown and is requested over the network through Github API's, so we don't have to redeploy the bot to have updated content.

The bot allows members to register the country they're located, so when questions about specific places come up, they can just use the bot to find those folks through a simple command like /whoat NL and ping them if needed with /ping NL

This bot is available in Telegram as @PNGGringoBot and it works in multiple groups. Keep in mind that the admins of Programando na Gringa own this instance as a community effort and manage the data accordingly. Feel free to reach out if you have any questions.

Features

The bot currently replies in Portuguese by default, and parses names of countries in Portuguese only. This will change in the future.

  • Register member location:
    • English: /register_member_at NL, /imat NL
    • Portuguese: /estou NL, /estou Holanda
  • Find folks from a location:
    • English: /find_members_at NL, /whoat NL
    • Portuguese: /quem NL, /quem Holanda
  • Ping folks from a location:
    • English: /ping_members_at NL, /ping NL
    • Portuguese: /alo NL, /alo Holanda
  • Deregister member location:
    • English: /leave NL
    • Portuguese: /sair NL, /sair Holanda
  • Find member registered locations:
    • English: /find_member, /whereami
    • Portuguese: /ondeestou
  • List Member count per Country:
    • English: /list_country_member_count, /list
    • Portuguese: /quantos
    • Include remote members when listing
  • Rank countries by number of members
    • English: /rank_country_member_count, /rank
    • Portuguese: /classificacao
    • Include remote members when ranking
  • Register as Remote Member:
    • English: /register_remote_member <from> <to>
    • Portuguese: /estou_remoto <from> <to>
  • Deregister as Remote Member:
    • English: /deregister_remote_member
    • Portuguese: /sair_remoto
  • Find remote member working from a location:
    • English: /find_remote_member_from BR
    • Portuguese: /quem_remoto_do BR
  • Find remote member working for a location:
    • English: /find_remote_member_to CA
    • Portuguese: /quem_remoto_para CA
  • Help Sections:
    • English: /help <subject> <topic>
    • Portuguese: /ajuda <assunto> <topico>
  • Ping all admins:
    • /ping_admins, /admins, /eita
  • Self preservation habilities
    • Handle deleted registered users and deregister those when identified
  • Message Auto Deletion:
    • Configurable through the MESSAGE_TIMEOUT_IN_MINUTES environment variable. Default is 2.
    • Feature can be toggled through the MESSAGE_TIMEOUT_ENABLED environment variable. Default is true.
    • Deletes both command and reply messages after timeout is reached.
    • Deletes all interactions that were replied with error messages.
    • Deletes messages from the following commands:
      • /leave
      • /find_member
      • /register_member_at
      • /register_remote_member
      • /deregister_remote_member
      • /find_members_at (only if no members are found)
      • /ping_members_at (only if no members are found)
      • /list_country_member_count (only if no members are registered)
      • /rank_country_member_count (only if no members are registered)

Developing

Make sure you have Git, Node and Yarn available in your local environment.

# clone repository
git clone https://github.com/armand1m/gringobot.git

# cd into it
cd ./gringobot

# install dependencies
yarn

You must have a Telegram Bot Token created by the Bot Father. Once you have that, run the following command with your bot token:

cat > ./.env <<EOL
NODE_ENV=development
BOT_TOKEN=your-bot-token-here
DATA_PATH=./data
LOCALES_PATH=./locales
MESSAGE_TIMEOUT_ENABLED=true
MESSAGE_TIMEOUT_IN_MINUTES=2
EOL

Now run yarn dev and your bot should be working. Changes will restart the process.

Deploying

Host

Follow the same configuration step for development, but run the following to start the process:

yarn build
node ./build/index.js

You probably want to use a process manager like systemd or PM2.

Docker

This bot is published publicly as a Docker Image, so you should be able to run it anywhere you can run a Docker Container.

To run it locally, just run the following:

docker run -e BOT_TOKEN="your-bot-token-here" armand1m/gringobot

Kubernetes

Kubernetes manifests are available at the ./kubernetes folder.

Create a secret named gringobot-secret with the bot_token:

kubectl create secret generic gringobot-secrets \
    --from-literal=bot_token='<token-goes-here>'

Then apply the manifest:

kubectl apply -f ./kubernetes/deployment.yml

You might have to adjust the PersistentVolumeClaim if you're not using a CSI driver.

Credits

Credits goes to all the maintainers and participants of the Programando na Gringa group.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].