Markinim Telegram bot source code
  • Nim 77.4%
  • Python 20.7%
  • Shell 1.5%
  • Dockerfile 0.4%
Find a file
2024-04-21 21:07:37 +02:00
.vscode GDPR export tool and data removal tool! 2024-04-20 12:29:11 +02:00
backup Backup system updates [test] 2023-08-23 13:55:28 +02:00
data Working with topics. Fixed Docker image cache issues. Recognize anonymous admins. Improved README 2022-11-05 18:46:25 +01:00
src Reply to consent commands 2024-04-16 10:28:32 +02:00
tools Backwards compatibility with older Python versions 2024-04-21 21:07:37 +02:00
.dockerignore Ignore backup/ in dockerignore 2023-09-23 13:47:33 +02:00
.env.sample Added logging flag in .env and secret.ini 2023-03-27 16:05:44 +02:00
.gitignore Change backup scripts names and add them to .gitignore, to ease git pull without git stash 2023-09-23 14:31:47 +02:00
docker-compose.yml Updated docker for Nim 2.0.2 2024-04-01 14:56:26 +02:00
Dockerfile Updated docker for Nim 2.0.2 2024-04-01 14:56:26 +02:00
LICENSE Bot is now open source! Removed useless tooling and cleaned up some code 2022-05-26 18:30:33 +02:00
markinim.nimble Updated norm dependency 2024-04-01 15:22:40 +02:00
README.md Forgot to add 'up' in the instructions 2023-09-23 14:57:37 +02:00

Markinim

This is the @MarkinimBot Telegram bot's source code. It's a bit messy (it was never meant to be open source at the beginning) so it needs a cleanup, but it works. Memory usage and performance are pretty good. It uses sqlite.

Deploy

For docker instructions, skip here

Install required dependencies:

$ nimble install

Then create a secret.ini file which looks like this, where admin is your Telegram user id, and token is the bot token obtainable from @BotFather.

[config]
token = "1234:abcdefg"
admin = 123456
logging = 1

You can also add a keeplast = 1500 parameter to the configuration, to avoid ram overloads by processing a maximum of keeplast messages per session (default: 1500)

$ nim c -o:markinim src/markinim.nim
$ ./markinim

Deploy (with docker)

  • Copy .env.sample to .env
  • Edit BOT_TOKEN and ADMIN_ID
  • If needed, edit KEEP_LAST (default: 1500. Read above)
  • Build and run the image with docker compose up -d --build
  • Run the bot with docker compose up -d

Old instructions

⚠️ WARNING: deprecated. Use the docker compose instructions above instead.

  • Build the image with docker build -t markinim .
  • Run the bot using docker run -itd -v="${pwd}/data":/code/data:z --env-file=.env --restart=unless-stopped --name=markinimbot markinim

Backups

⚠️ WARNING: This is an experimental backup script. It's not well-tested yet. Use it at your own risk. I am not responsible for any data loss. I don't know if it works.

  • Setup syncthing if you want to sync the backups to another device
  • Copy tools/backup_script.example.sh to tools/backup_script.sh and edit it to set the correct values for root_dir, backup_directory and backup_filename
  • Optionally, edit TELEGRAM_ID to receive a notification when the backup is done
  • Copy tools/backup.example.sh to tools/backup.sh and edit it if you want to change the container name
  • Run a cronjob to run tools/backup.sh every 4h (or whatever you want)
    • Open crontab with crontab -e
    • Add 0 */4 * * * /path/to/markinim/tools/backup.sh
    • Save and exit
  • Done! Now you should have a backup every 4h in the specified directory