bot

module
v0.0.0-...-a82784a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: MPL-2.0

README

* Marrano BOT

A marrano bot

** Usage

#+BEGIN_SRC
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
#+END_SRC

** Options

#+BEGIN_SRC toml
database = "marrano-bot.sqlite"
port = 6446

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

**** 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 [[https://clojure.org/reference/deps_and_cli][clj]] to manage it's dependencies and build process:

#+BEGIN_SRC
go build \
    -tags "sqlite_foreign_keys" \
    -v ./cmd/marrano-bot
#+END_SRC

Or using the makefile

#+BEGIN_SRC
make
#+END_SRC

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

#+BEGIN_SRC
nix build .#default
#+END_SRC

** NixOS flake usage

flake outputs:
#+BEGIN_SRC
├───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'
#+END_SRC

#+BEGIN_SRC nix
{
  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";
  };
}
#+END_SRC

* License

Copyright © 2023 Lorenzo Giuliani

Release under MPL-2.0, see attached [[LICENSE]] file.

Directories

Path Synopsis
cmd
internal
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL