summaryrefslogtreecommitdiffstats
path: root/krebs/2configs/reaktor2.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2023-06-03 15:50:01 +0200
committermakefu <github@syntax-fehler.de>2023-06-03 15:50:01 +0200
commit15f4d5f29d3a4b662376f362d21e5b163bd7c5e1 (patch)
tree77b0239c8899207b76fdef85090db7aa2b6e3eea /krebs/2configs/reaktor2.nix
parent563b55fa133a38aacff93747773f026b0681eece (diff)
parent7c3b3400b71678617ac042b522c26e747b8312c2 (diff)
Merge remote-tracking branch 'lassul.us/master'
Diffstat (limited to 'krebs/2configs/reaktor2.nix')
-rw-r--r--krebs/2configs/reaktor2.nix50
1 files changed, 49 insertions, 1 deletions
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index 0a503141..67c2dd4c 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -81,7 +81,8 @@ let
echo "$_from: $(report_error "$response")"
exit 0
fi
- printf '%s' "$text" | echo "$_from: $(cat)"
+ # value seems to be 512 - overhead
+ echo "$_from: $text" | fold -s -w 426
printf '%s' "$response" |
jq -r '[.item.messages[1].sourceAttributions[].seeMoreUrl] | to_entries[] | "[\(.key + 1)]: \(.value)"'
@@ -90,6 +91,52 @@ let
};
};
+ bing-img = {
+ pattern = "!bing-img (.*)$";
+ activate = "match";
+ arguments = [1];
+ timeoutSec = 1337;
+ command = {
+ filename = pkgs.writeDash "bing-img" ''
+ set -efu
+ report_error() {
+ printf '%s' "$*" |
+ curl -Ss http://p.r --data-binary @- |
+ tail -1 |
+ echo "error $(cat)"
+ exit 0
+ }
+ export PATH=${makeBinPath [
+ pkgs.dash
+ pkgs.coreutils
+ pkgs.curl
+ pkgs.findutils
+ pkgs.jq
+ ]}
+ response=$(printf '%s' "$*" |
+ curl -SsG http://bing-gpt.r/api/images --data-urlencode 'prompt@-'
+ )
+ if [ "$?" -ne 0 ]; then
+ report_error "$response"
+ else
+ if ! text=$(
+ printf '%s' "$response" |
+ jq -er '.[].url'
+ ); then
+ echo "$_from: $(report_error "$response")"
+ exit 0
+ fi
+ echo "$text" |
+ xargs -I {} dash -c 'curl -Ss {} |
+ curl -Ss https://p.krebsco.de --data-binary @- |
+ tail -1' |
+ tr '\n' ' ' |
+ echo "$_from: $(cat)"
+ fi
+ '';
+ };
+ };
+
confuse = {
pattern = "!confuse (.*)$";
activate = "match";
@@ -362,6 +409,7 @@ let
bedger-add
bedger-balance
bing
+ bing-img
hooks.sed
interrogate
say