mirror of https://github.com/nealey/irc-bot
Add FIFO
This commit is contained in:
parent
ecb62e614e
commit
6a272b0b86
4
bot
4
bot
|
@ -9,4 +9,6 @@ nickname=$1; export nickname
|
||||||
echo "USER $1 $1 $1 :I'm a little printf, short and stdout."
|
echo "USER $1 $1 $1 :I'm a little printf, short and stdout."
|
||||||
)
|
)
|
||||||
|
|
||||||
exec ./dispatch ./irc ./$1-handler
|
mkfifo -m 0600 $1.fifo
|
||||||
|
|
||||||
|
exec ./dispatch -f $1.fifo ./irc ./$1-handler
|
||||||
|
|
|
@ -19,6 +19,8 @@ join () {
|
||||||
raw "JOIN $1"
|
raw "JOIN $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out=$(tempfile)
|
||||||
|
|
||||||
case $command in
|
case $command in
|
||||||
001)
|
001)
|
||||||
for chan in ${CHANNELS:-#cobalt}; do
|
for chan in ${CHANNELS:-#cobalt}; do
|
||||||
|
@ -42,7 +44,14 @@ case $command in
|
||||||
join "$forum"
|
join "$forum"
|
||||||
raw "PRIVMSG %s :Thanks for the invitation, %s." "$forum" "$sender"
|
raw "PRIVMSG %s :Thanks for the invitation, %s." "$forum" "$sender"
|
||||||
;;
|
;;
|
||||||
esac | while read -r line; do
|
esac > $out
|
||||||
|
|
||||||
|
if [ "$forum" != "$sender" ] && [ $(wc -l < $out) -gt 5 ]; then
|
||||||
|
printf "PRIVMSG %s :Too many lines, sending privately.\r\n" "$forum"
|
||||||
|
forum=$sender
|
||||||
|
fi
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
case "$line" in
|
case "$line" in
|
||||||
*)
|
*)
|
||||||
printf "%s\r\n" "${line#}"
|
printf "%s\r\n" "${line#}"
|
||||||
|
@ -51,5 +60,7 @@ esac | while read -r line; do
|
||||||
printf "PRIVMSG %s :%s\r\n" "$forum" "$line"
|
printf "PRIVMSG %s :%s\r\n" "$forum" "$line"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done < $out
|
||||||
|
|
||||||
|
rm -f $out
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue