stockholm/krebs/2configs/news.nix

113 lines
3.7 KiB
Nix
Raw Normal View History

2021-01-21 16:58:27 +00:00
{ config, pkgs, ... }:
2017-09-03 22:16:54 +00:00
2017-09-08 22:16:50 +00:00
{
2021-01-08 11:20:29 +00:00
services.rss-bridge = {
enable = true;
whitelist = [ "*" ];
};
2021-01-12 21:21:32 +00:00
services.nginx.virtualHosts = {
rss-bridge = {
serverAliases = [
"rss.r"
];
};
"brockman.r" = {
2021-01-25 17:48:29 +00:00
serverAliases = [
"news.r"
];
2021-01-12 21:21:32 +00:00
locations."/".extraConfig = ''
root /var/lib/brockman;
index brockman.json;
'';
};
2021-01-08 11:20:29 +00:00
};
2021-01-12 21:21:32 +00:00
systemd.tmpfiles.rules = [
"d /var/lib/brockman 1750 brockman nginx -"
];
2021-01-08 11:20:29 +00:00
2020-12-30 10:46:12 +00:00
krebs.brockman = {
enable = true;
config = {
irc.host = "localhost";
2021-01-09 15:18:08 +00:00
channel = "#all";
2020-12-30 10:46:12 +00:00
shortener = "http://go.r";
2021-01-08 11:21:00 +00:00
controller = {
nick = "brockman";
channels = [ "#all" ];
2020-12-30 10:46:12 +00:00
};
2021-01-08 11:21:00 +00:00
bots = {};
2020-12-30 10:46:12 +00:00
};
2017-09-03 22:16:54 +00:00
};
2021-01-21 16:58:27 +00:00
krebs.reaktor2.news = {
hostname = "localhost";
port = "6667";
nick = "brockman-helper";
plugins = [
{
plugin = "register";
config = {
channels = [
"#all"
"#aluhut"
"#news"
];
};
}
{
plugin = "system";
config = {
hooks.PRIVMSG = [
{
activate = "match";
2021-01-26 11:03:24 +00:00
pattern = "^brockman-helper:\\s*(\\S*)(?:\\s+(.*\\S))?\\s*$";
2021-01-21 16:58:27 +00:00
command = 1;
arguments = [2];
commands = {
2021-01-26 11:03:24 +00:00
add-reddit.filename = pkgs.writeDash "add-reddit" ''
set -euf
if [ "$#" -ne 1 ]; then
echo 'usage: brockman-helper: add-reddit $reddit_channel'
exit 1
fi
reddit_channel=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
echo "brockman: add r_$reddit_channel http://rss.r/?action=display&bridge=Telegram&username=$reddit_channel&format=Mrss"
'';
2021-01-21 16:58:27 +00:00
add-telegram.filename = pkgs.writeDash "add-telegram" ''
2021-01-26 11:03:24 +00:00
set -euf
if [ "$#" -ne 1 ]; then
echo 'usage: brockman-helper: add-telegram $telegram_user'
exit 1
fi
telegram_user=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
echo "brockman: add t_$telegram_user http://rss.r/?action=display&bridge=Telegram&username=$telegram_user&format=Mrss"
'';
add-youtube.filename = pkgs.writeDash "add-youtube" ''
set -euf
2021-01-21 16:58:27 +00:00
if [ "$#" -ne 1 ]; then
2021-01-26 11:03:24 +00:00
echo 'usage: brockman-helper: add-youtube $nick $channelid'
2021-01-21 16:58:27 +00:00
exit 1
fi
2021-01-26 11:03:24 +00:00
youtube_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
youtube_id=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][1]')
echo "brockman: add yt_$youtube_nick http://rss.r/?action=display&bridge=Youtube&context=By+channel+id&c=$youtube_id&duration_min=&duration_max=&format=Mrss"
2021-01-21 16:58:27 +00:00
'';
search.filename = pkgs.writeDash "search" ''
2021-01-26 11:03:24 +00:00
set -euf
2021-01-21 16:58:27 +00:00
if [ "$#" -ne 1 ]; then
echo 'usage: brockman-helper: search $searchterm'
exit 1
fi
2021-01-26 11:03:24 +00:00
searchterm=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
${pkgs.curl}/bin/curl -Ss "https://feedsearch.dev/api/v1/search?url=$searchterm&info=true&favicon=false" |
2021-01-21 16:58:27 +00:00
${pkgs.jq}/bin/jq '.[].url'
'';
};
}
];
};
}
];
};
2017-09-03 22:16:54 +00:00
}