Return the identifier used to address this bot in this message.
        If one is not found, return None.

        :param message: a message dict from the slack api.
777785
def _bot_identifier(self, message):
        

        text = message['text']

        formatters = [
            lambda identifier: "%s " % identifier,
            lambda identifier: "%s:" % identifier,
        ]
        my_identifiers = [formatter(identifier) for identifier in [self.name, self.my_mention] for formatter in formatters]

        for identifier in my_identifiers:
            if text.startswith(identifier):
                self.log.debug("sent to me:\n%s", pprint.pformat(message))
                return identifier

        return None
425643
def defines(self, id, domain='messages'):
        
        assert isinstance(id, (str, unicode))
        assert isinstance(domain, (str, unicode))

        return id in self.messages.get(domain, {})
590139
def _identify_prefix(self, msg, data):
        '''
        
        '''
        prefix_id = -1
        for prefix in data:
            msg_dict = {}
            prefix_id += 1
            match = None
            if '__python_fun__' in prefix:
                log.debug('Trying to match using the %s custom python profiler', prefix['__python_mod__'])
                try:
                    match = prefix['__python_fun__'](msg)
                except Exception:
                    log.error('Exception while parsing %s with the %s python profiler',
                              msg, prefix['__python_mod__'], exc_info=True)
            else:
                log.debug('Matching using YAML-defined profiler:')
                log.debug(prefix['raw_prefix'])
                match = prefix['prefix'].search(msg)
            if not match:
                log.debug('Match not found')
                continue
            if '__python_fun__' in prefix:
                log.debug('%s matched using the custom python profiler %s', msg, prefix['__python_mod__'])
                msg_dict = match  # the output as-is from the custom function
            else:
                positions = prefix.get('prefix_positions', {})
                values = prefix.get('values')
                msg_dict = {}
                for key in values.keys():
                    msg_dict[key] = match.group(positions.get(key))
            # Remove whitespace from the start or end of the message
            msg_dict['__prefix_id__'] = prefix_id
            msg_dict['message'] = msg_dict['message'].strip()

            # The pri has to be an int as it is retrived using regex '\<(\d+)\>'
            if 'pri' in msg_dict:
                msg_dict['facility'] = int(int(msg_dict['pri']) / 8)
                msg_dict['severity'] = int(int(msg_dict['pri']) - (msg_dict['facility'] * 8))
            return msg_dict
326728
def _parse_metadata(self, message):
        '''
        '''

        # Try to handle all the fields of events we care about.
        metadata = Metadata(source=self.actor_urn).__dict__
        metadata['thread_ts'] = message.get('thread_ts')
        if 'presence' in message:
            metadata['presence'] = message['presence']

        if 'text' in message:
            metadata['text'] = message['text']
        elif 'previous_message' in message:
            # Try to handle slack links
            if 'text' in message['previous_message']:
                metadata['text'] = message['previous_message']['text']
            else:
                metadata['text'] = None
        else:
            metadata['text'] = None

        if 'user' in message:
            metadata['source_user'] = message['user']
        elif 'bot_id' in message:
            metadata['source_user'] = self.get_userid_from_botid(
                                      message['bot_id'])
        elif 'message' in message and 'user' in message['message']:
            metadata['source_user'] = message['message']['user']
        else:
            metadata['source_user'] = None

        metadata['user_id'] = metadata['source_user']
        metadata['display_name'] = self.get_username(metadata['source_user'])

        if 'channel' in message:
            metadata['source_channel'] = message['channel']
            # Slack starts DM channel IDs with "D"
            if message['channel'].startswith('D'):
                metadata['is_private_message'] = True
            else:
                metadata['is_private_message'] = False

        metadata['source_connector'] = 'slack'

        return metadata
1301572
def _messageFromSender(self, sender, messageID):
        
        return self.store.findUnique(
            _QueuedMessage,
            AND(_QueuedMessage.senderUsername == sender.localpart,
                _QueuedMessage.senderDomain == sender.domain,
                _QueuedMessage.messageID == messageID),
            default=None)
27452
def get(self, id, domain='messages'):
        
        assert isinstance(id, (str, unicode))
        assert isinstance(domain, (str, unicode))

        if self.defines(id, domain):
            return self.messages[domain][id]

        if self.fallback_catalogue is not None:
            return self.fallback_catalogue.get(id, domain)

        return id
1141174
def sign(self, message):
		
		return hmac.HMAC(self.key, message, digestmod=hashlib.md5).digest()
313109
async def get_reply_message(self):
        
        if self._reply_message is None:
            if not self.reply_to_msg_id:
                return None

            # Bots cannot access other bots' messages by their ID.
            # However they can access them through replies...
            self._reply_message = await self._client.get_messages(
                await self.get_input_chat() if self.is_channel else None,
                ids=types.InputMessageReplyTo(self.id)
            )
            if not self._reply_message:
                # ...unless the current message got deleted.
                #
                # If that's the case, give it a second chance accessing
                # directly by its ID.
                self._reply_message = await self._client.get_messages(
                    self._input_chat if self.is_channel else None,
                    ids=self.reply_to_msg_id
                )

        return self._reply_message
566579
def make_msg_id():
    
    random_string = get_rand_string(12)
    timestamp = time.strftime("%Y%m%d%I%M%S")
    msg_id = timestamp + "-" + random_string
    return msg_id
1225495
def do_IDENT(self, service_name: str, source: list, *args, **kwargs) -> None:
        
        self.logger.info(' IDENT %s as %s', service_name, source)
        self.messaging._address_map[service_name] = source
1246606
def message(message, title=''):
    
    return backend_api.opendialog("message", dict(message=message, title=title))
599522
def get_member_slackuid(self, slack):
        
        members = self.__con__.search_s(
            CSHMember.__ldap_user_ou__,
            ldap.SCOPE_SUBTREE,
            "(slackuid=%s)" % slack,
            ['ipaUniqueID'])
        if members:
            return CSHMember(
                    self,
                    members[0][1]['ipaUniqueID'][0].decode('utf-8'),
                    False)
        return None
603313
def message_identification=(value)
      raise ArgumentError.new('message_identification must be a string!') unless value.is_a?(String)

      regex = /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\'|\ ]){1,35}\z/
      raise ArgumentError.new("message_identification does not match #{regex}!") unless value.match(regex)

      @message_identification = value
    end
1043866
def message_received(self, message):
        """"""
        # If the message identifer is outstanding, then someone is
        # waiting for the respone so we save it here
        identifier = message.identifier or 'type_' + str(message.type)
        if identifier in self._outstanding:
            outstanding = OutstandingMessage(
                self._outstanding[identifier].semaphore, message)
            self._outstanding[identifier] = outstanding
            self._outstanding[identifier].semaphore.release()
        else:
            asyncio.ensure_future(self._dispatch(message), loop=self.loop)
731397
def info(self, message, domain=None):
        
        if domain is None:
            domain = self.extension_name
        info(message, domain)
836384
async def on_raw_311(self, message):
        
        target, nickname, username, hostname, _, realname = message.params
        info = {
            'username': username,
            'hostname': hostname,
            'realname': realname
        }

        self._sync_user(nickname, info)
        if nickname in self._pending['whois']:
            self._whois_info[nickname].update(info)
852431
def messaging(self):
        
        if self._messaging is None:
            from twilio.rest.messaging import Messaging
            self._messaging = Messaging(self)
        return self._messaging