summaryrefslogtreecommitdiffstats
path: root/lass/2configs/reaktor-coders.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lass/2configs/reaktor-coders.nix')
-rw-r--r--lass/2configs/reaktor-coders.nix194
1 files changed, 101 insertions, 93 deletions
diff --git a/lass/2configs/reaktor-coders.nix b/lass/2configs/reaktor-coders.nix
index 7cdcdf20c..44d9d6866 100644
--- a/lass/2configs/reaktor-coders.nix
+++ b/lass/2configs/reaktor-coders.nix
@@ -1,99 +1,107 @@
{ config, lib, pkgs, ... }:
with import <stockholm/lib>;
-{
- krebs.Reaktor.coders = {
- nickname = "Reaktor|lass";
- channels = [ "#coders" "#germany" "#panthermoderns" ];
- extraEnviron = {
- REAKTOR_HOST = "irc.hackint.org";
- };
- plugins = with pkgs.ReaktorPlugins; let
-
- lambdabot = (import (pkgs.fetchFromGitHub {
- owner = "NixOS"; repo = "nixpkgs";
- rev = "a4ec1841da14fc98c5c35cc72242c23bb698d4ac";
- sha256 = "148fpw31s922hxrf28yhrci296f7c7zd81hf0k6zs05rq0i3szgy";
- }) {}).lambdabot;
-
- lambdabotflags = ''
- -XStandaloneDeriving -XGADTs -XFlexibleContexts \
- -XFlexibleInstances -XMultiParamTypeClasses \
- -XOverloadedStrings -XFunctionalDependencies \'';
- in [
- sed-plugin
- url-title
- (buildSimpleReaktorPlugin "lambdabot-pl" {
- pattern = "^@pl (?P<args>.*)$$";
- script = pkgs.writeDash "lambda-pl" ''
- exec ${lambdabot}/bin/lambdabot \
- ${indent lambdabotflags}
- -e "@pl $1"
- '';
- })
- (buildSimpleReaktorPlugin "lambdabot-type" {
- pattern = "^@type (?P<args>.*)$$";
- script = pkgs.writeDash "lambda-type" ''
- exec ${lambdabot}/bin/lambdabot \
- ${indent lambdabotflags}
- -e "@type $1"
- '';
- })
- (buildSimpleReaktorPlugin "lambdabot-let" {
- pattern = "^@let (?P<args>.*)$$";
- script = pkgs.writeDash "lambda-let" ''
- exec ${lambdabot}/bin/lambdabot \
- ${indent lambdabotflags}
- -e "@let $1"
- '';
- })
- (buildSimpleReaktorPlugin "lambdabot-run" {
- pattern = "^@run (?P<args>.*)$$";
- script = pkgs.writeDash "lambda-run" ''
- exec ${lambdabot}/bin/lambdabot \
- ${indent lambdabotflags}
- -e "@run $1"
- '';
- })
- (buildSimpleReaktorPlugin "lambdabot-kind" {
- pattern = "^@kind (?P<args>.*)$$";
- script = pkgs.writeDash "lambda-kind" ''
- exec ${lambdabot}/bin/lambdabot \
- ${indent lambdabotflags}
- -e "@kind $1"
- '';
- })
- (buildSimpleReaktorPlugin "ping" {
- pattern = "^!ping (?P<args>.*)$$";
- script = pkgs.writeDash "ping" ''
- exec /run/wrappers/bin/ping -q -c1 "$1" 2>&1 | tail -1
- '';
- })
- (buildSimpleReaktorPlugin "google" {
- pattern = "^!g (?P<args>.*)$$";
- script = pkgs.writeDash "google" ''
- exec ${pkgs.ddgr}/bin/ddgr -C -n1 --json "$@" | \
- ${pkgs.jq}/bin/jq '@text "\(.[0].abstract) \(.[0].url)"'
- '';
- })
- (buildSimpleReaktorPlugin "blockchain" {
- pattern = ".*[Bb]lockchain.*$$";
- script = pkgs.writeDash "blockchain" ''
- exec echo 'DID SOMEBODY SAY BLOCKCHAIN? https://paste.krebsco.de/r99pMoQq/+inline'
- '';
- })
- (buildSimpleReaktorPlugin "shrug" {
- pattern = "^!shrug$";
- script = pkgs.writeDash "shrug" ''
- exec echo '¯\_(ツ)_/¯'
- '';
- })
- (buildSimpleReaktorPlugin "flip" {
- pattern = "^!flip$";
- script = pkgs.writeDash "shrug" ''
- exec echo '(╯°□°)╯ ┻━┻'
- '';
- })
+let
+ hooks = pkgs.reaktor2-plugins.hooks;
+in {
+ krebs.reaktor2.coders = {
+ hostname = "irc.hackint.org";
+ port = "9999";
+ useTLS = true;
+ nick = "reaktor2|lass";
+ plugins = [
+ {
+ plugin = "register";
+ config = {
+ channels = [
+ "#coders"
+ "#germany"
+ "#panthermoderns"
+ ];
+ };
+ }
+ {
+ plugin = "system";
+ config = {
+ workdir = config.krebs.reaktor2.coders.stateDir;
+ hooks.PRIVMSG = [
+ hooks.sed
+ hooks.url-title
+ {
+ activate = "match";
+ pattern = ''@([^ ]+) (.*)$'';
+ command = 1;
+ arguments = [2];
+ commands = let
+ lambdabot = (import (pkgs.fetchFromGitHub {
+ owner = "NixOS"; repo = "nixpkgs";
+ rev = "a4ec1841da14fc98c5c35cc72242c23bb698d4ac";
+ sha256 = "148fpw31s922hxrf28yhrci296f7c7zd81hf0k6zs05rq0i3szgy";
+ }) {}).lambdabot;
+ lambdabotWrapper = pkgs.writeDash "lambdabot.wrapper" ''
+ exec ${lambdabot}/bin/lambdabot \
+ -XStandaloneDeriving -XGADTs -XFlexibleContexts \
+ -XFlexibleInstances -XMultiParamTypeClasses \
+ -XOverloadedStrings -XFunctionalDependencies \
+ -e "$@"
+ '';
+ in {
+ pl = {
+ env.HOME = config.krebs.reaktor2.coders.stateDir;
+ filename = pkgs.writeDash "lambdabot-pl" ''
+ ${lambdabotWrapper} "@pl $1"
+ '';
+ };
+ type = {
+ env.HOME = config.krebs.reaktor2.coders.stateDir;
+ filename = pkgs.writeDash "lambdabot-type" ''
+ ${lambdabotWrapper} "@type $1"
+ '';
+ };
+ "let" = {
+ env.HOME = config.krebs.reaktor2.coders.stateDir;
+ filename = pkgs.writeDash "lambdabot-let" ''
+ ${lambdabotWrapper} "@let $1"
+ '';
+ };
+ run = {
+ env.HOME = config.krebs.reaktor2.coders.stateDir;
+ filename = pkgs.writeDash "lambdabot-run" ''
+ ${lambdabotWrapper} "@run $1"
+ '';
+ };
+ kind = {
+ env.HOME = config.krebs.reaktor2.coders.stateDir;
+ filename = pkgs.writeDash "lambdabot-kind" ''
+ ${lambdabotWrapper} "@kind $1"
+ '';
+ };
+ };
+ }
+ {
+ activate = "match";
+ pattern = ''!([^ ]+)(?:\s*(.*))?'';
+ command = 1;
+ arguments = [2];
+ commands = {
+ ping.filename = pkgs.writeDash "ping" ''
+ exec /run/wrappers/bin/ping -q -c1 "$1" 2>&1 | tail -1
+ '';
+ google.filename = pkgs.writeDash "google" ''
+ exec ${pkgs.ddgr}/bin/ddgr -C -n1 --json "$@" | \
+ ${pkgs.jq}/bin/jq '@text "\(.[0].abstract) \(.[0].url)"'
+ '';
+ shrug.filename = pkgs.writeDash "shrug" ''
+ exec echo '¯\_(ツ)_/¯'
+ '';
+ table.filename = pkgs.writeDash "table" ''
+ exec echo '(╯°□°)╯ ┻━┻'
+ '';
+ };
+ }
+ ];
+ };
+ }
];
};
}