Fix input with backslash and uri grabbing. - 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 a487ecc2b59075400fd82440ac42e5b4250afcef
DIR parent 821f4a797dd7867fe0700edd8f5ae400706ab632
HTML Author: Annna Robert-Houdin <annna@bitreich.org>
Date: Fri, 18 May 2018 20:34:47 +0200
Fix input with backslash and uri grabbing.
Diffstat:
M annna-start-services | 48 ++++++++++++++++----------------
1 file changed, 24 insertions(+), 24 deletions(-)
---
DIR diff --git a/annna-start-services b/annna-start-services
@@ -42,9 +42,9 @@ then
| grep -v --line-buffered '[0-9]* -!- ' \
| sed -u 's,[0-9]* <\([^ >]*\)> \(.*\),\1\n\2,' \
| {
- while read user;
+ while read -r user;
do
- read text
+ read -r text
[ "$user" = "${botname}" ] && continue
@@ -74,9 +74,9 @@ then
| grep -v --line-buffered '[0-9]* -!- ' \
| sed -u 's,[0-9]* <\([^ >]*\)> \(.*\),\1\n\2,' \
| {
- while read user;
+ while read -r user;
do
- read text
+ read -r text
[ "$user" = "${botname}" ] && continue
uri="$(printf "%s\n" "${text}" \
@@ -146,6 +146,26 @@ then
;;
esac
+ if [ "${text}" = "${botname}, I'm bored." ];
+ then
+ randomlink="$(/br/bin/bitreich-lawn-random-link)"
+ linktype="$(printf "%s\n" "${randomlink}" | cut -d '|' -f1 | cut -c2-)"
+ linktext="$(printf "%s\n" "${randomlink}" | cut -d '|' -f2)"
+ linksel="$(printf "%s\n" "${randomlink}" | cut -d '|' -f3)"
+ linkserver="$(printf "%s\n" "${randomlink}" | cut -d '|' -f4)"
+ linkport="$(printf "%s\n" "${randomlink}" | cut -d '|' -f5 | cut -d']' -f1)"
+ outtext="$(printf "%s - gopher://%s" "$linktext" "$linkserver")"
+ if [ "$linkport" != "70" -a "$linkport" != "port" ];
+ then
+ outtext="$(printf "%s:%s" "$outtext" "$linkport")"
+ fi
+ if [ -n "$linksel" ];
+ then
+ outtext="$(printf "%s/%s%s" "$outtext" "$linktype" "$linksel")"
+ fi
+ annna-say -c "#bitreich-en" "$outtext"
+ fi
+
ismember=0
for member in $brmembers;
do
@@ -274,26 +294,6 @@ then
continue;
fi
- if [ "${text}" = "${botname}, I'm bored." ];
- then
- randomlink="$(/br/bin/bitreich-lawn-random-link)"
- linktype="$(printf "%s\n" "${randomlink}" | cut -d '|' -f1 | cut -c2-)"
- linktext="$(printf "%s\n" "${randomlink}" | cut -d '|' -f2)"
- linksel="$(printf "%s\n" "${randomlink}" | cut -d '|' -f3)"
- linkserver="$(printf "%s\n" "${randomlink}" | cut -d '|' -f4)"
- linkport="$(printf "%s\n" "${randomlink}" | cut -d '|' -f5 | cut -d']' -f1)"
- outtext="$(printf "%s - gopher://%s" "$linktext" "$linkserver")"
- if [ "$linkport" != "70" -a "$linkport" != "port" ];
- then
- outtext="$(printf "%s:%s" "$outtext" "$linkport")"
- fi
- if [ -n "$linksel" ];
- then
- outtext="$(printf "%s/%s%s" "$outtext" "$linktype" "$linksel")"
- fi
- annna-say -c "#bitreich-en" "$outtext"
- fi
-
if [ "${text}" = "${botname}, please help." ];
then
# TODO: Add multiple line support to annna-say -c(1) with sleep.