예제 #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)
예제 #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)
예제 #3
0
파일: chatRoom.py 프로젝트: Adman/errbot
 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)
예제 #4
0
파일: base.py 프로젝트: ligadous/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 = {}
예제 #5
0
파일: base.py 프로젝트: 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 = {}
예제 #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)
예제 #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)
예제 #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
예제 #9
0
파일: base.py 프로젝트: 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
예제 #10
0
파일: base.py 프로젝트: 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()
예제 #11
0
파일: base.py 프로젝트: 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()
예제 #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
예제 #13
0
파일: chatRoom.py 프로젝트: rroemhild/err
 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)
예제 #14
0
파일: base.py 프로젝트: fernand0/errbot
 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()
예제 #15
0
파일: base.py 프로젝트: 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()
예제 #16
0
 def _make_nskey(self, key):
     return ':'.join((GLOBAL_PREFIX, self.ns, compat_str(key)))
예제 #17
0
 def _make_nskey(self, key):
     return ':'.join((GLOBAL_PREFIX, self.ns, compat_str(key)))