def setup(self): ### Grab important shit self.commands = CommandManager() self.storage = StorageManager() ### Initial config load try: self._config = self.storage.get_file(self, "config", YAML, "plugins/8ball.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/8ball.yml") self.logger.error("Disabling...") self._disable_self() return ### Setup some stuff self._random = random.Random() self._question_regex = re.compile("[\W_]+") ### Register commands self.commands.register_command("8ball", self.eight_ball_cmd, self, "8ball.8ball", default=True)
def setup(self): ### Grab important shit self.commands = CommandManager() self.storage = StorageManager() ### Initial config load try: self._config = self.storage.get_file(self, "config", YAML, "plugins/jargon.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/jargon.yml") self.logger.error("Disabling...") self._disable_self() return ### Register commands self.commands.register_command("jargon", self.jargon_cmd, self, "jargon.jargon", default=True)
def setup(self): self.logger.trace("Entered setup method.") self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/feeds.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling..") self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/feeds.yml") self.logger.error("Disabling..") self._disable_self() return self.config.add_callback(self.delayed_setup) self.events = EventManager() self.plugman = PluginManager() self.logger.info("Waiting 30 seconds to set up.") reactor.callLater(30, self.delayed_setup)
def setup(self): ### Grab important shit self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() ### Initial config load try: self._config = self.storage.get_file(self, "config", YAML, "plugins/triggers.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/triggers.yml") self.logger.error("Disabling...") self._disable_self() return ### Register event handlers def _message_event_filter(event=MessageReceived): return isinstance(event.target, Channel) self.events.add_callback("MessageReceived", self, self.message_handler, 1, _message_event_filter) self.events.add_callback("ActionReceived", self, self.action_handler, 1, _message_event_filter)
def __init__(self): configure(None) self.logger = getLogger("Permissions") self.confdir = tmpdir + "/config/" self.datadir = tmpdir + "/data/" try: os.makedirs(self.confdir) os.makedirs(self.datadir) self.logger.debug("Config and data dirs created.") except Exception: pass yaml.dump({"editor_warning": False}, open(self.confdir + "settings.yml", "w")) self.storage = StorageManager(self.confdir, self.datadir) self.data = self.storage.get_file(self, "data", formats.YAML, "permissions.yml") self.handler = permissionsHandler(self, self.data) super(TestPlugin, self).__init__( AttrDict(name="test", module="test_permissions"), AttrDict(name="python"), )
def setup(self): self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/wordnik.yml") except Exception: self.logger.exception("Unable to load the configuration!") return self._disable_self() if not self.config.exists: self.logger.error("Unable to find the configuration at " "config/plugins/wordnik.yml - Did you fill " "it out?") return self._disable_self() if "apikey" not in self.config or not self.config["apikey"]: self.logger.error("Unable to find an API key; did you fill out the" " config?") return self._disable_self() self._load() self.config.add_callback(self._load) self.plugman = PluginManager() self.commands = CommandManager() self.commands.register_command("dict", self.dict_command, self, "wordnik.dict", default=True) self.commands.register_command("wotd", self.wotd_command, self, "wordnik.wotd", default=True)
def setup(self): self.logger.trace("Entered setup method.") self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/wolfram.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling..") self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/wolfram.yml") self.logger.error("Disabling..") self._disable_self() return self.commands = CommandManager() self._load() self.config.add_callback(self._load) self.commands.register_command("wolfram", self.wolfram_command, self, "wolfram.wolfram", aliases=["wa"], default=True)
def setup(self): self.events = EventManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/blowfish.yml") except Exception: self.logger.exception("Error loading configuration!") self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/blowfish.yml") self._disable_self() return self.events.add_callback("PreMessageReceived", self, self.pre_message, 10001) self.events.add_callback("MessageSent", self, self.message_sent, 10001) self.events.add_callback("ActionReceived", self, self.message_sent, 10001) self.events.add_callback("ActionSent", self, self.message_sent, 10001)
def setup(self): self.logger.trace("Entered setup method.") self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/minecraft.yml") except Exception: self.logger.exception("Error loading configuration!") self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/minecraft.yml") self.logger.error("Disabling..") self._disable_self() return if not self.relay_targets: self.logger.warn("No valid target protocols found. " "Disabling status relaying.") self.commands = CommandManager() self.commands.register_command("mcquery", self.query_command, self, "minecraft.query", default=True) if self.do_relay: reactor.callLater(30, self.start_relay)
def setup(self): signal.signal(signal.SIGINT, self.signal_callback) self.yapsy_logger.debug_ = self.yapsy_logger.debug self.yapsy_logger.debug = self.yapsy_logger.trace self.storage = StorageManager() self.main_config = self.storage.get_file(self, "config", YAML, "settings.yml") self.commands.set_factory_manager(self) self.load_config() # Load the configuration try: self.metrics = Metrics(self.main_config, self) except Exception: self.logger.exception(_("Error setting up metrics.")) self.plugman.scan() self.load_plugins() # Load the configured plugins self.load_protocols() # Load and set up the protocols if not len(self.factories): self.logger.info( _("It seems like no protocols are loaded. " "Shutting down..")) return self.console_magic = ConsoleMagic()
def setup(self): self.logger.trace("Entered setup method.") self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/inter.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error(_("Disabling..")) self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/inter.yml") self.logger.error(_("Disabling..")) self._disable_self() return self.config.add_callback(self.reload) self.commands.register_command("players", self.players_command, self, "inter.players", default=True) if not reactor.running: self.events.add_callback( "ReactorStarted", self, self.first_load, 0 ) else: self.first_load()
def setup(self): self.storage = StorageManager() self.data = self.storage.get_file(self, "data", YAML, "plugins/memos/memos.yml") self.commands.register_command("memo", self.memo, self, default=True, permission="memos.memo") self.events.add_callback("PreMessageReceived", self, self.message_received, 0)
def setup(self): ### Grab important shit self.commands = CommandManager() self.storage = StorageManager() ### Initial config load try: self._config = self.storage.get_file(self, "config", YAML, "plugins/aoshelper.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/aoshelper.yml") self.logger.error("Disabling...") self._disable_self() return ### Load options from config self._load() self._config.add_callback(self._load) ### Register commands self.commands.register_command("aosplayercount", self.playercount_cmd, self, "aoshelper.playercount", [ "playercount" ], default=True) self.commands.register_command("aostoip", self.aos_to_ip_command, self, "aoshelper.aostoip", [ "aos2ip" ]) self.commands.register_command("iptoaos", self.ip_to_aos_command, self, "aoshelper.iptoaos", [ "ip2aos" ]) ### Setup soem variables self._last_update_voxlap = 0 self._last_update_steam = 0 self._last_voxlap_player_count = -1 self._last_steam_player_count = -1
def setup(self): """ Called when the plugin is loaded. Performs initial setup. """ self.logger.trace(_("Entered setup method.")) self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/urls.yml") except Exception: self.logger.exception(_("Error loading configuration!")) else: if not self.config.exists: self.logger.warn(_("Unable to find config/plugins/urls.yml")) else: self.content_types = self.config["content_types"] self.spoofing = self.config["spoofing"] self.logger.debug(_("Spoofing: %s") % self.spoofing) self.channels = self.storage.get_file(self, "data", YAML, "plugins/urls/channels.yml") self.shortened = self.storage.get_file( self, "data", DBAPI, "sqlite3:data/plugins/urls/shortened.sqlite", "data/plugins/urls/shortened.sqlite", check_same_thread=False) self.commands = CommandManager() self.events = EventManager() self.reload() def message_event_filter(event=MessageReceived): target = event.target type_ = event.type return type_ == "message" \ or isinstance(target, Channel) \ or isinstance(target, User) self.add_shortener("tinyurl", self.tinyurl) self.events.add_callback("MessageReceived", self, self.message_handler, 1, message_event_filter) self.commands.register_command("urls", self.urls_command, self, "urls.manage") self.commands.register_command("shorten", self.shorten_command, self, "urls.shorten", default=True)
def setup(self): ### Grab important shit self.commands = CommandManager() self.storage = StorageManager() ### Initial config load try: self._config = self.storage.get_file(self, "config", YAML, "plugins/lastfm.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/lastfm.yml") self.logger.error("Disabling...") self._disable_self() return ### Same for the data file (nickname=>lastfmusername map) try: self._nickmap = self.storage.get_file( self, "data", YAML, "plugins/lastfm-nickmap.yml") except Exception: self.logger.exception("Error loading nickmap!") self.logger.error("Disabling...") self._disable_self() ### Load options from config and nick map from data self._load() self._config.add_callback(self._load) ### Register commands self.commands.register_command("nowplaying", self.nowplaying_cmd, self, "lastfm.nowplaying", aliases=["np"], default=True) self.commands.register_command("lastfmnick", self.lastfmnick_cmd, self, "lastfm.lastfmnick", default=True) self.commands.register_command("lastfmcompare", self.compare_cmd, self, "lastfm.compare", aliases=["musiccompare", "compare"], default=True)
def setup(self): # ## Grab important shit self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() self.plugman = PluginManager() # ## Set up database self.database = self.storage.get_file( self, "data", DBAPI, "sqlite3:data/plugins/factoids.sqlite", "data/plugins/factoids.sqlite", check_same_thread=False ) self.database.add_callback(self.reload) self.reload() # ## Register commands # We have multiple possible permissions per command, so we have to do # permission handling ourselves self.commands.register_command("addfactoid", self.factoid_add_command, self, None) self.commands.register_command("setfactoid", self.factoid_set_command, self, None) self.commands.register_command("deletefactoid", self.factoid_delete_command, self, None, ["delfactoid"]) self.commands.register_command("getfactoid", self.factoid_get_command, self, None, default=True) # ## Register events self.events.add_callback("MessageReceived", self, self.message_handler, 1) self.events.add_callback("Web/ServerStartedEvent", self, self.web_routes, 1)
def setup(self): self.storage = StorageManager() self.config = self.storage.get_file(self, "config", YAML, "plugins/money.yml") self.commands = command_manager.CommandManager() self.commands.register_command("money", self.money_command_called, self, "money.main", default=True) self._load() self.config.add_callback(self._load)
def setup(self): ### Grab important shit self._commands = CommandManager() self._storage = StorageManager() ### Initial config load try: self._config = self._storage.get_file(self, "config", YAML, "plugins/xkcd.yml") except: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/xkcd.yml") self.logger.error("Disabling...") self._disable_self() return ### Same for the data files try: self._comic_cache = self._storage.get_file( self, "data", YAML, "plugins/xkcd/comic-cache.yml") except: self.logger.exception("Error loading comic-cache!") self.logger.error("Disabling...") self._disable_self() try: self._archive = self._storage.get_file(self, "data", YAML, "plugins/xkcd/archive.yml") except: self.logger.exception("Error loading archive!") self.logger.error("Disabling...") self._disable_self() ### Initial data file setup and stuff self._load() self._config.add_callback(self._load) self._comic_cache.add_callback(self._load) self._archive.add_callback(self._load) ### Register commands self._commands.register_command("xkcd", self.xkcd_cmd, self, "xkcd.xkcd", default=True)
def setup(self): ### Grab important shit self._commands = CommandManager() self._storage = StorageManager() ### Initial config load try: self._config = self._storage.get_file(self, "config", YAML, "plugins/dice.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/dice.yml") self.logger.error("Disabling...") self._disable_self() return ### Register commands self._commands.register_command("roll", self.roll_cmd, self, "dice.roll", aliases=["dice"], default=True)
def setup(self): self.commands = CommandManager() self.storage = StorageManager() self.logger.trace("Entered setup method.") try: self.config = self.storage.get_file(self, "config", YAML, "plugins/items.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.warn("Defaulting to SQLite for storage.") else: if not self.config.exists: self.logger.warn("Unable to find config/plugins/items.yml") self.logger.warn("Defaulting to SQLite for storage.") else: self.logger.info("Using storage type: %s" % self.storage_type) self._load() self.config.add_callback(self._load) self.commands.register_command("give", self.give_command, self, "items.give", default=True) self.commands.register_command("get", self.get_command, self, "items.get", default=True) self.commands.register_command("items", self.count_command, self, "items.count", default=True)
def setup(self): signal.signal(signal.SIGINT, self.signal_callback) self.yapsy_logger.debug_ = self.yapsy_logger.debug self.yapsy_logger.debug = self.yapsy_logger.trace self.storage = StorageManager() self.main_config = self.storage.get_file(self, "config", YAML, "settings.yml") self.commands.set_factory_manager(self) self.load_config() # Load the configuration try: self.metrics = Metrics(self.main_config, self) except Exception: self.logger.exception(_("Error setting up metrics.")) self.plugman.scan() self.load_plugins() # Load the configured plugins self.load_protocols() # Load and set up the protocols if not len(self.factories): self.logger.info(_("It seems like no protocols are loaded. " "Shutting down..")) return
def setup(self): self.logger.trace("Entered setup method.") self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/inter.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error(_("Disabling..")) self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/inter.yml") self.logger.error(_("Disabling..")) self._disable_self() return self.config.add_callback(self.reload) self.commands.register_command("players", self.players_command, self, "inter.players", default=True) self.events.add_callback("ReactorStarted", self, self.first_load, 0)
def setup(self): """The list of bridging rules""" self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() self.data = self.storage.get_file(self, "data", YAML, "plugins/dialectizer/settings.yml") self.events.add_callback("MessageSent", self, self.handle_msg_sent, 1) self.commands.register_command("dialectizer", self.dialectizer_command, self, "dialectizer.set", aliases=["dialectiser"])
def __init__(self, get=True): self.storage = StorageManager() if get: info_url = self.base_file_url + self.info_file response = urllib2.urlopen(info_url) data = response.read() self.data = yaml.load(data) self.packages = sorted(self.data.keys()) self.config = self.storage.get_file(self, "data", YAML, "packages.yml") with self.config: if "installed" not in self.config: self.config["installed"] = {} if "etags" not in self.config: self.config["etags"] = {}
def setup(self): self.events = EventManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/blowfish.yml") except Exception: self.logger.exception("Error loading configuration!") self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/blowfish.yml") self._disable_self() return self.events.add_callback( "PreMessageReceived", self, self.pre_message, 10001 ) self.events.add_callback( "MessageSent", self, self.message_sent, 10001 ) self.events.add_callback( "ActionReceived", self, self.message_sent, 10001 ) self.events.add_callback( "ActionSent", self, self.message_sent, 10001 )
def setup(self): # Define this so we have instances of everything we need self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() self.plugman = PluginManager() # Now run the actual setup function self.wrapper(self.clj_plugin.setup)()
def setup(self): ### Grab important shit self.commands = CommandManager() self.storage = StorageManager() ### Initial config load try: self._file_config = self.storage.get_file( self, "config", YAML, "plugins/jargon.yml" ) except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._file_config.exists: self.logger.error("Unable to find config/plugins/jargon.yml") self.logger.error("Disabling...") self._disable_self() return self._file_config.add_callback(self.load) self.load() ### Register commands self.commands.register_command( "jargon", self.jargon_cmd, self, JARGON_PERM, aliases=["generatesentence", "generate"], default=True ) self.commands.register_command( "jargonlist", self.jargonlist_cmd, self, JARGON_LIST_PERM, aliases=["generatesentencelist", "generatelist"], default=True )
def setup(self): self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() self.data = self.storage.get_file( self, "data", DBAPI, "sqlite3:data/plugins/lastseen/users.sqlite", "data/plugins/lastseen/users.sqlite", check_same_thread=False ) self.data.runQuery("CREATE TABLE IF NOT EXISTS users (" "user TEXT, " "protocol TEXT, " "at INTEGER)") self.commands.register_command("seen", self.seen_command, self, "seen.seen", default=True) # General events self.events.add_callback("PreMessageReceived", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_source_caller]) self.events.add_callback("PreCommand", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_source_caller]) self.events.add_callback("NameChanged", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller]) self.events.add_callback("UserDisconnected", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller]) # Mumble events self.events.add_callback("Mumble/UserRemove", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller]) self.events.add_callback("Mumble/UserJoined", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller]) self.events.add_callback("Mumble/UserMoved", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller]) self.events.add_callback("Mumble/UserSelfMuteToggle", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller]) self.events.add_callback("Mumble/UserSelfDeafToggle", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller]) self.events.add_callback("Mumble/UserRecordingToggle", self, self.event_handler, 0, cancelled=True, extra_args=[self.event_user_caller])
class ItemsPlugin(plugin.PluginObject): commands = None config = None data = None storage = None handler = None @property def storage_type(self): if self.config["storage"].lower() == "json": return "json" return "sqlite" def setup(self): self.commands = CommandManager() self.storage = StorageManager() self.logger.trace("Entered setup method.") try: self.config = self.storage.get_file(self, "config", YAML, "plugins/items.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.warn("Defaulting to SQLite for storage.") else: if not self.config.exists: self.logger.warn("Unable to find config/plugins/items.yml") self.logger.warn("Defaulting to SQLite for storage.") else: self.logger.info("Using storage type: %s" % self.storage_type) self._load() self.config.add_callback(self._load) self.commands.register_command("give", self.give_command, self, "items.give", default=True) self.commands.register_command("get", self.get_command, self, "items.get", default=True) def _load(self): if self.storage_type == "json": self.handler = JSONType(self, self.storage, self.logger) else: self.handler = SQLiteType(self, self.storage, self.logger) @RateLimiter(5, 0, 10) def give_command(self, *args, **kwargs): return self.handler.give_command(*args, **kwargs) @RateLimiter(5, 0, 10) def get_command(self, *args, **kwargs): return self.handler.get_command(*args, **kwargs)
def setup(self): self.commands = CommandManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/brainfuck.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling..") self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/brainfuck.yml") self.logger.error("Disabling..") self._disable_self() return self.commands.register_command("bf", self.bf_command, self, "brainfuck.exec", default=True)
def setup(self): ### Grab important shit self.commands = CommandManager() self.events = EventManager() self.storage = StorageManager() ### Initial config load try: self.config = self.storage.get_file(self, "config", YAML, "plugins/drunkoctopus.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self.config.exists: self.logger.error("Unable to find config/plugins/drunkoctopus.yml") self.logger.error("Disabling...") self._disable_self() return ### Create vars and stuff self._sobering_call = None self._drunktalk = DrunkTalk() ### Load options from config self._load() self.config.add_callback(self._load) ### Register events and commands self.events.add_callback("MessageSent", self, self.outgoing_message_handler, 1) self.commands.register_command("drunkenness", self.drunkenness_command, self, "drunkoctopus.drunkenness", default=True) self.commands.register_command("drink", self.drink_command, self, "drunkoctopus.drink")
def setup(self): """ Called when the plugin is loaded. Performs initial setup. """ self.logger.trace(_("Entered setup method.")) self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/urls.yml") except Exception: self.logger.exception(_("Error loading configuration!")) else: if not self.config.exists: self.logger.warn(_("Unable to find config/plugins/urls.yml")) else: self.content_types = self.config["content_types"] self.spoofing = self.config["spoofing"] self.logger.debug(_("Spoofing: %s") % self.spoofing) self.channels = self.storage.get_file(self, "data", YAML, "plugins/urls/channels.yml") self.shortened = self.storage.get_file( self, "data", DBAPI, "sqlite3:data/plugins/urls/shortened.sqlite", "data/plugins/urls/shortened.sqlite", check_same_thread=False ) self.commands = CommandManager() self.events = EventManager() self.reload() def message_event_filter(event=MessageReceived): target = event.target type_ = event.type return type_ == "message" \ or isinstance(target, Channel) \ or isinstance(target, User) self.add_shortener("tinyurl", self.tinyurl) self.events.add_callback("MessageReceived", self, self.message_handler, 1, message_event_filter) self.commands.register_command("urls", self.urls_command, self, "urls.manage") self.commands.register_command("shorten", self.shorten_command, self, "urls.shorten", default=True)
class WebhooksPlugin(plugin.PluginObject): config = None data = None commands = None events = None plugins = None storage = None @property def web(self): """ :rtype: plugins.web.WebPlugin """ return self.plugins.get_plugin("Web") def setup(self): self.logger.trace("Entered setup method.") self.commands = CommandManager() self.events = EventManager() self.plugins = PluginManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/webhooks.yml") except Exception: self.logger.exception("Error loading configuration!") return self._disable_self() else: if not self.config.exists: self.logger.error("Unable to find config/plugins/webhooks.yml") return self._disable_self() self._load() self.config.add_callback(self._load) self.events.add_callback("Web/ServerStartedEvent", self, self.add_routes, 0) def _load(self): pass def add_routes(self, _=None): self.web.add_navbar_entry("Webhooks", "/webhooks", "url") self.web.add_handler("/webhooks", "plugins.webhooks.routes.webhooks.Route") self.logger.info("Registered route: /webhooks") pass # So the regions work in PyCharm
def __init__(self, info, loader): from system.factory_manager import FactoryManager from system.plugins.manager import PluginManager self.commands = CommandManager() self.events = EventManager() self.factory_manager = FactoryManager() self.info = info self.logger = getLogger(info.name) self.module = self.info.module self.plugins = PluginManager() self.storage = StorageManager() self._loader = loader.name
def setup(self): self.logger.trace("Entered setup method.") self.commands = CommandManager() self.events = EventManager() self.plugins = PluginManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/twilio.yml") except Exception: self.logger.exception("Error loading configuration!") return self._disable_self() else: if not self.config.exists: self.logger.error("Unable to find config/plugins/twilio.yml") return self._disable_self() try: self.data = self.storage.get_file(self, "data", JSON, "plugins/twilio/contacts.json") except Exception: self.logger.exception("Error loading data!") self.logger.error("This data file is required. Shutting down...") return self._disable_self() self._load() self.config.add_callback(self._load) self.events.add_callback("Web/ServerStartedEvent", self, self.add_routes, 0) self.commands.register_command("sms", self.sms_command, self, "twilio.sms") self.commands.register_command("mms", self.mms_command, self, "twilio.mms") self.commands.register_command("tw", self.tw_command, self, "twilio.tw")
def setup(self): ### Grab important shit self.commands = CommandManager() self.storage = StorageManager() ### Initial config load try: self._config = self.storage.get_file(self, "config", YAML, "plugins/lastfm.yml") except Exception: self.logger.exception("Error loading configuration!") self.logger.error("Disabling...") self._disable_self() return if not self._config.exists: self.logger.error("Unable to find config/plugins/lastfm.yml") self.logger.error("Disabling...") self._disable_self() return ### Same for the data file (nickname=>lastfmusername map) try: self._nickmap = self.storage.get_file(self, "data", YAML, "plugins/lastfm-nickmap.yml") except Exception: self.logger.exception("Error loading nickmap!") self.logger.error("Disabling...") self._disable_self() ### Load options from config and nick map from data self._load() self._config.add_callback(self._load) ### Register commands self.commands.register_command("nowplaying", self.nowplaying_cmd, self, "lastfm.nowplaying", aliases=["np"], default=True) self.commands.register_command("lastfmnick", self.lastfmnick_cmd, self, "lastfm.lastfmnick", default=True) self.commands.register_command("lastfmcompare", self.compare_cmd, self, "lastfm.compare", aliases=["musiccompare", "compare"], default=True)
def setup(self): self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/urltools.yml") except Exception: self.logger.exception("Unable to load the configuration!") self._disable_self() return self.sites["osu.ppy.sh"] = self.site_osu self.sites["youtube.com"] = self.site_youtube self.sites["github.com"] = self.site_github self.shorteners["is.gd"] = self.shortener_isgd self.shorteners["nazr.in"] = self.shortener_nazrin self.shorteners["v.gd"] = self.shortener_vgd self.shorteners["waa.ai"] = self.shortener_waaai self.plugman = PluginManager() self._load() self.config.add_callback(self._load)
def setup(self): self.logger.trace("Entered setup method.") self.commands = CommandManager() self.events = EventManager() self.plugins = PluginManager() self.storage = StorageManager() try: self.config = self.storage.get_file(self, "config", YAML, "plugins/webhooks.yml") except Exception: self.logger.exception("Error loading configuration!") return self._disable_self() else: if not self.config.exists: self.logger.error("Unable to find config/plugins/webhooks.yml") return self._disable_self() self._load() self.config.add_callback(self._load) self.events.add_callback("Web/ServerStartedEvent", self, self.add_routes, 0)
def __init__(self): self.logger = getLogger("Permissions") self.confdir = tmpdir + "/config/" self.datadir = tmpdir + "/data/" try: os.makedirs(self.confdir) os.makedirs(self.datadir) self.logger.debug("Config and data dirs created.") except Exception: pass yaml.dump({"editor_warning": False}, open(self.confdir + "settings.yml", "w")) self.storage = StorageManager(self.confdir, self.datadir) self.data = self.storage.get_file(self, "data", formats.YAML, "permissions.yml") self.handler = permissionsHandler(self, self.data) super(PluginObject, self).__init__()
class MemosPlugin(plugin.PluginObject): storage = None data = {} def setup(self): self.storage = StorageManager() self.data = self.storage.get_file(self, "data", YAML, "plugins/memos/memos.yml") self.commands.register_command("memo", self.memo, self, default=True, permission="memos.memo") self.events.add_callback("PreMessageReceived", self, self.message_received, 0) def memo(self, protocol, caller, source, command, raw_args, args): if args is None: args = raw_args.split() if len(args) < 2: caller.respond("Usage: {CHARS}memo <user> <message>") return user = args[0] message = "[{0}]: {1}".format(caller.name, " ".join(args[1:])) with self.data: if protocol.name in self.data: if user in self.data[protocol.name]: self.data[protocol.name][user].append(message) else: self.data[protocol.name].update({user: [message]}) else: self.data[protocol.name] = {user: [message]} source.respond("I'll send it to {0}".format(user)) def message_received(self, event=PreMessageReceived): if event.caller.name in self.data: if event.source.name in self.data[event.caller.name]: event.source.respond('Message for {0}: {1}'.format( event.source.name, self.data[event.caller.name][event.source.name] )) with self.data: del self.data[event.caller.name][event.source.name]