1
0
mirror of https://github.com/kmein/niveum synced 2026-03-20 12:01:06 +01:00
Files
niveum/configs/bots/nachtischsatan.nix

49 lines
1.4 KiB
Nix
Raw Normal View History

2022-03-10 21:52:12 +01:00
{
pkgs,
config,
lib,
2022-03-10 21:52:12 +01:00
...
}: 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
} ''
2023-06-07 10:27:02 +02:00
from telegram.ext import Application, ContextTypes, MessageHandler, filters
from telegram import Update
import random
import time
2023-06-07 10:27:02 +02:00
async def flubber(update: Update, context: ContextTypes.DEFAULT_TYPE):
2020-06-10 17:37:25 +02:00
time.sleep(random.randrange(4000) / 1000)
2023-06-07 10:27:02 +02:00
await update.message.reply_text("*flubberflubber*")
with open('${tokenFile}', 'r') as tokenFile:
2023-06-07 10:27:02 +02:00
token = tokenFile.read().strip()
application = Application.builder().token(token).build()
application.add_handler(MessageHandler(filters.ALL, flubber))
application.run_polling()
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*";
}
];
}