<commit_before>from twisted.internet import reactor
from twisted.plugin import IPlugin
from twisted.python import log
from txircd.module_interface import IModuleData
from txircd.user import LocalUser
from txircd.utils import isValidNick, ircLower
from zope.interface import implements
import re

from dbservice import DBService


def getDonorID(user):
    """Helper function that returns the user's authenticated donor ID,
    or None if not authenticated."""
    return user.cache.get("accountid", None)


class NickServ(DBService):
    implements(IPlugin, IModuleData)

    name = "NickServ"

    user_cmd_aliases = {
        "NS": (10, None),
        "GHOST": (10, "GHOST"),
        "ID": (10, "IDENTIFY"),
        "IDENTIFY": (10, "IDENTIFY"),
    }

    help = ("NickServ matches your IRC nickname to your Donor account, allowing for a painless auction process, "
           "as well as the peace of mind that nobody can use your nickname but you.\n"
           "You can run these commands with \x02/ns COMMAND\x02.")

    def load(self):
        super(NickServ, self).load()
        # Some explanation of the flow of checking a user's nick and how it works:
        # A nick check is started by a user registering, changing nick, logging out, or at module load.
        # A DB query and a timer are both started.
        # If the DB query shows that the nick is not protected, or that the user owns it, the timer is cancelled.
        # Once both the DB query and the timer have completed, the final conditions are checked:
        #     That the user does not own the nick
        #     That the user has not changed nicks again during this time
        # then the user's nick is forced to change.
        # This dict maps (user, nick) to (timer, owners), where owners is a list of owning donorIDs,
        # or None if not known yet (note that an empty list means nick is unowned).
        # Note that if checkNick tries to start a check on an already pending (user, nick),<commit_msg>Add NICKSERV as a command alias to nickserv<commit_after>from twisted.internet import reactor
from twisted.plugin import IPlugin
from twisted.python import log
from txircd.module_interface import IModuleData
from txircd.user import LocalUser
from txircd.utils import isValidNick, ircLower
from zope.interface import implements
import re

from dbservice import DBService


def getDonorID(user):
    """Helper function that returns the user's authenticated donor ID,
    or None if not authenticated."""
    return user.cache.get("accountid", None)


class NickServ(DBService):
    implements(IPlugin, IModuleData)

    name = "NickServ"

    user_cmd_aliases = {
        "NS": (10, None),
        "NICKSERV": (10, None),
        "GHOST": (10, "GHOST"),
        "ID": (10, "IDENTIFY"),
        "IDENTIFY": (10, "IDENTIFY"),
    }

    help = ("NickServ matches your IRC nickname to your Donor account, allowing for a painless auction process, "
           "as well as the peace of mind that nobody can use your nickname but you.\n"
           "You can run these commands with \x02/ns COMMAND\x02.")

    def load(self):
        super(NickServ, self).load()
        # Some explanation of the flow of checking a user's nick and how it works:
        # A nick check is started by a user registering, changing nick, logging out, or at module load.
        # A DB query and a timer are both started.
        # If the DB query shows that the nick is not protected, or that the user owns it, the timer is cancelled.
        # Once both the DB query and the timer have completed, the final conditions are checked:
        #     That the user does not own the nick
        #     That the user has not changed nicks again during this time
        # then the user's nick is forced to change.
        # This dict maps (user, nick) to (timer, owners), where owners is a list of owning donorIDs,
        # or None if not known yet (note that an empty list means nick is unowned).
        # Note that if checkNick tries to start a check on an already pending (user, nick),
{'fraction_non_alphanumeric': 0.07188735177865613, 'fraction_numerical': 0.006422924901185771, 'mean_word_length': 2.92725509214355, 'pattern_counts': {'":': 9, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1529612', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1077, 'n_words': 539}