def _initialise(bot): _migrate_syncroom_v1(bot) plugins.register_admin_command(["syncusers"]) plugins.register_handler(_handle_syncrooms_broadcast, type="sending") plugins.register_handler(_handle_incoming_message, type="message") plugins.register_handler( _handle_syncrooms_membership_change, type="membership")
def _initialise(bot): plugins.register_admin_command([ "memorytaint", "memoryuntaint", "memorystatus", "memoryset", "memoryget", "memorypop", "memorysave", "memorydelete", "submemoryinit", "submemoryclear", "submemoryset", "submemoryget", "submemorypop", "submemorydelete" ])
def _initialise(bot): # unbreak slackrtm memory.json usage # previously, this plugin wrote into "user_data" key to store its internal team settings _slackrtm_conversations_migrate_20170319(bot) # Start and asyncio event loop loop = asyncio.get_event_loop() slack_sink = bot.get_config_option('slackrtm') threads = [] if isinstance(slack_sink, list): for sinkConfig in slack_sink: # start up slack listener in a separate thread t = SlackRTMThread(bot, loop, sinkConfig) t.daemon = True t.start() t.isFullyLoaded.wait() threads.append(t) logger.info("%d sink thread(s) started", len(threads)) plugins.register_handler(_handle_membership_change, type="membership") plugins.register_handler(_handle_rename, type="rename") plugins.register_admin_command([ "slacks", "slack_channels", "slack_listsyncs", "slack_syncto", "slack_disconnect", "slack_setsyncjoinmsgs", "slack_setimageupload", "slack_sethotag", "slack_users", "slack_setslacktag", "slack_showslackrealnames", "slack_showhorealnames" ]) plugins.register_user_command(["slack_identify"]) plugins.start_asyncio_task(_wait_until_unloaded).add_done_callback( _plugin_unloaded)
def _initialise(bot): _migrate_syncroom_v1(bot) plugins.register_admin_command(["syncusers"]) plugins.register_handler(_handle_syncrooms_broadcast, type="sending") plugins.register_handler(_handle_incoming_message, type="message") plugins.register_handler(_handle_syncrooms_membership_change, type="membership")
def _initialize(bot): api_key = bot.get_config_option('forecast_api_key') if api_key: _internal['forecast_api_key'] = api_key plugins.register_user_command(['weather', 'forecast']) plugins.register_admin_command(['setweatherlocation']) else: logger.error('WEATHER: config["forecast_api_key"] required')
def _initialise(): """register the commands and their help entrys""" plugins.register_admin_command([ "broadcast", "users", "user", "hangouts", "rename", "leave", "reload", "quit", "config", "whereami" ]) plugins.register_user_command(["echo", "whoami"]) plugins.register_help(HELP)
def _initialise(bot): load() plugins.register_handler(_handle_bad_words, type='message') plugins.register_handler(_handle_bad_names, type='rename') plugins.register_handler(_handle_toxicity, type='message') plugins.register_user_command(['language', 'lastword', 'analyze']) plugins.register_admin_command(['langadd', 'langdel', 'langload']) plugins.register_user_command(['koby'])
def _initialise(bot): utils._conversation_list_cache = convmem # !!!: it works, but i don't like it ;P _memory_load(bot) _update_conversation_list(bot) plugins.register_admin_command(["dumpconv"]) plugins.register_handler(_watch_message, type="allmessages") plugins.register_handler(_watch_rename, type="rename") plugins.register_handler(_watch_member, type="membership") plugins.register_shared('convmem.removeconv', _conv_remove)
def _initialise(bot): plugins.register_user_command(["tldr"]) plugins.register_admin_command(["tldrecho"]) bot.register_shared("plugin_tldr_shared", tldr_shared) # Set the global option if not bot.get_config_option('tldr_echo'): bot.config.set_by_path(["tldr_echo"], 1) # tldr_echo_options[1] is "GROUP" bot.config.save()
def _initialise(bot): plugins.register_handler(_broadcast, type="sending") plugins.register_handler(_repeat, type="message") #_register_chatbridge_behaviour('userlist', _syncout_users) plugins.register_admin_command(["syncusers"]) return [] plugins.register_handler(_handle_syncrooms_membership_change, type="membership")
def _initialise(bot): if not bot.get_config_option("botalive"): return plugins.register_admin_command(["dumpwatermarklogs"]) plugins.start_asyncio_task(_tick) # track events that can modify the watermark watch_event_types = ["message", "membership", "rename"] for event_type in watch_event_types: plugins.register_handler(_conv_external_event, event_type)
def _initialise(bot): convert_legacy_config(bot) plugins.register_user_command(["slack_identify"]) plugins.register_admin_command(["slack_sync", "slack_unsync"]) root = bot.get_config_option("slackrtm") or {} Base.bot = bot for team, config in root.get("teams", {}).items(): Base.add_slack(Slack(team, config["token"])) for sync in root.get("syncs", []): Base.add_bridge(BridgeInstance(bot, "slackrtm", sync)) for slack in Base.slacks.values(): slack.start() plugins.register_handler(on_membership_change, type="membership")
def _initialise(bot): _migrate_syncroom_v1(bot) plugins.register_handler(_broadcast, type="sending") plugins.register_handler(_repeat, type="allmessages") #_register_chatbridge_behaviour('userlist', _syncout_users) plugins.register_admin_command(["syncusers"]) return [] plugins.register_handler(_handle_syncrooms_membership_change, type="membership")
def _initialize(bot): bot.spawn_lock = asyncio.Lock() config = bot.get_config_option("spawn") if not config: return cmds = config.get("commands") # override the load logic and register our commands directly for cmd in cmds: command.register(_spawn, admin=True, final=True, name=cmd) logger.info("spawn - %s", ", ".join(['*' + cmd for cmd in cmds])) plugins.register_admin_command(list(cmds))
def _initialise(bot): if not bot.get_config_option("botalive"): return plugins.register_admin_command(["dumpwatermarklogs"]) plugins.start_asyncio_task(_tick) # track events that can modify the watermark watch_event_types = [ "message", "membership", "rename" ] for event_type in watch_event_types: plugins.register_handler(_conv_external_event, event_type)
def _initialise(bot): """register the commands and help, shareds on the aliases Args: bot: HangupsBot instance """ bot.memory.validate({'hoalias': {}}) plugins.register_user_command(['gethoalias']) plugins.register_admin_command(['sethoalias']) plugins.register_help(HELP) plugins.register_shared('convid2alias', functools.partial(get_alias, bot)) plugins.register_shared('alias2convid', functools.partial(get_convid, bot))
def _initialise(bot): """update the sources, register the admin command and watch for messages Args: bot: HangupsBot instance """ if not bot.memory.exists(['passcode_relay']): bot.memory.set_by_path(['passcode_relay'], {}) if not bot.memory.exists(['passcode_relay', '_available_relays']): bot.memory.set_by_path(['passcode_relay', '_available_relays'], {}) asyncio.ensure_future(_update_relays(bot)) plugins.register_admin_command(['passcode_relay']) plugins.register_handler(_on_hangouts_message, "allmessages")
def _initialise(Handlers, bot=None): admin_commands = ["broadcast", "users", "user", "hangouts", "hangout", "rename", "leave", "reload", "quit", "config", "whereami"] user_commands = ["echo", "echoparsed", "whoami"] try: plugins.register_admin_command(admin_commands) plugins.register_user_command(user_commands) except Exception as e: if "register_admin_command" in dir(Handlers) and "register_user_command" in dir(Handlers): print(_("DEFAULT: LEGACY FRAMEWORK MODE")) Handlers.register_admin_command(admin_commands) Handlers.register_user_command(user_commands) else: print(_("DEFAULT: OBSOLETE FRAMEWORK MODE")) return admin_commands + user_commands return []
def _initialise(bot): plugins.register_admin_command(["clearpokedex"]) plugins.register_user_command(["pokedex", "pokemon"]) global pokedex_config try: pokedex_config = bot.get_config_option('pokedex') or {} except: logger.error('Unable to load pokedex configuration - default configuration will apply.') try: if not pokedex_config['info']: pokedex_config['info'] = ['types'] except KeyError: pokedex_config['info'] = ['types']
def _initialise(bot): plugins.register_admin_command(["lograise", "logconfig"]) rootLogger = logging.getLogger() for handler in rootLogger.handlers: if handler.__class__.__name__ == "ChatMessageLogger": logger.info("ChatMessageLogger already attached") return chatHandler = ChatMessageLogger(bot) chatHandler.setFormatter(logging.Formatter("<b>%(levelname)s %(name)s </b>: %(message)s")) chatHandler.setLevel(logging.WARNING) chatHandler.addFilter(PluginFilter(bot)) rootLogger.addHandler(chatHandler)
def _initialise(bot): plugins.register_admin_command(["clearpokedex"]) plugins.register_user_command(["pokedex", "pokemon"]) global pokedex_config try: pokedex_config = bot.get_config_option('pokedex') or {} except: logger.error( 'Unable to load pokedex configuration - default configuration will apply.' ) try: if not pokedex_config['info']: pokedex_config['info'] = ['types'] except KeyError: pokedex_config['info'] = ['types']
def _initialise(bot): if not _telesync_config(bot): return if not bot.memory.exists(['telesync']): bot.memory.set_by_path(['telesync'], {'ho2tg': {}, 'tg2ho': {}}) bot.memory.save() if not bot.memory.exists(['profilesync']): bot.memory.set_by_path(['profilesync'], {'ho2tg': {}, 'tg2ho': {}}) bot.memory.save() global client_session global tg_bot global tg_loop client_session = aiohttp.ClientSession() tg_bot = TelegramBot(bot) tg_bot.set_on_message_callback(tg_on_message) tg_bot.set_on_photo_callback(tg_on_photo) tg_bot.set_on_sticker_callback(tg_on_sticker) tg_bot.set_on_user_join_callback(tg_on_user_join) tg_bot.set_on_user_leave_callback(tg_on_user_leave) tg_bot.set_on_location_share_callback(tg_on_location_share) tg_bot.set_on_supergroup_upgrade_callback(tg_on_supergroup_upgrade) tg_bot.add_command("/whoami", tg_command_whoami) tg_bot.add_command("/whereami", tg_command_whereami) tg_bot.add_command("/setsyncho", tg_command_set_sync_ho) tg_bot.add_command("/clearsyncho", tg_command_clear_sync_ho) tg_bot.add_command("/addadmin", tg_command_add_bot_admin) tg_bot.add_command("/removeadmin", tg_command_remove_bot_admin) tg_bot.add_command("/syncprofile", tg_command_sync_profile) tg_bot.add_command("/unsyncprofile", tg_command_unsync_profile) tg_bot.add_command("/getme", tg_command_get_me) tg_loop = MessageLoop(tg_bot) plugins.start_asyncio_task(tg_loop.run_forever()) plugins.start_asyncio_task(tg_bot.setup_bot_info()) plugins.register_admin_command(["telesync"]) plugins.register_user_command(["syncprofile"]) plugins.register_handler(_on_membership_change, type="membership")
def initialise(bot): plugins.register_user_command(["filmrec"], ["filmrate"]) plugins.register_admin_command(['filmload']) if not bot.memory.exists(['filmrec']): print("INITIALIZING") bot.memory.set_by_path(['filmrec'], {}) with open("ratings.csv") as csvfile: rateread = csv.reader(csvfile) for row in rateread: ratings[str(row[0])][row[1]] = row[2] with open("movies.csv") as csvfile: filmread = csv.reader(csvfile) for row in filmread: movies[str(row[0])] = row[1] bot.memory.get_by_path(['filmrec'])["ratings"] = ratings bot.memory.get_by_path(['filmrec'])["movies"] = movies
def _initialise(bot): global _bot, client _bot = bot token = bot.get_config_option('discord_token') if not token: logger.error("discord_token not set") return plugins.register_handler(_handle_hangout_message, type="allmessages") plugins.register_user_command(["dusers"]) plugins.register_admin_command(['dsync', 'discordfwd','discordfwdfilter']) try: client.run(token) except RuntimeError: # client.run will try start an event loop, however this will fail as hangoutsbot will have already started one # this isn't anything to worry about pass
def _initialise(bot): plugins.register_admin_command( [ "memorytaint", "memoryuntaint", "memorystatus", "memoryset", "memoryget", "memorypop", "memorysave", "memorydelete", "submemoryinit", "submemoryclear", "submemoryset", "submemoryget", "submemorypop", "submemorydelete", ] )
def _initialise(bot): if not _telesync_config(bot): return if not bot.memory.exists(['telesync']): bot.memory.set_by_path(['telesync'], {'ho2tg': {}, 'tg2ho': {}}) bot.memory.save() if not bot.memory.exists(['profilesync']): bot.memory.set_by_path(['profilesync'], {'ho2tg': {}, 'tg2ho': {}}) bot.memory.save() global tg_bot tg_bot = TelegramBot(bot) tg_bot.set_on_message_callback(tg_on_message) tg_bot.set_on_photo_callback(tg_on_photo) tg_bot.set_on_sticker_callback(tg_on_sticker) tg_bot.set_on_user_join_callback(tg_on_user_join) tg_bot.set_on_user_leave_callback(tg_on_user_leave) tg_bot.set_on_location_share_callback(tg_on_location_share) tg_bot.set_on_supergroup_upgrade_callback(tg_on_supergroup_upgrade) tg_bot.add_command("/whoami", tg_command_whoami) tg_bot.add_command("/whereami", tg_command_whereami) tg_bot.add_command("/setsyncho", tg_command_set_sync_ho) tg_bot.add_command("/clearsyncho", tg_command_clear_sync_ho) tg_bot.add_command("/addadmin", tg_command_add_bot_admin) tg_bot.add_command("/removeadmin", tg_command_remove_bot_admin) tg_bot.add_command("/tldr", tg_command_tldr) tg_bot.add_command("/syncprofile", tg_command_sync_profile) tg_bot.add_command("/unsyncprofile", tg_command_unsync_profile) tg_bot.add_command("/getme", tg_command_get_me) plugins.start_asyncio_task(tg_bot.message_loop(timeout=50)) plugins.start_asyncio_task(tg_bot.setup_bot_info()) plugins.register_admin_command(["telesync"]) plugins.register_user_command(["syncprofile"]) plugins.register_handler(_on_membership_change, type="membership")
def _initialize(bot): bot.spawn_lock = asyncio.Lock() config = bot.get_config_option("spawn") if not config: return cmds = config.get("commands") # override the load logic and register our commands directly get_location = False for cmd, cnf in cmds.items(): command.register(_spawn, admin=True, final=True, name=cmd) if cnf.get("allow_location"): get_location = True logger.info("spawn - %s", ", ".join(['*' + cmd for cmd in cmds])) plugins.register_admin_command(list(cmds)) if get_location: global _MAP_MATCH _MAP_MATCH = re.compile(config.get("map_regex", _MAP_REGEX), re.IGNORECASE|re.MULTILINE) plugins.register_handler(_location_handler, type="message")
def _initialise(bot): # unbreak slackrtm memory.json usage # previously, this plugin wrote into "user_data" key to store its internal team settings _slackrtm_conversations_migrate_20170319(bot) # Start and asyncio event loop loop = asyncio.get_event_loop() slack_sink = bot.get_config_option('slackrtm') threads = [] if isinstance(slack_sink, list): for sinkConfig in slack_sink: # start up slack listener in a separate thread t = SlackRTMThread(bot, loop, sinkConfig) t.daemon = True t.start() t.isFullyLoaded.wait() threads.append(t) logger.info("%d sink thread(s) started", len(threads)) plugins.register_handler(_handle_membership_change, type="membership") plugins.register_handler(_handle_rename, type="rename") plugins.register_admin_command([ "slacks", "slack_channels", "slack_listsyncs", "slack_syncto", "slack_disconnect", "slack_setsyncjoinmsgs", "slack_setimageupload", "slack_sethotag", "slack_users", "slack_setslacktag", "slack_showslackrealnames", "slack_showhorealnames" ]) plugins.register_user_command([ "slack_identify" ]) plugins.start_asyncio_task(_wait_until_unloaded).add_done_callback(_plugin_unloaded)
def register_admin_command(self, command_names): logger.debug( "[LEGACY] plugins.register_admin_command()" " instead of handlers.register_admin_command()") plugins.register_admin_command(command_names)
def _initialise(bot): plugins.register_admin_command(["attachsyncout", "detachsyncout"])
def _initialise(bot): plugins.register_admin_command(["bootcamp", "asylum", "bcadmin"])
def _initialise(bot): plugins.register_handler(_watch_new_adds, type="membership") plugins.register_admin_command(["addmod", "delmod"])
def _initialise(bot): _migrate_mention_config_to_memory(bot) plugins.register_handler(_handle_mention, "message") plugins.register_user_command(["pushbulletapi", "setnickname", "bemorespecific"]) plugins.register_admin_command(["mention"])
def _initialise(): plugins.register_handler(_handle_keyword) plugins.register_user_command(["subscribe", "unsubscribe"]) plugins.register_admin_command(["testsubscribe"])
def _initialise(bot): plugins.register_admin_command(["broadcast", "users", "user", "hangouts", "rename", "leave", "reload", "quit", "config", "whereami"]) plugins.register_user_command(["echo", "whoami"])
def _initialise(bot): plugins.register_admin_command(["invite"]) plugins.register_user_command(["rsvp"]) plugins.register_handler(_issue_invite_on_exit, type="membership")
def _initialise(): plugins.register_handler(_watch_new_adds, type="membership") plugins.register_admin_command(["addmod", "delmod"])
def _initialise(bot): plugins.register_handler(_handle_incoming_message, type="message") plugins.register_user_command(["chat"]) plugins.register_admin_command(["chatreset"])
def _initialise(bot): plugins.register_admin_command(["clearpokedex"]) plugins.register_user_command(["pokedex"])
def register_admin_command(self, command_names): logger.debug("[LEGACY] plugins.register_admin_command()" " instead of handlers.register_admin_command()") plugins.register_admin_command(command_names)
def _initialise(bot): plugins.register_admin_command( ["convecho", "convfilter", "convleave", "convrename", "convusers"])
def _initialise(bot): plugins.register_admin_command(["ia"])
def _initialise(bot): plugins.register_admin_command([ "rememberme", "whatme", "forgetme", "rememberchat", "whatchat", "forgetchat" ])
def _initialise(bot): plugins.register_admin_command( ["addme", "addusers", "createconversation", "refresh", "kick"])
def _initialise(bot): plugins.register_admin_command(["rememberme", "whatme", "forgetme", "rememberchat", "whatchat", "forgetchat"])
def _initialise(bot): _load_all_the_things() plugins.register_admin_command(["redditmemeword"]) plugins.register_handler(_scan_for_triggers)
def _initialise(bot): plugins.register_handler(_watch_rename, type="rename") plugins.register_admin_command(["topic"])
def _initialise(bot): _migrate_mention_config_to_memory(bot) plugins.register_handler(_handle_mention, "message") plugins.register_user_command( ["pushbulletapi", "setnickname", "bemorespecific"]) plugins.register_admin_command(["mention"])
def _initialise(bot): plugins.register_admin_command(["convecho", "convfilter", "convleave", "convrename", "convusers"])
def _initialise(bot): plugins.register_user_command(["screen", "coc"]) plugins.register_admin_command(["setlog", "clearlog"])
def _initialise(bot): plugins.register_admin_command(["addme", "addusers", "createconversation", "refresh"])