Exemplo n.º 1
0
    def __init__(self):
        self.conf = config.get_bot_config()
        irc.Bot.__init__(self, self.conf.get('bot', 'nick'))
        self.timeout = int(self.conf.get('bot', 'ping_timeout'))

        self.addMessageHandler(Message.MESSAGE, DbgLordNikon.handlePrivMsg)
        self.addMessageHandler(Message.JOIN, DbgLordNikon.handlePrivMsg)
        self.addMessageHandler("376", DbgLordNikon.handleConnected)
        self.addMessageHandler(Message.NOTICE, DbgLordNikon.handleNotice)
        self.connect(self.conf.get('bot', 'server'),
                     int(self.conf.get('bot', 'port')))

        self.cmdHandler = cmds.getHandler()
        self.queue = comm.getHandler()
        self.listeners = listeners.getHandler()

        self.sendAuth()
Exemplo n.º 2
0
        self._cursor.execute('SELECT user_id FROM users WHERE nick = ?;',
                             [msg.nick])
        uid = self._cursor.fetchone()[0]
        self._cursor.execute(
            'SELECT channel_id FROM channels WHERE channel = ?;',
            [msg.channel])
        cid = self._cursor.fetchone()[0]

        self._cursor.execute("INSERT INTO lines VALUES (?,?,?,?,?)", (
            None,
            text,
            datetime.now(),
            cid,
            uid,
        ))

        self._connection.commit()

    def execute(self, msg):
        if msg.channel != None:  # jsut feck
            if not self.has_table('lines'):
                pass
            self.insert_line(msg)


listeners.getHandler().add(LoggerListener())

if __name__ == "__main__":
    l = LoggerListener()
Exemplo n.º 3
0
        listeners.SelfJoinListener.__init__(self, "firstlastselfjoin")

    def execute(self, msg):
        global firsts, lasts
        msg.reply_channel("Went down for a while...do")
        if msg.channel in firsts:
            # we do not have the nick yet
            msg.reply_channel("We had a first...")
        else:
            msg.reply_channel("The first is free")

        if msg.channel in lasts.keys():
            msg.reply_channel("lasts:" +
                              ",".join([x.nick for x in lasts[msg.channel]]))
        else:
            msg.reply_channel("no lasts for today")


listeners.getHandler().add(LastListener())
listeners.getHandler().add(MidnightRunListener())
listeners.getHandler().add(FirstListener())
listeners.getHandler().add(FirstLastJoinListener())
cmds.getHandler().add("highscore", high_score)
cmds.getHandler().add("score", my_score)

create_tables()
load_first_lasts()

if __name__ == '__main__':
    getHighScore('#dbglordnikon')
Exemplo n.º 4
0
class TitleListener(listeners.RegexListener):
    def __init__(self):
        listeners.RegexListener.__init__(
            self, "title", "http.?:([^\s]+)\.([a-z]{1,3})(\/?[^\s]+)")
        self.sendTo = comm.getHandler().sendTo
        self.send = comm.getHandler().sendRaw

    def execute(self, msg):
        global AUTOTITLE
        if msg.channel in autotitles:
            if not autotitles[msg.channel]:
                return

        if "localhost" in msg.line or "127.0" in msg.line:
            return

        for arg in msg.args:
            match = self.regex.match(arg)
            if match:
                u = match.group(0)
                try:
                    r = get_title(u)
                    if AUTOTITLE and r:
                        msg.reply_channel("title: " + r)

                except Exception as e:
                    print(e)


listeners.getHandler().add(TitleListener())