Skip to content

moolite/bot

Repository files navigation

Marrano BOT

A marrano bot

Usage

2024/01/10 17:19:18 INFO starting marrano-bot version=0.10.0
Usage of ./marrano-bot:
  -c, --config string       bot configuration path (default "./marrano-bot.toml")
  -D, --dump                dump configuration object
  -E, --export              export database data as csv (defaults to stdout)
      --export-dir string   folder to write database exported data csv files
  -h, --help                this message
  -I, --init                initialize the database
  -v, --verbose             set verbose output

Options

database = "marrano-bot.sqlite"
port = 6446

[telegram]
name = "marrano-bot"
token = "123456789-bot"
domain = "bot.marrani.lol"

config.toml

  • database the database filename
  • port port to listen to (the web server listens to loopback, hardcoded)
  • telegram.name colloquial name of the bot, update only when updating the subscription
  • telegram.token telegram bot token secret
  • telegram.domain domain name to register for webhooks

envars

  • DATABASE envar can be used to override the config option database
  • TELEGRAM_TOKEN envar can be used to override the config option telegram.token

Building

This project is using clj to manage it’s dependencies and build process:

go build \
    -tags "sqlite_foreign_keys" \
    -v ./cmd/marrano-bot

Or using the makefile

make

Or building the nix derivation producing ./results/bin/marrano-bot

nix build .#default

NixOS flake usage

flake outputs:

├───checks
│   ├───aarch64-linux
│   │   ├───editorconfig: derivation 'check-editorconfig'
│   │   ├───formatting: derivation 'check-formatting'
│   │   └───packages-default: derivation 'marrano-bot'
│   └───x86_64-linux
│       ├───editorconfig: derivation 'check-editorconfig'
│       ├───formatting: derivation 'check-formatting'
│       └───packages-default: derivation 'marrano-bot'
├───devShells
│   ├───aarch64-linux
│   │   └───default: development environment 'nix-shell'
│   └───x86_64-linux
│       └───default: development environment 'nix-shell'
├───formatter
│   ├───aarch64-linux: package 'formatter'
│   └───x86_64-linux: package 'formatter'
├───nixosModules
│   └───default: NixOS module
├───overlays
│   └───default: Nixpkgs overlay
└───packages
    ├───aarch64-linux
    │   └───default: package 'marrano-bot'
    └───x86_64-linux
        └───default: package 'marrano-bot'
{
  description = "my flake";

  outputs = { nixpkgs, marrano-bot, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        overlays = [
        ];
      };
    in
      {
        nixosConfigurations.my-machine = pkgs.lib.nixosSystem {
          inherit system;
          modules = [
            inputs.ragenix.nixosModules.default
            inputs.marrano-bot.nixosModules.default
            ./configuration.nix
          ];

          age.secrets.marrano-bot.file = ./secrets/marrano-bot.age;
          services.marrano-bot = {
            enable = true;
            hostName = "bot.example-bot-farm.lol";
            logLevel = "debug";
          };
        };
      };

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
    ragenix.url = "github:yaxitech/ragenix";
    ragenix.inputs.nixpkgs.follows = "nixpkgs";
    marrano-bot.url = "github:moolite/bot";
    marrano-bot.inputs.nixpkgs.follows = "nixpkgs";
  };
}

License

Copyright © 2023 Lorenzo Giuliani

Release under MPL-2.0, see attached LICENSE file.