summaryrefslogtreecommitdiffstats
path: root/krebs/2configs
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-05-05 01:50:19 +0200
committerlassulus <git@lassul.us>2023-05-05 03:29:27 +0200
commitd39c0b2d18ea48a824b37d58746151b77451e0e8 (patch)
treec9a21cab50ff8e88466b1ec3b40fbba4248fb71e /krebs/2configs
parenta2b03cb28c97be3e9ccd382f7003f128508f1018 (diff)
reaktor2: add bing-img
Diffstat (limited to 'krebs/2configs')
-rw-r--r--krebs/2configs/reaktor2.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index 0a5031415..de1e01a35 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -90,6 +90,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 +408,7 @@ let
bedger-add
bedger-balance
bing
+ bing-img
hooks.sed
interrogate
say