Tryint to get greets working.
This commit is contained in:
parent
ae2a737d2c
commit
e0da89efaa
20
bot.sh
20
bot.sh
@ -1,8 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
msg()
|
||||||
|
{
|
||||||
|
local msg="PRIVMSG $1:"
|
||||||
|
shift
|
||||||
|
echo "$msg $@" | tee -a "$log"
|
||||||
|
}
|
||||||
|
|
||||||
[ -f bot.properties ] && source bot.properties
|
[ -f bot.properties ] && source bot.properties
|
||||||
input=".bot.cfg"
|
input=".bot.cfg"
|
||||||
echo "Starting session: $(date "+[%y:%m:%d %T]")">$log
|
echo "Starting session: $(date "+[%y:%m:%d %T]")" | tee $log
|
||||||
echo "NICK $nick" > $input
|
echo "NICK $nick" > $input
|
||||||
echo "USER $user" >> $input
|
echo "USER $user" >> $input
|
||||||
for c in ${channel[@]} ; do
|
for c in ${channel[@]} ; do
|
||||||
@ -12,7 +19,7 @@ done
|
|||||||
tail -f $input | telnet $server $port | while read res
|
tail -f $input | telnet $server $port | while read res
|
||||||
do
|
do
|
||||||
# log the session
|
# log the session
|
||||||
echo "$(date "+[%y:%m:%d %T]")$res" >> $log
|
echo "$(date "+[%y:%m:%d %T]")$res" | tee -a $log
|
||||||
# do things when you see output
|
# do things when you see output
|
||||||
case "$res" in
|
case "$res" in
|
||||||
# respond to ping requests from the server
|
# respond to ping requests from the server
|
||||||
@ -24,12 +31,15 @@ do
|
|||||||
echo "JOIN #$channel" >> $input
|
echo "JOIN #$channel" >> $input
|
||||||
;;
|
;;
|
||||||
# run when someone joins
|
# run when someone joins
|
||||||
*JOIN*) who=$(echo "$res" | perl -pe "s/:(.*)\!.*@.*/\1/")
|
*JOIN*)
|
||||||
if [ "$who" = "$nick" ]
|
who=$(echo "$res" | perl -pe "s/:(.*)\!.*@.*/\1/")
|
||||||
then
|
chan="$(echo "$res" | cut -d '#' -f2)"
|
||||||
|
chan="#$chan"
|
||||||
|
if [ "$who" = "$nick" ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "MODE #$channel +o $who" >> $input
|
echo "MODE #$channel +o $who" >> $input
|
||||||
|
[ -e greeting.txt ] && msg $chan $who: $(shuf -n1 greeting.txt)
|
||||||
;;
|
;;
|
||||||
# run when a message is seen
|
# run when a message is seen
|
||||||
*PRIVMSG*)
|
*PRIVMSG*)
|
||||||
|
1
greeting.txt
Normal file
1
greeting.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
welcome to $channel
|
Loading…
x
Reference in New Issue
Block a user