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-03-26 19:06:56 +00:00
|
|
|
locations."/api".extraConfig = ''
|
|
|
|
proxy_pass http://127.0.0.1:7777/;
|
|
|
|
proxy_pass_header Server;
|
|
|
|
'';
|
|
|
|
locations."= /graph.html".extraConfig = ''
|
|
|
|
alias ${pkgs.fetchurl {
|
|
|
|
url = "https://raw.githubusercontent.com/kmein/brockman/05d33c8caaaf6255752f9600981974bb58390851/tools/graph.html";
|
|
|
|
sha256 = "0iw2vdzj6kzkix1c447ybmc953lns6z4ap6sr9pcib8bany4g43w";
|
|
|
|
}};
|
|
|
|
'';
|
2021-01-12 21:21:32 +00:00
|
|
|
locations."/".extraConfig = ''
|
|
|
|
root /var/lib/brockman;
|
|
|
|
index brockman.json;
|
|
|
|
'';
|
2021-02-23 22:41:38 +00:00
|
|
|
extraConfig = ''
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
|
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
|
|
|
'';
|
2021-01-12 21:21:32 +00:00
|
|
|
};
|
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-03-26 19:06:56 +00:00
|
|
|
"d /run/irc-api 1750 brockman nginx -"
|
2021-01-12 21:21:32 +00:00
|
|
|
];
|
2021-01-08 11:20:29 +00:00
|
|
|
|
2021-02-23 22:42:12 +00:00
|
|
|
systemd.services.brockman-graph = {
|
|
|
|
path = [
|
|
|
|
pkgs.graphviz
|
|
|
|
pkgs.jq
|
|
|
|
pkgs.inotifyTools
|
|
|
|
];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = pkgs.writers.writeDash "brockman-graph" ''
|
|
|
|
|
|
|
|
while :; do
|
|
|
|
graphviz="$(cat /var/lib/brockman/brockman.json \
|
|
|
|
| jq -r '
|
|
|
|
.bots |
|
|
|
|
to_entries |
|
|
|
|
map(select(.value.extraChannels|length > 1 )) |
|
|
|
|
.[] |
|
|
|
|
"\"\(.key)\" -> {\(.value.extraChannels|map("\""+.+"\"")|join(" "))}"
|
|
|
|
')"
|
|
|
|
echo "digraph news { $graphviz }" | circo -Tsvg > /var/lib/brockman/graph.svg
|
|
|
|
|
|
|
|
inotifywait -q -e MODIFY /var/lib/brockman/brockman.json
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
User = "brockman";
|
|
|
|
};
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.brockman.serviceConfig.LimitNOFILE = 16384;
|
|
|
|
systemd.services.brockman.environment.BROCKMAN_LOG_LEVEL = "DEBUG";
|
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";
|
2021-03-26 19:06:56 +00:00
|
|
|
extraChannels = [ "#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
|
|
|
|
2021-03-26 19:06:56 +00:00
|
|
|
krebs.reaktor2.api = {
|
|
|
|
hostname = "localhost";
|
|
|
|
port = "6667";
|
|
|
|
nick = "api";
|
|
|
|
API.listen = "inet://127.0.0.1:7777";
|
|
|
|
plugins = [
|
|
|
|
{
|
|
|
|
plugin = "register";
|
|
|
|
config = {
|
|
|
|
channels = [
|
|
|
|
"#all"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-02-10 14:50:28 +00:00
|
|
|
krebs.reaktor2.news = let
|
|
|
|
name = "candyman";
|
|
|
|
in {
|
2021-01-21 16:58:27 +00:00
|
|
|
hostname = "localhost";
|
|
|
|
port = "6667";
|
2021-02-10 14:50:28 +00:00
|
|
|
nick = name;
|
2021-01-21 16:58:27 +00:00
|
|
|
plugins = [
|
|
|
|
{
|
|
|
|
plugin = "register";
|
|
|
|
config = {
|
|
|
|
channels = [
|
|
|
|
"#all"
|
|
|
|
"#aluhut"
|
|
|
|
"#news"
|
2021-02-23 22:42:12 +00:00
|
|
|
"#lasstube"
|
2021-01-21 16:58:27 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
plugin = "system";
|
|
|
|
config = {
|
|
|
|
hooks.PRIVMSG = [
|
|
|
|
{
|
|
|
|
activate = "match";
|
2021-02-10 14:50:28 +00:00
|
|
|
pattern = "^${name}:\\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
|
2021-02-10 14:50:28 +00:00
|
|
|
echo 'usage: ${name}: add-reddit $reddit_channel'
|
2021-01-26 11:03:24 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
reddit_channel=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
|
2021-01-26 16:48:55 +00:00
|
|
|
echo "brockman: add r_$reddit_channel http://rss.r/?action=display&bridge=Reddit&context=single&r=$reddit_channel&format=Atom"
|
2021-01-26 11:03:24 +00:00
|
|
|
'';
|
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
|
2021-02-10 14:50:28 +00:00
|
|
|
echo 'usage: ${name}: add-telegram $telegram_user'
|
2021-01-26 11:03:24 +00:00
|
|
|
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-02-23 22:42:33 +00:00
|
|
|
echo 'usage: ${name}: add-youtube $nick $channel/video/stream/id'
|
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]')
|
2021-02-23 22:42:33 +00:00
|
|
|
youtube_url=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][1]')
|
|
|
|
if [ ''${#youtube_url} -eq 24 ]; then
|
|
|
|
youtube_id=$youtube_url
|
|
|
|
else
|
|
|
|
youtube_id=$(${pkgs.youtube-dl}/bin/youtube-dl --max-downloads 1 -j "$youtube_url" | ${pkgs.jq}/bin/jq -r '.channel_id')
|
|
|
|
fi
|
2021-01-26 11:03:24 +00:00
|
|
|
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
|
|
|
'';
|
2021-02-23 22:42:33 +00:00
|
|
|
add-twitch.filename = pkgs.writeDash "add-twitch" ''
|
|
|
|
set -euf
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
echo 'usage: ${name}: add-twitch $handle'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
twitch_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
|
|
|
|
echo "brockman: add twitch_$twitch_nick http://rss.r/?action=display&bridge=Twitch&channel=$twitch_nick&type=all&format=Atom"
|
|
|
|
'';
|
|
|
|
add-twitter.filename = pkgs.writeDash "add-twitter" ''
|
|
|
|
set -euf
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
|
|
echo 'usage: ${name}: add-twitter $handle'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
twitter_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
|
|
|
|
echo "brockman: add tw_$twitter_nick http://rss.r/?action=display&bridge=Twitch&channel=$twitter_nick&type=all&format=Atom"
|
|
|
|
'';
|
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
|
2021-02-10 14:50:28 +00:00
|
|
|
echo 'usage: ${name}: search $searchterm'
|
2021-01-21 16:58:27 +00:00
|
|
|
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
|
|
|
}
|