Checks if the bot was called by a user.
        Returns the suffix if so.

        Prefixes include the bot's nick as well as a set symbol.
345426
def _strip_prefix(self, message):
        

        if not hasattr(self, "name_regex"):
            """
            regex example:
            ^(((BotA|BotB)[,:]?\s+)|%)(.+)$
            
            names = [BotA, BotB]
            prefix = %
            """

            names = self.config['names']
            prefix = self.config['prefix']

            name_regex_str = r'^(?:(?:(%s)[,:]?\s+)|%s)(.+)$' % (re.escape("|".join(names)), prefix)
            self.name_regex = re.compile(name_regex_str, re.IGNORECASE)

        search = self.name_regex.search(message)
        if search:
            return search.groups()[1]

        return None
732232
def _key(self, username, frozen=False):
        """"""
        if frozen:
            return self.frozen + username
        return self.prefix + username
541619
def add_user(self, nick, prefixes=None):
        """"""
        if nick not in self._user_nicks:
            self._user_nicks.append(nick)

        self.prefixes[nick] = prefixes
956090
def get_suffix(name):
    
    a = name.count(".")
    if a:
        ext = name.split(".")[-1]
        if ext in LANGS.keys():
            return ext
        return False
    else:
        return False
336116
def nick=(nick)
      success = Utils.call_executable_returning_status(
        '-i', id, '--nick', nick, '--update'
      )
      unless success
        raise Error, "Unable to set nickname for interface (#{id}). " \
                    'Please make sure the vnstat daemon is not running while ' \
                    'performing this operation.'
      end
      @nick = nick
    end
135593
def _parse_nicknameinuse(client, command, actor, args):
    
    nick, _, _ = args.rpartition(" ")
    client.dispatch_event("NICKNAMEINUSE", nick)
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
815877
async def FindActionTagsByPrefix(self, prefixes):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Action',
                   request='FindActionTagsByPrefix',
                   version=3,
                   params=_params)
        _params['prefixes'] = prefixes
        reply = await self.rpc(msg)
        return reply
798642
def umode(self, nick, modes=''):
        
        with self.lock:
            if not modes:
                self.send('MODE %s' % nick)
                if self.readable():
                    msg = self._recv(expected_replies=('221',))
                    if msg[0] == '221':
                        modes = msg[2].replace('+', '').replace(':', '', 1)
                return modes

            self.send('MODE %s %s' % (nick, modes))

            if self.readable():
                msg = self._recv(expected_replies=('MODE',))
                if msg[0] == 'MODE':
                    if not self.hide_called_events:
                        self.stepback()
                    return msg[2].replace(':', '', 1)
238429
def _is_suffix(self, t):
        """"""
        return t not in NOT_SUFFIX and (t.replace('.', '') in SUFFIXES or t.replace('.', '') in SUFFIXES_LOWER)
551372
def keys_with_suffix(self, suffix):
        
        return [k.rstrip(suffix) for k in self.keys() if k.endswith(suffix)]
670223
function () {
        var user_prefixes = this.get('user_prefixes'),
            modes = this.get('modes'),
            o, max_mode;

        if (modes.length > 0) {
            o = _.indexOf(user_prefixes, _.find(user_prefixes, function (prefix) {
                return prefix.mode === 'o';
            }));

            max_mode = _.indexOf(user_prefixes, _.find(user_prefixes, function (prefix) {
                return prefix.mode === modes[0];
            }));

            if ((max_mode === -1) || (max_mode > o)) {
                this.set({"is_op": false}, {silent: true});
            } else {
                this.set({"is_op": true}, {silent: true});
            }

        } else {
            this.set({"is_op": false}, {silent: true});
        }
    }
552060
def _is_bot(user_agent):
    """"""
    bot_list = [
                'http://www.baidu.com/search/spider.html',
                'python-requests',
                'http://ltx71.com/',
                'http://drupal.org/',
                'www.sogou.com',
                'http://search.msn.com/msnbot.htm',
                'semantic-visions.com crawler',
               ]
    for bot in bot_list:
        if re.search(re.escape(bot), user_agent):
            return True
    return False
1182410
def get_prefix(self, form, name):
        
        return '{form_prefix}{prefix_name}-{field_name}'.format(
            form_prefix=form.prefix + '-' if form.prefix else '',
            prefix_name=self.prefix_name,
            field_name=name)
61397
def regenerate_prefixes(self, *args):
        """"""
        nick = self.controller.client.user.nick
        self.prefixes = set([
            nick + ": ",
            nick + ", ",
            nick + " - ",
        ])
        # Include lower-case versions as well, but not caps
        self.prefixes.update([p.lower() for p in self.prefixes])
        if self.sigil:
            self.prefixes.add(self.sigil)
201693
def get_api_key_with_prefix(self, identifier):
        
        if self.api_key.get(identifier) and self.api_key_prefix.get(identifier):
            return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier]
        elif self.api_key.get(identifier):
            return self.api_key[identifier]
885693
def match_mstring(self, tokens, item, use_bytes=None):
        """"""
        prefix, name, suffix = tokens
        if use_bytes is None:
            if prefix.startswith("b") or suffix.startswith("b"):
                if prefix.startswith("b") and suffix.startswith("b"):
                    use_bytes = True
                else:
                    raise CoconutDeferredSyntaxError("string literals and byte literals cannot be added in patterns", self.loc)
        if use_bytes:
            self.add_check("_coconut.isinstance(" + item + ", _coconut.bytes)")
        else:
            self.add_check("_coconut.isinstance(" + item + ", _coconut.str)")
        if prefix is not None:
            self.add_check(item + ".startswith(" + prefix + ")")
        if suffix is not None:
            self.add_check(item + ".endswith(" + suffix + ")")
        if name != wildcard:
            self.add_def(
                name + " = " + item + "[" +
                ("" if prefix is None else "_coconut.len(" + prefix + ")") + ":"
                + ("" if suffix is None else "-_coconut.len(" + suffix + ")") + "]",
            )