Exemplo n.º 1
0
 def _join_room(self, room):
     if isinstance(room, (tuple, list)):
         room_name = compat_str(room[0])
         room_password = compat_str(room[1])
         room, username, password = (room_name, self.bot_config.CHATROOM_FN,
                                     room_password)
         self.log.info(
             "Joining room {} with username {} and password".format(
                 room, username))
     else:
         room_name = compat_str(room)
         room, username, password = (room_name, self.bot_config.CHATROOM_FN,
                                     None)
         self.log.info("Joining room {} with username {}".format(
             room, username))
     try:
         self.query_room(room).join(username=self.bot_config.CHATROOM_FN,
                                    password=password)
     except NotImplementedError:
         # Backward compatibility for backends which do not yet have a
         # query_room implementation and still have a join_room method.
         logging.warning(
             "query_room not implemented on this backend, using legacy join_room instead"
         )
         self.join_room(room, username=username, password=password)
Exemplo n.º 2
0
def glob(text, patterns):
    """
    Match text against the list of patterns according to unix glob rules.
    Return True if a match is found, False otherwise.
    """
    if is_str(patterns):
        patterns = (patterns,)
    return any(fnmatch.fnmatchcase(compat_str(text), compat_str(pattern)) for pattern in patterns)
Exemplo n.º 3
0
 def _join_room(self, room):
     if isinstance(room, (tuple, list)):
         room_name = compat_str(room[0])
         room_password = compat_str(room[1])
         room, username, password = (room_name, self.bot_config.CHATROOM_FN, room_password)
         self.log.info("Joining room {} with username {} and password".format(room, username))
     else:
         room_name = compat_str(room)
         room, username, password = (room_name, self.bot_config.CHATROOM_FN, None)
         self.log.info("Joining room {} with username {}".format(room, username))
         self.query_room(room).join(username=self.bot_config.CHATROOM_FN, password=password)
Exemplo n.º 4
0
    def __init__(self,
                 body: str = '',
                 frm: Identifier = None,
                 to: Identifier = None,
                 delayed: bool = False,
                 extras: Mapping = None,
                 flow=None):
        """
        :param body:
            The plaintext body of the message.
        :param extras:
            Extra data attached by a backend
        :param flow:
            The flow in which this message has been triggered.
        """
        self._body = compat_str(body)
        self._from = frm
        self._to = to
        self._delayed = delayed
        self._extras = extras or dict()
        self._flow = flow

        # Convenience shortcut to the flow context
        if flow:
            self.ctx = flow.ctx
        else:
            self.ctx = {}
Exemplo n.º 5
0
Arquivo: base.py Projeto: Adman/errbot
    def __init__(self,
                 body: str='',
                 frm: Identifier=None,
                 to: Identifier=None,
                 delayed: bool=False,
                 extras: Mapping=None,
                 flow=None):
        """
        :param body:
            The plaintext body of the message.
        :param extras:
            Extra data attached by a backend
        :param flow:
            The flow in which this message has been triggered.
        """
        self._body = compat_str(body)
        self._from = frm
        self._to = to
        self._delayed = delayed
        self._extras = extras or dict()
        self._flow = flow

        # Convenience shortcut to the flow context
        if flow:
            self.ctx = flow.ctx
        else:
            self.ctx = {}
Exemplo n.º 6
0
 def _join_room(self, room):
     if isinstance(room, (tuple, list)):
         room_name = compat_str(room[0])
         room_password = compat_str(room[1])
         room, username, password = (room_name, self.bot_config.CHATROOM_FN,
                                     room_password)
         self.log.info(
             "Joining room {} with username {} and password".format(
                 room, username))
     else:
         room_name = compat_str(room)
         room, username, password = (room_name, self.bot_config.CHATROOM_FN,
                                     None)
         self.log.info("Joining room {} with username {}".format(
             room, username))
         self.query_room(room).join(username=self.bot_config.CHATROOM_FN,
                                    password=password)
Exemplo n.º 7
0
 def _join_room(self, room):
     if isinstance(room, (tuple, list)):
         room_name = compat_str(room[0])
         room_password = compat_str(room[1])
         room, username, password = (room_name, self.bot_config.CHATROOM_FN, room_password)
         self.log.info("Joining room {} with username {} and password".format(room, username))
     else:
         room_name = compat_str(room)
         room, username, password = (room_name, self.bot_config.CHATROOM_FN, None)
         self.log.info("Joining room {} with username {}".format(room, username))
     try:
         self.query_room(room).join(username=self.bot_config.CHATROOM_FN, password=password)
     except NotImplementedError:
         # Backward compatibility for backends which do not yet have a
         # query_room implementation and still have a join_room method.
         logging.warning("query_room not implemented on this backend, using legacy join_room instead")
         self.join_room(room, username=username, password=password)
