示例#1
0
    def __init__(self, word_completer, messaging):
        self.author_observer = AuthorObserver(self)

        messaging.chatter.subscribe(self.author_observer)
        self.authors = _LRUCache(100, _add_word(word_completer),
                                 _remove_word(word_completer))
        self.author_metadata = _LRUCache(100)
        self.metadata_words = [
            'channel',
        ]
示例#2
0
    def __init__(self, word_completer, messaging):
        self.service_observer = ServiceObserver(self)
        messaging.chatter.subscribe(self.service_observer)

        self.services = set()
        self.channels = _LRUCache(100, _add_word(word_completer),
                                  _remove_word(word_completer))
示例#3
0
    def __init__(self, application=None):
        super().__init__()
        # NOTE: if this raises an error, then the instantion is incorrect.
        # Need to instantiate the application before the print observer
        output = application.output

        colors = ('af8700', '5f5faf', '0087ff', '2aa198', '5f8700')
        self.colors = [_get_attributes(output, color) for color in colors]
        self._grey = _get_attributes(output, 'ansidarkgray')
        self.num_colors = len(self.colors)

        self._author_color = _LRUCache(100)
        # NOTE: vt100 ONLY
        self._reset_color = '\033[0m'
        self._time_format = "%H:%M"
示例#4
0
    def __init__(self, botname: str = 'vexbot', **kwargs):
        """
        `kwargs`:
            protocol:   'tcp'
            address: '*'
            chatter_publish_port: 4000
            chatter_subscription_port: [4001,]
            command_port: 4002
            request_port: 4003
            control_port: 4005
        """
        # Defaults. Can be overriden by the use of `kwargs`
        self.config = _get_default_port_config()
        # override the default with the `kwargs`
        self.config = {**self.config, **kwargs}
        self._service_name = botname
        self._logger = logging.getLogger(__name__)
        self._messaging_logger = MessagingLogger(botname)
        self.uuid = str(uuid.uuid1())
        self._logger.info(' uuid: %s', self.uuid)

        self.subscription_socket = None
        self.publish_socket = None
        self.command_socket = None
        self.control_socket = None
        self.request_socket = None
        self.pub_handler = LoopPubHandler(self)

        self.loop = IOLoop()
        self.scheduler = Scheduler()
        self._heartbeat_helper = _HeartbeatHelper(messaging=self,
                                                  loop=self.loop)

        # Socket factory keeps the zmq context, default address and
        # protocol for socket creation.
        self._socket_factory = _SocketFactory(self.config['address'],
                                              self.config['protocol'],
                                              logger=self._logger,
                                              loop=self.loop)

        # converts from ports to zmq ip addresses
        self._config_convert_to_address_helper()
        self._address_map = _LRUCache(100)

        self.control = _Subject()
        self.command = _Subject()
        self.chatter = _Subject()