summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2022-10-18 21:37:26 +0200
committertv <tv@krebsco.de>2022-10-18 21:38:23 +0200
commitb5f7882fcada26d968b643765f32fd1ac23613ff (patch)
tree876043fe4625f2a88e34d4ea188637dd2b4d995f
parent2dbfd35f759702b53938b5ca4f1cd9a2fb731317 (diff)
reaktor2: give bedger its real name and logo
-rw-r--r--krebs/2configs/reaktor2.nix81
1 files changed, 44 insertions, 37 deletions
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index 233fe2fd7..f76bc6463 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -9,6 +9,48 @@ let
hooks = pkgs.reaktor2-plugins.hooks;
commands = pkgs.reaktor2-plugins.commands;
+ # bedger - the bier ledger
+ #
+ # logo: http://c.r/bedger2
+ #
+ bedger-add = {
+ pattern = ''^([\H-]*?):?\s+([+-][1-9][0-9]*)\s+(\S+)$'';
+ activate = "match";
+ arguments = [1 2 3];
+ command = {
+ env = {
+ # TODO; get state as argument
+ state_file = "${stateDir}/ledger";
+ };
+ filename = pkgs.writeDash "bedger-add" ''
+ set -x
+ tonick=$1
+ amt=$2
+ unit=$3
+ printf '%s\n %s %d %s\n %s %d %s\n' "$(date -Id)" "$tonick" "$amt" "$unit" "$_from" "$(expr 0 - "''${amt#+}")" "$unit" >> $state_file
+ ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
+ | ${pkgs.coreutils}/bin/tail +2 \
+ | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
+ | ${pkgs.gnugrep}/bin/grep "$_from"
+ '';
+ };
+ };
+ bedger-balance = {
+ pattern = "^bier (ballern|bal(an(ce)?)?)$";
+ activate = "match";
+ command = {
+ env = {
+ state_file = "${stateDir}/ledger";
+ };
+ filename = pkgs.writeDash "bedger-balance" ''
+ ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
+ | ${pkgs.coreutils}/bin/tail +2 \
+ | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
+ | ${pkgs.gnused}/bin/sed 's/^\(.\)/\1‍/'
+ '';
+ };
+ };
+
taskRcFile = builtins.toFile "taskrc" ''
confirmation=no
'';
@@ -60,43 +102,8 @@ let
}
];
hooks.PRIVMSG = [
- {
- pattern = "^bier (ballern|bal(an(ce)?)?)$";
- activate = "match";
- command = {
- env = {
- state_file = "${stateDir}/ledger";
- };
- filename = pkgs.writeDash "bier-balance" ''
- ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
- | ${pkgs.coreutils}/bin/tail +2 \
- | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
- | ${pkgs.gnused}/bin/sed 's/^\(.\)/\1‍/'
- '';
- };
- }
- {
- pattern = ''^([\H-]*?):?\s+([+-][1-9][0-9]*)\s+(\S+)$'';
- activate = "match";
- arguments = [1 2 3];
- command = {
- env = {
- # TODO; get state as argument
- state_file = "${stateDir}/ledger";
- };
- filename = pkgs.writeDash "ledger-add" ''
- set -x
- tonick=$1
- amt=$2
- unit=$3
- printf '%s\n %s %d %s\n %s %d %s\n' "$(date -Id)" "$tonick" "$amt" "$unit" "$_from" "$(expr 0 - "''${amt#+}")" "$unit" >> $state_file
- ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
- | ${pkgs.coreutils}/bin/tail +2 \
- | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
- | ${pkgs.gnugrep}/bin/grep "$_from"
- '';
- };
- }
+ bedger-add
+ bedger-balance
hooks.sed
(generators.command_hook {
inherit (commands) dance random-emoji nixos-version;