import time import irc.bot class IrcBot(irc.bot.SingleServerIRCBot): def __init__(self, settings): self.settings = settings self.server = self.settings.IRC_SERVER self.port = self.settings.IRC_PORT self.channel = self.settings.IRC_CHANNEL self.nickname = self.settings.IRC_NICK self.password = self.settings.IRC_PASSWORD # Starting Bot irc.bot.SingleServerIRCBot.__init__( self, [(self.server, self.port)], self.nickname, self.nickname ) def on_nicknameinuse(self, connection, event): # TODO: Check again if name is available later self.nickname = self.nickname + "_" connection.nick(self.nickname) def on_welcome(self, connection, event): connection.join(self.channel) def send(self, target, message): self.connection.privmsg(target, message) def send_multiple(self, target, messages): for message in messages: self.send(target, message) time.sleep(self.settings.IRC_DELAY)