diff options
Diffstat (limited to 'krebs/2configs')
-rw-r--r-- | krebs/2configs/news.nix | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/krebs/2configs/news.nix b/krebs/2configs/news.nix index ce4e83408..410beb041 100644 --- a/krebs/2configs/news.nix +++ b/krebs/2configs/news.nix @@ -19,12 +19,46 @@ root /var/lib/brockman; index brockman.json; ''; + extraConfig = '' + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + ''; }; }; systemd.tmpfiles.rules = [ "d /var/lib/brockman 1750 brockman nginx -" ]; + 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"; krebs.brockman = { enable = true; config = { @@ -53,6 +87,7 @@ "#all" "#aluhut" "#news" + "#lasstube" ]; }; } @@ -87,13 +122,36 @@ add-youtube.filename = pkgs.writeDash "add-youtube" '' set -euf if [ "$#" -ne 1 ]; then - echo 'usage: ${name}: add-youtube $nick $channelid' + echo 'usage: ${name}: add-youtube $nick $channel/video/stream/id' exit 1 fi 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]') + 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 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" ''; + 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" + ''; search.filename = pkgs.writeDash "search" '' set -euf if [ "$#" -ne 1 ]; then |