<commit_before># commands.py: base PyLink commands
import time

from pylinkirc import utils, __version__, world, real_version
from pylinkirc.log import log
from pylinkirc.coremods import permissions

from pylinkirc.coremods.login import pwd_context

default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan']}

def main(irc=None):
    """Commands plugin main function, called on plugin load."""
    # Register our permissions.
    permissions.add_default_permissions(default_permissions)

def die(irc=None):
    """Commands plugin die function, called on plugin unload."""
    permissions.remove_default_permissions(default_permissions)

@utils.add_cmd
def status(irc, source, args):
    """takes no arguments.

    Returns your current PyLink login status."""
    permissions.check_permissions(irc, source, ['commands.status'])
    identified = irc.users[source].account
    if identified:
        irc.reply('You are identified as \x02%s\x02.' % identified)
    else:
        irc.reply('You are not identified as anyone.')
    irc.reply('Operator access: \x02%s\x02' % bool(irc.is_oper(source)))

_none = '\x1D(none)\x1D'
@utils.add_cmd
def showuser(irc, source, args):
    """<user>

    Shows information about <user>."""
    permissions.check_permissions(irc, source, ['commands.showuser'])
    try:
        target = args[0]
    except IndexError:
        irc.error("Not enough arguments. Needs 1: nick.")
        return
    u = irc.nick_to_uid(target) or target
    # Only show private info if the person is calling 'showuser' on themselves,
    # or is an oper.
    verbose = irc.is_oper(source) or u == source
    if u not in irc.users:
        irc.error('Unknown user %r.' % target)
        return

    f = lambda s: irc.reply(s, private=True)

    userobj = irc.users[u]
    f('Showing information on user \x02%s\x02 (%s@%s): %s' % (userobj.nick, userobj.ident,
      userobj.host, userobj.realname))

    sid = irc.get_server(u)
    serverobj = irc.servers[sid]
    ts = userobj.ts

    # Show connected server & nick TS
    f('\x02Home server\x02: %s (%s); \x02Nick TS:\x02 %s [UTC] (%s)' % \
      (serverobj.name, sid, time.asctime(time.gmtime(int(ts))), ts))

    if verbose:  # Oper only data: user modes, channels on, account info, etc.

        f('\x02User modes\x02: %s' % irc.join_modes(userobj.modes, sort=True))
        f('\x02Protocol UID\x02: %s; \x02Real host\x02: %s; \x02IP\x02: %s' % \
          (u, userobj.realhost, userobj.ip))
        channels = sorted(userobj.channels)
        f('\x02Channels\x02: %s' % (' '.join(channels) or _none))
        f('\x02PyLink identification\x02: %s; \x02Services account\x02: %s; \x02Away status\x02: %s' % \
          ((userobj.account or _none), (userobj.services_account or _none), userobj.away or _none))


@utils.add_cmd
def showchan(irc, source, args):
    """<channel>

    Shows information about <channel>."""
    permissions.check_permissions(irc, source, ['commands.showchan'])
    try:
        channel = args[0]
    except IndexError:
        irc.error("Not enough arguments. Needs 1: channel.")
        return
    if channel not in irc.channels:
        irc.error('Unknown channel %r.' % channel)
        return

    f = lambda s: irc.reply(s, private=True)

    c = irc.channels[channel]
    # Only show verbose info if caller is oper or is in the target channel.
    verbose = source in c.users or irc.is_oper(source)
    secret = ('s', None) in c.modes
    if secret and not verbose:<commit_msg>commands.showuser: show home server and TS as "N/A" if they are spoofed values<commit_after># commands.py: base PyLink commands
import time

from pylinkirc import utils, __version__, world, real_version
from pylinkirc.log import log
from pylinkirc.coremods import permissions

from pylinkirc.coremods.login import pwd_context

default_permissions = {"*!*@*": ['commands.status', 'commands.showuser', 'commands.showchan']}

def main(irc=None):
    """Commands plugin main function, called on plugin load."""
    # Register our permissions.
    permissions.add_default_permissions(default_permissions)

def die(irc=None):
    """Commands plugin die function, called on plugin unload."""
    permissions.remove_default_permissions(default_permissions)

@utils.add_cmd
def status(irc, source, args):
    """takes no arguments.

    Returns your current PyLink login status."""
    permissions.check_permissions(irc, source, ['commands.status'])
    identified = irc.users[source].account
    if identified:
        irc.reply('You are identified as \x02%s\x02.' % identified)
    else:
        irc.reply('You are not identified as anyone.')
    irc.reply('Operator access: \x02%s\x02' % bool(irc.is_oper(source)))

_none = '\x1D(none)\x1D'
@utils.add_cmd
def showuser(irc, source, args):
    """<user>

    Shows information about <user>."""
    permissions.check_permissions(irc, source, ['commands.showuser'])
    try:
        target = args[0]
    except IndexError:
        irc.error("Not enough arguments. Needs 1: nick.")
        return
    u = irc.nick_to_uid(target) or target
    # Only show private info if the person is calling 'showuser' on themselves,
    # or is an oper.
    verbose = irc.is_oper(source) or u == source
    if u not in irc.users:
        irc.error('Unknown user %r.' % target)
        return

    f = lambda s: irc.reply(s, private=True)

    userobj = irc.users[u]
    f('Showing information on user \x02%s\x02 (%s@%s): %s' % (userobj.nick, userobj.ident,
      userobj.host, userobj.realname))

    sid = irc.get_server(u)
    serverobj = irc.servers[sid]
    ts = userobj.ts

    # Show connected server & nick TS if available
    serverinfo = '%s[%s]' % (serverobj.name, sid) \
        if irc.has_cap('can-track-servers') else 'N/A'
    tsinfo = '%s [UTC] (%s)' % (time.asctime(time.gmtime(int(ts))), ts) \
        if irc.has_cap('has-ts') else 'N/A'
    f('\x02Home server\x02: %s; \x02Nick TS:\x02 %s' % (serverinfo, tsinfo))

    if verbose:  # Oper/self only data: user modes, channels in, account info, etc.
        f('\x02User modes\x02: %s' % irc.join_modes(userobj.modes, sort=True))
        f('\x02Protocol UID\x02: %s; \x02Real host\x02: %s; \x02IP\x02: %s' % \
          (u, userobj.realhost, userobj.ip))
        channels = sorted(userobj.channels)
        f('\x02Channels\x02: %s' % (' '.join(channels) or _none))
        f('\x02PyLink identification\x02: %s; \x02Services account\x02: %s; \x02Away status\x02: %s' % \
          ((userobj.account or _none), (userobj.services_account or _none), userobj.away or _none))


@utils.add_cmd
def showchan(irc, source, args):
    """<channel>

    Shows information about <channel>."""
    permissions.check_permissions(irc, source, ['commands.showchan'])
    try:
        channel = args[0]
    except IndexError:
        irc.error("Not enough arguments. Needs 1: channel.")
        return
    if channel not in irc.channels:
        irc.error('Unknown channel %r.' % channel)
        return

    f = lambda s: irc.reply(s, private=True)

    c = irc.channels[channel]
    # Only show verbose info if caller is oper or is in the target channel.
    verbose = source in c.users or irc.is_oper(source)
    secret = ('s', None) in c.modes
    if secret and not verbose:
{'fraction_non_alphanumeric': 0.1338474249518039, 'fraction_numerical': 0.015973561002478657, 'mean_word_length': 3.220220801859384, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 11, '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': '467964', 'n_tokens_mistral': 2514, 'n_tokens_neox': 2399, 'n_words': 670}