Introduction
Introduction Statistics Contact Development Disclaimer Help
Add new dictcurl script. - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit f1861dec786ba6af58ab4d9db17c63d388d65a60
parent 1c9816b1574f11d4be5e92a7475acc79ca160d17
Author: Annna Robert-Houdin <[email protected]>
Date: Wed, 3 Jan 2024 21:10:35 +0100
Add new dictcurl script.
Thanks eidolon for the hint!
Diffstat:
M annna-message-common | 43 ++++++++++++-----------------…
A dictcurl | 22 ++++++++++++++++++++++
2 files changed, 38 insertions(+), 27 deletions(-)
---
diff --git a/annna-message-common b/annna-message-common
@@ -308,7 +308,7 @@ case "${text}" in
"${ircuser}, how can I phlog on bitreich?")
annna-say -s "${server}" -c "${channel}" "${user}, please read: gopher…
;;
-"${ircuser}, what is my type?")
+"${ircuser}, what's my type?")
{
cd /br/gopher
usertype="$(find memecache/type-?.png -type f \
@@ -325,36 +325,25 @@ case "${text}" in
;;
esac
+ dictserver="dict.org"
case "${word}" in
- "love")
- puri="$(clippy-say "Baby don't hurt me no more!")"
+ dict.org*)
+ dictserver="dict.org"
+ word="$(printf "%s\n" "${word}" | cut -c 9-)"
;;
- "my future")
- puri="$(clippy-say "Did you mean _what's my horoscope?_?")"
+ parazy.de*)
+ dictserver="parazy.de"
+ word="$(printf "%s\n" "${word}" | cut -c 10-)"
;;
- "my horoscope")
- puri="$(clippy-say "Did you mean _what's my future?_?")"
- ;;
- "up")
- puri="$(clippy-say "Did you mean _what's up?_?")"
- ;;
- *)
- puri=""
- dresult="$(printf '%s\n' "define * $word" QUIT | nc parazyd.or…
-
- if printf '%s\n' "$dresult" | grep -q '^150'
- then
- n="$(printf '%s\n' "$dresult" | grep -c '^151')"
- nmessage="$n definition(s) found."
- paste="$(printf '%s\n' "$dresult" | /br/bin/bitreich-p…
- puri="$nmessage $paste"
- elif printf '%s\n' "$dresult" | grep -q '^552'
- then
- puri="No match found."
- else
- puri="Server destroyed. Nothing to see here."
- fi
esac
+
+ dresult="$(dictcurl "${dictserver}" "" "${word}")"
+ if [ -z "${dresult}" ];
+ then
+ puri="No match found."
+ else
+ puri="$(printf "%s\n" "${dresult}" | /br/bin/bitreich-paste)"
+ fi
annna-say -s "${server}" -c "${channel}" "${puri}"
;;
"${ircuser}, cowsay "*)
diff --git a/dictcurl b/dictcurl
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $# -lt 3 ];
+then
+ printf "usage: %s server[:port] db query\n" "$(basename "$0")" >&2
+ exit 1
+fi
+
+server="${1}"
+db="${2}"
+query="${3:?}"
+
+curl -s "dict://${server}/d:${query}${db:+:$db}" \
+| awk '/^552 / {
+ print "No match for word." > "/dev/stderr"
+ exit 1
+ }
+ /^151 /,/^\./ {
+ sub(/^151 |^\./, "")
+ print
+ }
+'
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.