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)
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)
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)
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 = {}
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 = {}
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)
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)
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
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
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()
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()
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)
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()
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()
def _make_nskey(self, key): return ':'.join((GLOBAL_PREFIX, self.ns, compat_str(key)))