Add talk back from annna for TIL - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
DIR commit 9ae0629d20eb0854f1195f93ad27803c1d13750e
DIR parent cb81412efa9ed5137013987f5b676d9f8785917a
HTML Author: Scarlett McAllister <no+reply@roygbyte.com>
Date: Mon, 23 Oct 2023 22:56:00 -0300
Add talk back from annna for TIL
Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
Diffstat:
M annna-message-common | 6 ++++++
A til-user | 40 +++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
---
DIR diff --git a/annna-message-common b/annna-message-common
@@ -1255,6 +1255,12 @@ case "${text}" in
fi
fi
;;
+"${ircuser}, what have I learned?")
+ if result=$(til-user ${user});
+ then
+ annna-say -s "${server}" -c "${channel}" "${user}, ${result}"
+ fi
+ ;;
esac
DIR diff --git a/til-user b/til-user
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+nick="${1}"
+tilmodbase="$HOME/bin/modules/til"
+tilmodbase="." #remove before commit
+tildb="${tilmodbase}/til.txt"
+
+# Make sure there's a file to parse.
+if [ ! -f "${tildb}" ];
+then
+ exit 1
+fi
+
+format_user_tils() {
+ awk -v nick="${nick}" \
+'BEGIN {
+ FS="\t"
+ print nick "\n"
+}
+$1 ~ nick {
+ print $3
+ print "\nTIL" $2 "\n\n"
+}' "${tildb}"
+}
+
+if user_learned_count="$(grep -cP "^${nick}\t" "${tildb}")";
+then
+ results=$(format_user_tils "${nick}" \
+ | fmt -w 69 \
+ | /br/bin/bitreich-paste)
+ printf ", here is all your learning: %s" "${results}"
+ exit 0
+else
+ printf ", you haven't learned anything yet :o"
+ exit 0
+fi
+
+
+
+