diff --git a/.gitignore b/.gitignore index 26f8469..5f04328 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ input.txt subscribers.txt email-subscribers.txt now_playing.txt +account.ini diff --git a/account.ini.sample b/account.ini.sample new file mode 100644 index 0000000..f00beb3 --- /dev/null +++ b/account.ini.sample @@ -0,0 +1,3 @@ +account=bensbots +password=my super secret password + diff --git a/bot.sh b/bot.sh index a87a123..6824669 100644 --- a/bot.sh +++ b/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