예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
    def start(self):
        """start the cleanup, restore old entrys and start dumping to memory"""
        plugins.start_asyncio_task(self._periodic_cleanup)

        # loading and dumping depends on a configured intervall and dump path
        if self._dump_config is not None:
            path = self._dump_config[1]
            self.bot.memory.ensure_path(path)

            # restore old entrys
            for identifier, value in self.bot.memory.get_by_path(path).items():
                self.add(identifier, *value)

            plugins.start_asyncio_task(self._periodic_dump)
예제 #4
0
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)
예제 #5
0
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")
예제 #6
0
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")
예제 #7
0
def _initialise(bot):
    config_botalive = bot.get_config_option("botalive") or {}
    if not config_botalive:
        return

    _new_config = {}
    if isinstance(config_botalive, list):
        if "admins" in config_botalive:
            _new_config["admins"] = 900
        if "groups" in config_botalive:
            _new_config["groups"] = 10800
        config_botalive = _new_config

    if "admin" in config_botalive and config_botalive["admin"] < 60:
        config_botalive["admin"] = 60
    if "groups" in config_botalive and config_botalive["groups"] < 60:
        config_botalive["groups"] = 60

    logger.info("timing {}".format(config_botalive))

    plugins.start_asyncio_task(_periodic_watermark_update, config_botalive)
예제 #8
0
def _initialise(bot):
    config_botalive = bot.get_config_option("botalive") or {}
    if not config_botalive:
        return

    _new_config = {}
    if isinstance(config_botalive, list):
        if "admins" in config_botalive:
            _new_config["admins"] = 900
        if "groups" in config_botalive:
            _new_config["groups"] = 10800
        config_botalive = _new_config

    if "admin" in config_botalive and config_botalive["admin"] < 60:
        config_botalive["admin"] = 60
    if "groups" in config_botalive and config_botalive["groups"] < 60:
        config_botalive["groups"] = 60

    logger.info("timing {}".format(config_botalive))

    plugins.start_asyncio_task(_periodic_watermark_update, config_botalive)
예제 #9
0
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)
예제 #10
0
 def start_listening(self, bot):
     for configuration in self.configuration:
         plugins.start_asyncio_task(self.telegram_longpoll, configuration)
예제 #11
0
 def _start_sinks(self, bot):
     plugins.start_asyncio_task(self.telegram_longpoll)
예제 #12
0
 def _start_sinks(self, bot):
     plugins.start_asyncio_task(self.telegram_longpoll)
예제 #13
0
 def start_listening(self, bot):
     for configuration in self.configuration:
         plugins.start_asyncio_task(self.telegram_longpoll, configuration)
예제 #14
0
def _initialise(bot):
    plugins.register_handler(_handle_weather, type="message")
    plugins.register_admin_command(["weather", "runcode"])
    plugins.start_asyncio_task(_delay_notify_admins, bot)