news: let candyman react to his name

This commit is contained in:
lassulus 2021-02-10 15:50:28 +01:00
parent 8b10ef8cf4
commit bd7f002fef

View File

@ -39,10 +39,12 @@
}; };
}; };
krebs.reaktor2.news = { krebs.reaktor2.news = let
name = "candyman";
in {
hostname = "localhost"; hostname = "localhost";
port = "6667"; port = "6667";
nick = "candyman"; nick = name;
plugins = [ plugins = [
{ {
plugin = "register"; plugin = "register";
@ -60,14 +62,14 @@
hooks.PRIVMSG = [ hooks.PRIVMSG = [
{ {
activate = "match"; activate = "match";
pattern = "^brockman-helper:\\s*(\\S*)(?:\\s+(.*\\S))?\\s*$"; pattern = "^${name}:\\s*(\\S*)(?:\\s+(.*\\S))?\\s*$";
command = 1; command = 1;
arguments = [2]; arguments = [2];
commands = { commands = {
add-reddit.filename = pkgs.writeDash "add-reddit" '' add-reddit.filename = pkgs.writeDash "add-reddit" ''
set -euf set -euf
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo 'usage: brockman-helper: add-reddit $reddit_channel' echo 'usage: ${name}: add-reddit $reddit_channel'
exit 1 exit 1
fi fi
reddit_channel=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') reddit_channel=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
@ -76,7 +78,7 @@
add-telegram.filename = pkgs.writeDash "add-telegram" '' add-telegram.filename = pkgs.writeDash "add-telegram" ''
set -euf set -euf
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo 'usage: brockman-helper: add-telegram $telegram_user' echo 'usage: ${name}: add-telegram $telegram_user'
exit 1 exit 1
fi fi
telegram_user=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') telegram_user=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
@ -85,7 +87,7 @@
add-youtube.filename = pkgs.writeDash "add-youtube" '' add-youtube.filename = pkgs.writeDash "add-youtube" ''
set -euf set -euf
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo 'usage: brockman-helper: add-youtube $nick $channelid' echo 'usage: ${name}: add-youtube $nick $channelid'
exit 1 exit 1
fi fi
youtube_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') youtube_nick=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')
@ -95,7 +97,7 @@
search.filename = pkgs.writeDash "search" '' search.filename = pkgs.writeDash "search" ''
set -euf set -euf
if [ "$#" -ne 1 ]; then if [ "$#" -ne 1 ]; then
echo 'usage: brockman-helper: search $searchterm' echo 'usage: ${name}: search $searchterm'
exit 1 exit 1
fi fi
searchterm=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]') searchterm=$(echo "$1" | ${pkgs.jq}/bin/jq -Rr '[match("(\\S+)\\s*";"g").captures[].string][0]')