benkio / sBots

Collection of Scala bots based on different characters
1 stars 1 forks source link
bots scala telegram telegram-bot

[[https://actions-badge.atrox.dev/benkio/sBots/goto][file:https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fbenkio%2FsBots%2Fbadge&style=flat]] [[https://scala-steward.org][file:https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=]] [[Cats Friendly Badge][https://typelevel.org/cats/img/cats-badge-tiny.png]]

A repository containing the following bots developed in Scala.

Author: https://t.me/Benkio

** Bots

 | Telegram Bot                     | Character Link |
 | https://t.me/RichardPHJBensonBot | [[https://en.wikipedia.org/wiki/Richard_Benson_(musician)][Richard Philip Henry John Benson]] |
 | https://t.me/YouTuboAncheI0Bot   | [[https://www.youtube.com/channel/UCO66DuFYNFMdR8Y31Ire1fg][Youtubo Anche Io]] |
 | https://t.me/ABarberoBot         | [[https://en.wikipedia.org/wiki/Alessandro_Barbero][Alessandro Barbero]] |
 | https://t.me/M0sconiBot          | [[https://en.wikipedia.org/wiki/Germano_Mosconi][Germano Mosconi]] |
 | https://t.me/XahLeeBot           | [[http://xahlee.info/][Xah Lee]] |
 | https://t.me/CalandroBot         | |

** Required Software

** Add Data to the Bots

 Each bot contains a ~resources~ folder. You need to put in there
 the ~.token~ file containing the telegram key specific to each
 bot.

 Each  bot also uses a ~SQLite~ Database! So you need
 to provide the path to the database into the ~application.conf~
 or just set up the specific environment variables. No need to put
 the files in resources since those will be fetched from the web
 via URLs.

 Check [[https://youtu.be/T-AfAvJLSJE][this video]] for a complete rundown on how to add files to a bot.

** Database Setup

 There's a module called ~botDB~, if opportunely configured,
 when launched, it applies the migrations and populates a bot
 database. Just set up the ~application.conf~ correctly with the DB
 path, see the DB in the root of the project, and the location of
 the ~json~. There should be a ~json~ file at the root of each bot
 module

** Compile and Test

Several command alias are defined in the project to group together useful ~sbt~ commands:

** Run the Bots *** Long Polling Under Windows use the git bash terminal.

+begin_src bash

 ./lunch.sh # I know it's lunch not launch :)

+end_src

* Webhook ** Localhost

 - Export the webhook host, locally using [[https://ngrok.com/][ngrok]], [[https://github.com/beyondcode/expose][expose]] or [[https://github.com/agrinman/tunnelto][tunnelTo]]. example: ~./expose share http://localhost:8080~
 - Change the entry ~WEBHOOK_HOST_URL~ with the name of the host from the previous step or change it in ~~sBots/main/src/main/resources/application.conf~
 - run ~sbt assembly~
 - run ~java -cp main/target/scala-3.3.1/main.jar com.benkio.main.MainWebhook~

**** Docker

  TODO: There's already a ~main/Dockerfile~ with the command to run the webhook, but still it needs to be tested and visible from outside
        Also check [[https://expose.dev/docs/getting-started/installation#as-a-docker-container][expose on docker]]. In order to may make it discoverable from telegram API.

** Continuous Deployment

There should be a pipeline on master, running after the other workflows, that should deploy build, deploy and run the bots remotely on Oracle already. Every new master commit will result in a deployment.

** Deploy on Oracle Cloud Infrastructure VM *** Setup

**** Webhook Extra Configuration

If something doesn't work, please follow [[https://core.telegram.org/bots/webhooks#the-verbose-version][this guide]] and update the documentation accondingly Follow these steps to set up the server property:

*** Deploy