1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/configs/telegram-bots/nachtischsatan.nix

50 lines
1.3 KiB
Nix
Raw Normal View History

2022-03-10 21:52:12 +01:00
{
pkgs,
config,
2022-03-10 21:52:12 +01:00
lib,
...
}: let
nachtischsatan-bot = {tokenFile}:
2020-06-10 17:37:25 +02:00
pkgs.writers.writePython3 "nachtischsatan-bot" {
2022-03-10 21:52:12 +01:00
libraries = [pkgs.python3Packages.python-telegram-bot];
2020-06-10 17:37:25 +02:00
} ''
from telegram.ext import Updater, MessageHandler
from telegram.ext.filters import Filters
import random
import time
def flubber(update, context):
2020-06-10 17:37:25 +02:00
time.sleep(random.randrange(4000) / 1000)
update.message.reply_text("*flubberflubber*")
with open('${tokenFile}', 'r') as tokenFile:
updater = Updater(tokenFile.read().strip())
updater.dispatcher.add_handler(MessageHandler(Filters.all, flubber))
updater.start_polling()
updater.idle()
2020-06-10 17:37:25 +02:00
'';
in {
systemd.services.telegram-nachtischsatan = {
2022-03-10 21:52:12 +01:00
wantedBy = ["multi-user.target"];
description = "*flubberflubber*";
enable = true;
script = toString (nachtischsatan-bot {
tokenFile = config.age.secrets.telegram-token-nachtischsatan.path;
});
serviceConfig.Restart = "always";
};
2022-05-22 11:47:59 +02:00
age.secrets.telegram-token-nachtischsatan.file = ../../secrets/telegram-token-nachtischsatan.age;
2022-05-22 11:47:59 +02:00
niveum.passport.services = [
{
title = "Nachtischsatan-Bot";
link = "https://t.me/NachtischsatanBot";
description = "*flubberflubber*";
}
];
}