コード例 #1
0
ファイル: sleekbot.py プロジェクト: cakebread/SleekBot
 def die(self):
     """ Kills the bot.
     """
     PlugBot.stop(self)
     CommandBot.stop(self)
     self.rooms = {}
     logging.info("Disconnecting bot")
     self.disconnect()
コード例 #2
0
ファイル: sleekbot.py プロジェクト: cakebread/SleekBot
 def __init__(self, config_file, ssl=False, plugin_config = {}):
     """ Initializes the bot
             config_file -- string pointing to an xml configuration file
     """
     self.config_file = config_file
     self.botconfig = self.load_config(config_file)
     auth = self.botconfig.find('auth')
     logging.info("Logging in as %s" % auth.attrib['jid'])
     sleekxmpp.ClientXMPP.__init__(self, auth.attrib['jid'], auth.attrib['pass'], auth.get('ssl', True), plugin_config)
     storageXml = self.botconfig.find('storage')
     if storageXml is not None:
         self.store = store(storageXml.attrib['file'])
     else:
         logging.warning("No storage element found in config file - proceeding with no persistent storage, plugin behaviour may be undefined.")
     self.rooms = {}
     self.add_event_handler("session_start", self.handle_session_start, threaded=True)
     self.register_xmpp_plugins()
     CommandBot.__init__(self)
     PlugBot.__init__(self, default_package = 'sleekbot.plugins')
     self.register_adhocs()
コード例 #3
0
ファイル: sleekbot.py プロジェクト: cakebread/SleekBot
    def rehash(self):
        """ Re-reads the config file, making appropriate runtime changes.
            Causes all plugins to be reloaded (or unloaded).
            The XMPP stream and MUC rooms will not be disconnected.
        """
        logging.info("Rehashing started")
        modules = self.cmd_plugins.get_modules()
        CommandBot.pause(self)
        PlugBot.stop(self)

        logging.info("Reloading config file")
        self.botconfig = self.load_config(self.config_file)
        for module in modules:
            reload(module)
        CommandBot.reset(self)

        PlugBot.start(self)
        CommandBot.resume(self)
        self.join_rooms()
コード例 #4
0
ファイル: reminder.py プロジェクト: DomNomNom/simplepybot
        # let the user know!
        self.bot.msg_all("Copy that", targets)

    def send_reminder(self, string, targets):
        self.bot.msg_all(string, targets)

    def syntax(self):
        return """
                Reminder module supports
                !remind me in {x} [minutes|seconds|hours] {some reminder string}
                """

    def close(self):
        # we don't need to clean up anything special
        pass


if __name__ == "__main__":
    # basic stream handler
    h = logging.StreamHandler()
    h.setLevel(logging.DEBUG)
    # format to use
    f = logging.Formatter("%(name)s %(levelname)s %(message)s")
    h.setFormatter(f)
    file_handler.setFormatter(f)
    bot = CommandBot("TimeTester", "irc.segfault.net.nz", 6667, log_handlers=[h])
    bot.join("#bots")
    ReminderModule(bot)
    bot.loop()
コード例 #5
0
ファイル: reminder.py プロジェクト: DomNomNom/simplepybot
        
        #let the user know!
        self.bot.msg_all("Copy that", targets)


    def send_reminder(self, string, targets):
        self.bot.msg_all(string, targets)
    
    def syntax(self):
        return  '''
                Reminder module supports
                !remind me in {x} [minutes|seconds|hours] {some reminder string}
                '''
                
    def close(self):
        #we don't need to clean up anything special
        pass

if __name__ == '__main__':
    #basic stream handler
    h = logging.StreamHandler()
    h.setLevel(logging.DEBUG)
    #format to use
    f = logging.Formatter("%(name)s %(levelname)s %(message)s")
    h.setFormatter(f)
    file_handler.setFormatter(f)
    bot = CommandBot('TimeTester', 'irc.segfault.net.nz', 6667, log_handlers=[h])
    bot.join('#bots')
    ReminderModule(bot)
    bot.loop()