Ejemplo n.º 1
0
def execute(self, name, params, channel, userdata, rank):
    """Commandchain:
        +announce start : append thread to announce
        +announce ignore [id OR name] : ignore certain forum category
        +announce subscribe username : subscribe to replies of (your) account
        +announce help : displays helpfile
        +announce reset : resets the announce-storage
        +announce delete : clears the complete storage
    """
    dbp = DatabaseProcess()
    dbs = DatabaseStorage()
    announcer = Announcer(channel, dbp, dbs)

    if len(params) == 1 and "start" in params:
        if self.threading.checkStatus("forum_announcer_" + channel)[0]:
            self.threading.sigquitThread("forum_announcer_" + channel)
            self.sendNotice(name, "Announcer will be restarted.")
        else:
            self.sendNotice(name, "Announcer started.")
        self.threading.addThread("forum_announcer_" + channel, announcer_process, [self, announcer, channel])
        return


    if len(params) >= 1 and "ignore" in params:
        if params > 1:
            ignore = announcer.add_ignored_category(str(params[1]))
            self.sendNotice(name, 'Ignoring from now on this category: ' + dbp.categories[ignore])
        else:
            self.sendNotice(name, "Invalid use of commandchain.")

    if len(params) == 1 and "reset" in params:
        # @TODO: Change timeframe back on deploy
        threads = dbp.get_latest_threads(timeframe=1000)
        for line in threads:
            dbs.write_DiscussionID(line['threadID'], channel)

    if len(params) == 1 and "delete" in params:
        announcer.delete_storage()

    if len(params) == 1 and "help" in params:
        self.sendNotice(name, "This is the Moddota Forum Announcer, usage as following:")
        self.sendNotice(name, self.cmdprefix + "announce start : append thread to announce")
        self.sendNotice(name, self.cmdprefix + "announce ignore [id OR name] : ignore certain forum category")
        self.sendNotice(name, self.cmdprefix + "announce subscribe username : subscribe to replies of (your) account")
        self.sendNotice(name, self.cmdprefix + "announce help : displays this helpfile")
        self.sendNotice(name, self.cmdprefix + "announce reset : resets the announce-storage")
        self.sendNotice(name, self.cmdprefix + "announce delete : clears the complete storage")
        self.sendNotice(name, self.cmdprefix + "announce info : prints out status of channel")
Ejemplo n.º 2
0
def execute(self, name, params, channel, userdata, rank):
    """Commandchain:
        +announce start : append thread to announce
        +announce ignore [id OR name] : ignore certain forum category
        +announce subscribe username : subscribe to replies of (your) account
        +announce help : displays helpfile
        +announce reset : resets the announce-storage
        +announce delete : clears the complete storage
    """
    dbp = DatabaseProcess()
    dbs = DatabaseStorage()
    announcer = Announcer(channel, dbp, dbs)

    if len(params) == 1 and "start" in params:
        if self.threading.checkStatus("forum_announcer_" + channel)[0]:
            self.threading.sigquitThread("forum_announcer_" + channel)
            self.sendNotice(name, "Announcer will be restarted.")
        else:
            self.sendNotice(name, "Announcer started.")
        self.threading.addThread("forum_announcer_" + channel,
                                 announcer_process, [self, announcer, channel])
        return

    if len(params) >= 1 and "ignore" in params:
        if params > 1:
            ignore = announcer.add_ignored_category(str(params[1]))
            self.sendNotice(
                name, 'Ignoring from now on this category: ' +
                dbp.categories[ignore])
        else:
            self.sendNotice(name, "Invalid use of commandchain.")

    if len(params) == 1 and "reset" in params:
        # @TODO: Change timeframe back on deploy
        threads = dbp.get_latest_threads(timeframe=1000)
        for line in threads:
            dbs.write_DiscussionID(line['threadID'], channel)

    if len(params) == 1 and "delete" in params:
        announcer.delete_storage()

    if len(params) == 1 and "help" in params:
        self.sendNotice(
            name, "This is the Moddota Forum Announcer, usage as following:")
        self.sendNotice(
            name,
            self.cmdprefix + "announce start : append thread to announce")
        self.sendNotice(
            name, self.cmdprefix +
            "announce ignore [id OR name] : ignore certain forum category")
        self.sendNotice(
            name, self.cmdprefix +
            "announce subscribe username : subscribe to replies of (your) account"
        )
        self.sendNotice(
            name, self.cmdprefix + "announce help : displays this helpfile")
        self.sendNotice(
            name,
            self.cmdprefix + "announce reset : resets the announce-storage")
        self.sendNotice(
            name,
            self.cmdprefix + "announce delete : clears the complete storage")
        self.sendNotice(
            name,
            self.cmdprefix + "announce info : prints out status of channel")
Ejemplo n.º 3
0
    if len(params) == 1 and "reset" in params:
        # @TODO: Change timeframe back on deploy
        threads = dbp.get_latest_threads(timeframe=1000)
        for line in threads:
            dbs.write_DiscussionID(line['threadID'], channel)

    if len(params) == 1 and "delete" in params:
        announcer.delete_storage()

    if len(params) == 1 and "help" in params:
        self.sendNotice(name, "This is the Moddota Forum Announcer, usage as following:")
        self.sendNotice(name, self.cmdprefix + "announce start : append thread to announce")
        self.sendNotice(name, self.cmdprefix + "announce ignore [id OR name] : ignore certain forum category")
        self.sendNotice(name, self.cmdprefix + "announce subscribe username : subscribe to replies of (your) account")
        self.sendNotice(name, self.cmdprefix + "announce help : displays this helpfile")
        self.sendNotice(name, self.cmdprefix + "announce reset : resets the announce-storage")
        self.sendNotice(name, self.cmdprefix + "announce delete : clears the complete storage")
        self.sendNotice(name, self.cmdprefix + "announce info : prints out status of channel")


if __name__ == '__main__':
    # announcer_process('self', 'pipe', '#dota2mods')
    dbp = DatabaseProcess()
    dbs = DatabaseStorage()
    a = Announcer('#dota2mods', dbp, dbs)
    print a.add_ignored_category('Tutorials')
    print dbp.categories[2]
#    threads = dbp.get_latest_threads(timeframe=1000)
#    for line in threads:
#        print line
#        dbs.write_DiscussionID(line['threadID'], '#dota2mods')
Ejemplo n.º 4
0
        self.sendNotice(
            name, self.cmdprefix +
            "announce ignore [id OR name] : ignore certain forum category")
        self.sendNotice(
            name, self.cmdprefix +
            "announce subscribe username : subscribe to replies of (your) account"
        )
        self.sendNotice(
            name, self.cmdprefix + "announce help : displays this helpfile")
        self.sendNotice(
            name,
            self.cmdprefix + "announce reset : resets the announce-storage")
        self.sendNotice(
            name,
            self.cmdprefix + "announce delete : clears the complete storage")
        self.sendNotice(
            name,
            self.cmdprefix + "announce info : prints out status of channel")


if __name__ == '__main__':
    # announcer_process('self', 'pipe', '#dota2mods')
    dbp = DatabaseProcess()
    dbs = DatabaseStorage()
    a = Announcer('#dota2mods', dbp, dbs)
    print a.add_ignored_category('Tutorials')
    print dbp.categories[2]
#    threads = dbp.get_latest_threads(timeframe=1000)
#    for line in threads:
#        print line
#        dbs.write_DiscussionID(line['threadID'], '#dota2mods')