forked from tilderadio/radiobot
add support for nickserv auth
This commit is contained in:
parent
543dd48e01
commit
639c7eece0
|
@ -6,3 +6,4 @@ input.txt
|
|||
subscribers.txt
|
||||
email-subscribers.txt
|
||||
now_playing.txt
|
||||
account.ini
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
account=bensbots
|
||||
password=my super secret password
|
||||
|
21
bot.sh
21
bot.sh
|
@ -3,6 +3,9 @@
|
|||
# read configs
|
||||
. bot.properties
|
||||
|
||||
# not registered and identified
|
||||
reg=""
|
||||
|
||||
printf "starting %s: %s\n" "$nick" "$(date "+[%y:%m:%d %T]")"
|
||||
|
||||
function send {
|
||||
|
@ -75,8 +78,22 @@ do
|
|||
send "$(printf %s "$line" | sed "s/I/O/")"
|
||||
;;
|
||||
|
||||
# log in to services
|
||||
*001*) # RPL_WELCOME
|
||||
if [ -z "$reg" ] && [ -f account.ini ]; then
|
||||
. account.ini
|
||||
send "SQUERY NickServ identify $account $password"
|
||||
fi
|
||||
;;
|
||||
|
||||
# grab account name if authentication successful
|
||||
*900*) # RPL_LOGGEDIN
|
||||
reg=$(printf %s "$line" | sed -E "s/.* (.*) :.*/\1/")
|
||||
printf "successfully logged in as '%s'\n" "$reg"
|
||||
;;
|
||||
|
||||
# make sure we're joined
|
||||
*376*|*404*)
|
||||
*376*) # RPL_ENDOFMOTD
|
||||
for chan in $notify_channels; do
|
||||
send "JOIN #$chan"
|
||||
done
|
||||
|
@ -89,7 +106,7 @@ do
|
|||
|
||||
# "#" would mean it's a channel
|
||||
if printf %s "$from" | grep -q "^#"; then
|
||||
# channel messages need to continue our nick
|
||||
# channel messages need to contain our nick
|
||||
printf %s "$line" | grep -q ":$nick:" || continue
|
||||
trailing=$(printf %s "$line" | sed -E "s/.*:$nick:(.*)/\1/")
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue