예제 #1
0
    def _on_connect(self, initial_data):
        """handle connection/reconnection"""

        logging.debug("connected")

        self._handlers = handlers.EventHandler(self)
        handlers.handler.set_bot(self) # shim for handler decorator

        self._user_list = yield from hangups.user.build_user_list(self._client,
                                                                  initial_data)

        self._conv_list = hangups.ConversationList(self._client,
                                                   initial_data.conversation_states,
                                                   self._user_list,
                                                   initial_data.sync_timestamp)

        self.conversations = yield from permamem.initialise_permanent_memory(self)
        self.tags = tagging.tags(self)

        plugins.load(self, command)

        self._conv_list.on_event.add_observer(self._on_event)
        self._client.on_state_update.add_observer(self._on_status_changes)

        logging.info("bot initialised")
예제 #2
0
    def _on_connect(self, initial_data):
        """handle connection/reconnection"""

        logging.debug("connected")

        self._handlers = handlers.EventHandler(self)
        handlers.handler.set_bot(self)  # shim for handler decorator

        self._user_list = yield from hangups.user.build_user_list(
            self._client, initial_data)

        self._conv_list = hangups.ConversationList(
            self._client, initial_data.conversation_states, self._user_list,
            initial_data.sync_timestamp)

        self.conversations = yield from permamem.initialise_permanent_memory(
            self)
        self.tags = tagging.tags(self)

        plugins.load(self, command)

        self._conv_list.on_event.add_observer(self._on_event)
        self._client.on_state_update.add_observer(self._on_status_changes)

        logging.info("bot initialised")
예제 #3
0
    async def _on_connect(self):
        """handle connection"""

        def _retry_reset(dummy):
            """schedule a retry counter reset

            Args:
                dummy: hangups.conversation_event.ConversationEvent instance
            """
            async def _delayed_reset():
                """delayed reset of the retry count"""
                try:
                    await asyncio.sleep(self._max_retries)
                except asyncio.CancelledError:
                    return
                self.__retry = 1

            if (self.__retry > 1 and
                    (self.__retry_reset is None or self.__retry_reset.done())):
                self.__retry_reset = asyncio.ensure_future(_delayed_reset())

        logger.debug("connected")

        self.shared = {}
        self.tags = tagging.tags(self)
        self._handlers = handlers.EventHandler(self)
        handlers.handler.set_bot(self) # shim for handler decorator

        # monkeypatch plugins go heere
        # # plugins.load(self, "monkeypatch.something")
        # use only in extreme circumstances
        #  e.g. adding new functionality into hangups library

        self._user_list, self._conv_list = (
            await hangups.build_user_conversation_list(self._client))

        self._conv_list.on_event.add_observer(_retry_reset)

        self.conversations = await permamem.initialise(self)

        # init the shareds, start caches for reprocessing and start listening
        await self._handlers.setup(self._conv_list)

        await plugins.load(self, "commands.plugincontrol")
        await plugins.load(self, "commands.alias")
        await plugins.load(self, "commands.basic")
        await plugins.load(self, "commands.tagging")
        await plugins.load(self, "commands.permamem")
        await plugins.load(self, "commands.convid")
        await plugins.load(self, "commands.loggertochat")
        await plugins.load_user_plugins(self)

        logger.warning("bot initialised")
        sys.stdout.write("\x1b]2;HangupsBot: %s\x07"
                         % self.user_self()["full_name"])
예제 #4
0
    def _on_connect(self):
        """handle connection/reconnection"""

        logger.debug("connected")

        plugins.tracking.set_bot(self)
        command.set_tracking(plugins.tracking)
        command.set_bot(self)

        self.tags = tagging.tags(self)
        self._handlers = handlers.EventHandler(self)
        handlers.handler.set_bot(self) # shim for handler decorator

        """
        monkeypatch plugins go heere
        # plugins.load(self, "monkeypatch.something")
        use only in extreme circumstances e.g. adding new functionality into hangups library
        """

        #self._user_list = yield from hangups.user.build_user_list(self._client)

        self._user_list, self._conv_list = (
            yield from hangups.build_user_conversation_list(self._client)
        )

        self.conversations = yield from permamem.initialise_permanent_memory(self)

        plugins.load(self, "commands.plugincontrol")
        plugins.load(self, "commands.basic")
        plugins.load(self, "commands.tagging")
        plugins.load(self, "commands.permamem")
        plugins.load(self, "commands.convid")
        plugins.load(self, "commands.loggertochat")
        plugins.load_user_plugins(self)

        self._conv_list.on_event.add_observer(self._on_event)
        self._client.on_state_update.add_observer(self._on_status_changes)

        logger.info("bot initialised")
예제 #5
0
    def _on_connect(self, initial_data):
        """handle connection/reconnection"""

        logger.debug("connected")

        plugins.tracking.set_bot(self)
        command.set_tracking(plugins.tracking)
        command.set_bot(self)

        self.tags = tagging.tags(self)
        self._handlers = handlers.EventHandler(self)
        handlers.handler.set_bot(self)  # shim for handler decorator

        plugins.load(self, "monkeypatch.otr_support")

        self._user_list = yield from hangups.user.build_user_list(self._client,
                                                                  initial_data)

        self._conv_list = hangups.ConversationList(self._client,
                                                   initial_data.conversation_states,
                                                   self._user_list,
                                                   initial_data.sync_timestamp)

        self.conversations = yield from permamem.initialise_permanent_memory(self)

        plugins.load(self, "commands.plugincontrol")
        plugins.load(self, "commands.basic")
        plugins.load(self, "commands.tagging")
        plugins.load(self, "commands.permamem")
        plugins.load(self, "commands.convid")
        plugins.load(self, "commands.loggertochat")
        plugins.load_user_plugins(self)

        self._conv_list.on_event.add_observer(self._on_event)
        self._client.on_state_update.add_observer(self._on_status_changes)

        logger.info("bot initialised")
        yield from self.coro_send_message(CONTROL, _("Bot is back up"))
    def _on_connect(self):
        """handle connection/reconnection"""

        logger.debug("connected")

        plugins.tracking.set_bot(self)
        command.set_tracking(plugins.tracking)
        command.set_bot(self)

        self.tags = tagging.tags(self)
        self._handlers = handlers.EventHandler(self)
        handlers.handler.set_bot(self)  # shim for handler decorator
        """
        monkeypatch plugins go heere
        # plugins.load(self, "monkeypatch.something")
        use only in extreme circumstances e.g. adding new functionality into hangups library
        """

        #self._user_list = yield from hangups.user.build_user_list(self._client)

        self._user_list, self._conv_list = (
            yield from hangups.build_user_conversation_list(self._client))

        self.conversations = yield from permamem.initialise_permanent_memory(
            self)

        plugins.load(self, "commands.plugincontrol")
        plugins.load(self, "commands.basic")
        plugins.load(self, "commands.tagging")
        plugins.load(self, "commands.permamem")
        plugins.load(self, "commands.convid")
        plugins.load(self, "commands.loggertochat")
        plugins.load_user_plugins(self)

        self._conv_list.on_event.add_observer(self._on_event)
        self._client.on_state_update.add_observer(self._on_status_changes)

        logger.info("bot initialised")
예제 #7
0
    def _on_connect(self, initial_data):
        """handle connection/reconnection"""

        logger.debug("connected")

        plugins.tracking.set_bot(self)
        command.set_tracking(plugins.tracking)
        command.set_bot(self)

        self.tags = tagging.tags(self)
        self._handlers = handlers.EventHandler(self)
        handlers.handler.set_bot(self)  # shim for handler decorator

        plugins.load(self, "monkeypatch.otr_support")

        self._user_list = yield from hangups.user.build_user_list(
            self._client, initial_data)

        self._conv_list = hangups.ConversationList(
            self._client, initial_data.conversation_states, self._user_list,
            initial_data.sync_timestamp)

        self.conversations = yield from permamem.initialise_permanent_memory(
            self)

        plugins.load(self, "commands.plugincontrol")
        plugins.load(self, "commands.basic")
        plugins.load(self, "commands.tagging")
        plugins.load(self, "commands.permamem")
        plugins.load(self, "commands.convid")
        plugins.load(self, "commands.loggertochat")
        plugins.load_user_plugins(self)

        self._conv_list.on_event.add_observer(self._on_event)
        self._client.on_state_update.add_observer(self._on_status_changes)

        logger.info("bot initialised")