Externalized configuration in /etc/redminebot/ file.
This commit is contained in:
parent
404ec1bd46
commit
0bad25ed8c
@ -9,15 +9,26 @@ import xml.dom.minidom
|
||||
from time import mktime, localtime
|
||||
|
||||
import iso8601
|
||||
import ConfigParser
|
||||
|
||||
|
||||
# IRC configuration
|
||||
|
||||
default_server = "irc.eu.freenode.net"
|
||||
default_nickname = "agirbot"
|
||||
# Help configuration.
|
||||
help_list = ["help", "faq", "aide"]
|
||||
hello_list = ["hello", "yo", "bonjour", "salut"]
|
||||
registered = True
|
||||
|
||||
# Load configuration.
|
||||
configurationFilename="/etc/redminebot/redminebot.conf"
|
||||
if os.path.isfile(configurationFilename):
|
||||
config = ConfigParser.RawConfigParser()
|
||||
config.read(configurationFilename)
|
||||
|
||||
default_server=config.get('IRCSection', 'irc.server')
|
||||
default_nickname=config.get('IRCSection', 'irc.nickname');
|
||||
registered=config.get('IRCSection', 'irc.registered');
|
||||
password=config.get('IRCSection', 'irc.password');
|
||||
else:
|
||||
print "Missing configuration file."
|
||||
sys.exit()
|
||||
|
||||
|
||||
#########################
|
||||
### Class Definitions ###
|
||||
@ -72,12 +83,10 @@ class Bot(object):
|
||||
self.ircsock.send("USER {0} {0} {0} :Robot Agir April"
|
||||
".\n".format(self.botnick)) # bot authentication
|
||||
self.ircsock.send("NICK {}\n".format(self.botnick)) # Assign the nick to the bot.
|
||||
if os.path.isfile("password.txt"):
|
||||
with open("password.txt", 'r') as f:
|
||||
password = f.read()
|
||||
if registered == True:
|
||||
print("PRIVMSG {} {} {}".format("NickServ","IDENTIFY",password))
|
||||
self.ircsock.send("PRIVMSG {} :{} {} {}".format("NickServ","IDENTIFY", self.botnick, password))
|
||||
|
||||
if not password.strip() and registered == True:
|
||||
print("PRIVMSG {} {} {}".format("NickServ","IDENTIFY",password))
|
||||
self.ircsock.send("PRIVMSG {} :{} {} {}".format("NickServ","IDENTIFY", self.botnick, password))
|
||||
|
||||
def add_project(self, project):
|
||||
project.set_ircsock ( self.ircsock )
|
||||
|
Loading…
Reference in New Issue
Block a user