Fixes register logic so we only need password.txt when register set to True

This commit is contained in:
Shauna 2015-03-14 16:54:36 -04:00
parent 971c13cc25
commit b148c9a1e6
1 changed files with 20 additions and 21 deletions

15
bot.py
View File

@ -1,7 +1,7 @@
# Welcome to WelcomeBot. Find source, documentation, etc here: https://github.com/shaunagm/WelcomeBot/ Licensed https://creativecommons.org/licenses/by-sa/2.0/
# Import some necessary libraries.
import socket, sys, time, csv, Queue, random, re, pdb, select
import socket, sys, time, csv, Queue, random, re, pdb, select, os.path
from threading import Thread
# Some basic variables used to configure the bot.
@ -12,7 +12,7 @@ channel_greeters = ['shauna', 'paulproteus', 'marktraceur']
wait_time = 60
hello_list = [r'hello', r'hi', r'hey', r'yo', r'sup']
help_list = [r'help', r'info', r'faq', r'explain yourself']
registered = true # If users don't want to identify, change the value to false.
registered = False # If users don't want to identify, change the value to false.
#########################
@ -72,10 +72,11 @@ def join_irc(ircsock):
ircsock.send("USER {0} {0} {0} :This is http://openhatch.org/'s greeter bot"
".\n".format(botnick)) # bot authentication
ircsock.send("NICK {}\n".format(botnick)) # Assign the nick to the bot.
with open("password.txt", 'r') as f:
password = f.read()
if registered == true:
ircsock.send("PRIVMSG {} {} {} {}".format("NickServ","IDENTIFY", botnick, password))
if os.path.isfile("password.txt"):
with open("password.txt", 'r') as f:
password = f.read()
if registered == True:
ircsock.send("PRIVMSG {} {} {} {}".format("NickServ","IDENTIFY", botnick, password))
ircsock.send("JOIN {} \n".format(channel)) # Joins channel
# Reads the messages from the server and adds them to the Queue and prints
@ -245,5 +246,3 @@ def main():
if __name__ == "__main__": # This line tells the interpreter to only execute main() if the program is being run, not imported.
sys.exit(main())