Exemplo n.º 8
0
    def keys(self):

        keys = self.redis.keys(pattern=self._all_keys)
        filtered_keys = []

        for key in keys:
            log.debug('Key: (pre-filter): {0}'.format(key))
            key = compat_str(key)
            filtered_keys.append(key.split(self.ns_prefix)[1])

        log.debug('Keys: %s' % filtered_keys)
        return filtered_keys
Exemplo n.º 9
0
Arquivo: base.py Projeto: jjahraus/err
 def __init__(self, body='', type_='chat', frm=None, to=None, delayed=False):
     """
     :param body:
         The plaintext body of the message.
     :param type_:
         The type of message (generally one of either 'chat' or 'groupchat').
     """
     self._body = compat_str(body)
     self._type = type_
     self._from = frm
     self._to = to
     self._delayed = delayed
Exemplo n.º 10
0
Arquivo: base.py Projeto: gsass/err
 def __init__(self, body="", type_="chat", frm=None, to=None, delayed=False, extras=None):
     """
     :param body:
         The plaintext body of the message.
     :param type_:
         The type of message (generally one of either 'chat' or 'groupchat').
     :param extras:
         Extra data attached by a backend
     """
     self._body = compat_str(body)
     self._type = type_
     self._from = frm
     self._to = to
     self._delayed = delayed
     self._extras = extras or dict()
Exemplo n.º 11
0
Arquivo: base.py Projeto: Synforge/err
 def __init__(self,
              body: str='',
              frm: Identifier=None,
              to: Identifier=None,
              delayed: bool=False,
              extras: Mapping=None):
     """
     :param body:
         The plaintext body of the message.
     :param extras:
         Extra data attached by a backend
     """
     self._body = compat_str(body)
     self._from = frm
     self._to = to
     self._delayed = delayed
     self._extras = extras or dict()
Exemplo n.º 12
0
 def __init__(self,
              body='',
              type_='chat',
              frm=None,
              to=None,
              delayed=False):
     """
     :param body:
         The plaintext body of the message.
     :param type_:
         The type of message (generally one of either 'chat' or 'groupchat').
     """
     self._body = compat_str(body)
     self._type = type_
     self._from = frm
     self._to = to
     self._delayed = delayed
Exemplo n.º 13
0
 def callback_connect(self):
     log.info('Callback_connect')
     if not self.connected:
         self.connected = True
         for room in self.bot_config.CHATROOM_PRESENCE:
             log.debug('Try to join room %s' % repr(room))
             room_name = compat_str(room)
             if room_name is not None:
                 room, username, password = (room_name, self.bot_config.CHATROOM_FN, None)
             else:
                 room, username, password = (room[0], self.bot_config.CHATROOM_FN, room[1])
             log.info("Joining room {} with username {}".format(room, username))
             try:
                 self.query_room(room).join(username=self.bot_config.CHATROOM_FN, password=password)
             except NotImplementedError:
                 # Backward compatibility for backends which do not yet have a
                 # query_room implementation and still have a join_room method.
                 logging.warning("query_room not implemented on this backend, using legacy join_room instead")
                 self.join_room(room, username=username, password=password)
Exemplo n.º 14
0
 def __init__(
     self,
     body: str = "",
     frm: Identifier = None,
     to: Identifier = None,
     delayed: bool = False,
     extras: Mapping = None,
 ):
     """
     :param body:
         The plaintext body of the message.
     :param extras:
         Extra data attached by a backend
     """
     self._body = compat_str(body)
     self._from = frm
     self._to = to
     self._delayed = delayed
     self._extras = extras or dict()
Exemplo n.º 15
0
Arquivo: base.py Projeto: Kromey/err
 def __init__(self,
              body='',
              type_='chat',
              frm=None,
              to=None,
              delayed=False,
              extras=None):
     """
     :param body:
         The plaintext body of the message.
     :param type_:
         The type of message (generally one of either 'chat' or 'groupchat').
     :param extras:
         Extra data attached by a backend
     """
     self._body = compat_str(body)
     self._type = type_
     self._from = frm
     self._to = to
     self._delayed = delayed
     self._extras = extras or dict()
Exemplo n.º 16
0
 def _make_nskey(self, key):
     return ':'.join((GLOBAL_PREFIX, self.ns, compat_str(key)))
Exemplo n.º 17
0
 def _make_nskey(self, key):
     return ':'.join((GLOBAL_PREFIX, self.ns, compat_str(key)))