about summary refs log tree commit diff
path: root/ops/modules/teleirc.nix
blob: 9f9ac059ce380fc69fc2990890638d0a5513238f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Run the Telegram<>IRC sync bot for the Volga Sprint channel.
#
# This module is written in a pretty ad-hoc style, as it is sort of a
# throwaway thing (will be removed again after the event).
{ depot, config, lib, pkgs, ... }:

let
  cfg = config.services.depot.owothia;
  description = "IRC<>Telegram sync for Volga Sprint channel";
  configFile = builtins.toFile "teleirc.env" ''
    # connect through tvlbot's ZNC bouncer
    IRC_SERVER="localhost"
    IRC_PORT=2627
    IRC_USE_SSL=false
    IRC_CHANNEL="#volgasprint"
    IRC_BLACKLIST="tvlbot"
    IRC_BOT_NAME="tvlbot"
    IRC_BOT_REALNAME="TVL bot for Volga Sprint"
    IRC_BOT_IDENT="tvlbot"
    IRC_SEND_STICKER_EMOJI=false # look into this
    TELEGRAM_CHAT_ID=-1002153072030
  '';
in
{
  options.services.depot.teleirc.enable = lib.mkEnableOption description;

  config = lib.mkIf cfg.enable {
    systemd.services.teleirc = {
      inherit description;
      wantedBy = [ "multi-user.target" ];

      serviceConfig = {
        DynamicUser = true;
        Restart = "always";
        EnvironmentFile = "/run/agenix/teleirc";
        ExecStart = "${depot.third_party.teleirc}/bin/teleirc -conf ${configFile}";
      };
    };
  };
}