Пример #1
0
    def __init__(self):
        """Constructor"""
        self.debug = True
        super(DeeBot, self).__init__("UnoBot")

        # Config
        self.config = {}
        self.config["server"] = os.environ['IRC_SERVER']
        self.config["channel"] = os.environ['IRC_CHANNEL']
        self.config["admins"] = [
            x.strip() for x in os.environ['IRC_ADMINS'].split(',')
        ]
        self.config["plugins"] = ["Uno"]

        # Add events.
        self.addEvent("connected", Events.ConnectedEvent())
        self.addEvent("message", Events.MessageEvent())

        # Plugin modules are loaded into the plugin dictionary, with the key
        # being the name of the module.
        self.plugins = {}

        # Load plugins.
        for plugin in self.config["plugins"]:
            self.loadPlugin(plugin)

        # Check PID Files
        pid = str(os.getpid())
        pidfile = "UnoBot.pid"

        if os.path.isfile(pidfile):
            os.remove(pidfile)
            file(pidfile, 'w').write(pid)
        else:
            file(pidfile, 'w').write(pid)