add support for nickserv auth

This commit is contained in:
Ben Harris 2020-06-17 15:31:24 -04:00
parent 543dd48e01
commit 639c7eece0
3 changed files with 23 additions and 2 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ input.txt
subscribers.txt
email-subscribers.txt
now_playing.txt
account.ini

3
account.ini.sample Normal file
View File

@ -0,0 +1,3 @@
account=bensbots
password=my super secret password

21
bot.sh
View File

@ -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