Bit more sanitizing strings passed to MegaHAL
[mirrors/libpurple-core-answerscripts.git] / purple / answerscripts.d / 00-megahal.sh
index 940bb3846cf715fbf16a06771cd0e0db821ed620..70cbe323560d04b09e79fcab7751ce6315e90599 100755 (executable)
@@ -1,5 +1,10 @@
 #!/bin/sh
 #Artificial Pseudo Inteligence using megahal package :-)
 #More info: http://megahal.alioth.debian.org/
-#alias cat=true #silent mode, comment out to enable loud replies :-)
-echo -n '[MegaHAL]:' $({ echo "$ANSW_MSG" &&   echo -e '\n#quit\n';    } | megahal -p -b -w | tail -n1) | cat
+
+AI_LOUD=false #enable loud replies (otherwise will be learning only :-)
+AI_LOUD_UNAVAILABLE=true; #enable loud replies when not available :-)
+
+$AI_LOUD_UNAVAILABLE && [ "$ANSW_L_STATUS" != 'available' ] && AI_LOUD=true
+AI_ANSW="$({ echo "$ANSW_MSG." | sed -e 's/#//g' && echo -e '\n#quit\n'; } | timeout 23 megahal -p -b -w | tail -n1)"
+$AI_LOUD && [ -n "$AI_ANSW" ] && echo -n "[MegaHALuz]: $AI_ANSW"
This page took 0.121994 seconds and 4 git commands to generate.