Archived
1
0
Fork 0
This repository has been archived on 2025-03-10. You can view files and clone it, but cannot push or open issues or pull requests.
shbot/shbot.sh
Vivia Nikolaidou f5faacf250 Fix nickname and channel detection
* Nicknames were assumed to be in [A-Za-z] format. Just detecting
  a [^!] now as ! separates the nickname from the host.
* Channels may start with two hashes, the previous regexp didn't
  recognize that.
2013-11-05 15:41:52 +02:00

27 lines
469 B
Bash
Executable file

#!/bin/bash
source ./shbirth.sh
exec 3<>/dev/tcp/$SERVER/$PORT
shbirth 1>&3
while true
do
read LINE 0<&3 || break
echo "<-- "$LINE
if [[ "$LINE" =~ PING\ *:(.*) ]]; then
echo "PONG :${BASH_REMATCH[1]}" >&3
else
[[ ${LINE} =~ :[^!]*![^#]*(#.*)\ :.* ]] && ORIGIN=${BASH_REMATCH[1]}
echo "${LINE}" | ./shbrain.sh | \
while true
do
read ANSWER || break
echo "--> "$ANSWER
echo "PRIVMSG $ORIGIN :"$ANSWER >&3 3>&3
done
fi
done
exec 3>&-
exit 0