'Apply nick replacement of entries in raw_string with nick replacement.
Args:
raw_string (str): The string in which to perform nick
replacement.
categories (tuple, optional): Replacement categories in
which to perform the replacement, such as "inputline",
"channel" etc.
include_player (bool, optional): Also include replacement
with nicks stored on the Player level.
kwargs (any, optional): Not used.
Returns:
string (str): A string with matching keys replaced with
their nick equivalents.'

def nickreplace(self, raw_string, categories=('inputline', 'channel'), include_player=True):

    nicks = {}
    for category in make_iter(categories):
        nicks.update({nick.key: nick for nick in make_iter(self.get(category=category, return_obj=True)) if (nick and nick.key)})
    if (include_player and self.obj.has_player):
        for category in make_iter(categories):
            nicks.update({nick.key: nick for nick in make_iter(self.obj.player.nicks.get(category=category, return_obj=True)) if (nick and nick.key)})
    for (key, nick) in nicks.iteritems():
        (nick_regex, template, _, _) = nick.value
        regex = self._regex_cache.get(nick_regex)
        if (not regex):
            regex = re.compile(nick_regex, ((re.I + re.DOTALL) + re.U))
            self._regex_cache[nick_regex] = regex
        (is_match, raw_string) = parse_nick_template(raw_string.strip(), regex, template)
        if is_match:
            break
    return raw_string
