<commit_before>#!/usr/bin/env python
"""
admin.py - Willie Admin Module
Copyright 2010-2011, <NAME> (inamidst.com) and <NAME> (yanovich.net)
Licensed under the Eiffel Forum License 2.

http://willie.dfbta.net
"""

import os

def join(willie, trigger):
   """Join the specified channel. This is an admin-only command."""
   # Can only be done in privmsg by an admin
   if trigger.sender.startswith('#'): return
   if trigger.admin:
      channel, key = trigger.group(1), trigger.group(2)
      if not key:
         willie.write(['JOIN'], channel)
      else: willie.write(['JOIN', channel, key])
join.rule = r'\.join (#\S+)(?: *(\S+))?'
join.priority = 'low'
join.example = '.join #example or .join #example key'

def part(phenny, trigger): 
    """Part the specified channel. This is an admin-only command."""
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): return
    if trigger.admin: 
        phenny.write(['PART'], trigger.group(2))
part.commands = ['part']
part.priority = 'low'
part.example = '.part #example'

def quit(phenny, trigger): 
    """Quit from the server. This is an owner-only command."""
    # Can only be done in privmsg by the owner
    if trigger.sender.startswith('#'): return
    if trigger.owner: 
        phenny.write(['QUIT'])
        __import__('os')._exit(0)
quit.commands = ['quit']
quit.priority = 'low'

def msg(phenny, trigger): 
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): return
    a, b = trigger.group(2), trigger.group(3)
    if (not a) or (not b): return
    if trigger.admin: 
        phenny.msg(a, b)
msg.rule = (['msg'], r'(#?\S+) (.+)')
msg.priority = 'low'

def me(phenny, trigger): 
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): return
    if trigger.admin: 
        msg = '\x01ACTION %s\x01' % trigger.group(3)
        phenny.msg(trigger.group(2), msg)
me.rule = (['me'], r'(#?\S+) (.*)')
me.priority = 'low'

def defend_ground(willie, trigger):
    """
    This function monitors all kicks across all channels willie is in. If she
    detects that she is the one kicked she'll automatically join that channel.

    WARNING: This may not be needed and could cause problems if willie becomes
    annoying. Please use this with caution.
    """
    channel = trigger.sender
    willie.write(['JOIN'], channel)
defend_ground.event = 'KICK'
defend_ground.rule = '.*'
defend_ground.priority = 'low'

def mode(willie, trigger):
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): return<commit_msg>[admin] Use core quit, part and join methods instead of callling willie.write directly<commit_after>#!/usr/bin/env python
# coding=utf-8
"""
admin.py - Willie Admin Module
Copyright 2010-2011, <NAME> (inamidst.com) and <NAME> (yanovich.net)
Copyright © 2012, <NAME>, <<EMAIL>>

Licensed under the Eiffel Forum License 2.

http://willie.dfbta.net
"""

import os

def join(willie, trigger):
    """Join the specified channel. This is an admin-only command."""
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): 
        return
    if trigger.admin:
        channel, key = trigger.group(1), trigger.group(2)
        if not key:
            willie.join(channel)
        else: 
            willie.join(channel, key)
join.rule = r'\.join (#\S+)(?: *(\S+))?'
join.priority = 'low'
join.example = '.join #example or .join #example key'

def part(willie, trigger): 
    """Part the specified channel. This is an admin-only command."""
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): 
        return
    if trigger.admin: 
        willie.part(trigger.group(2).strip())
part.commands = ['part']
part.priority = 'low'
part.example = '.part #example'

def quit(willie, trigger): 
    """Quit from the server. This is an owner-only command."""
    # Can only be done in privmsg by the owner
    if trigger.sender.startswith('#'): 
        return
    if trigger.owner:
        quit_message = 'Quitting on command from %s' % trigger.nick
        if trigger.group(2) is not None:
            quit_message = trigger.group(2)
        willie.quit(quit_message)
quit.commands = ['quit']
quit.priority = 'low'

def msg(willie, trigger): 
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): 
        return
    a, b = trigger.group(2), trigger.group(3)
    if (not a) or (not b): 
        return
    if trigger.admin: 
        willie.msg(a, b)
msg.rule = (['msg'], r'(#?\S+) (.+)')
msg.priority = 'low'

def me(willie, trigger): 
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'): 
        return
    if trigger.admin: 
        msg = '\x01ACTION %s\x01' % trigger.group(3)
        willie.msg(trigger.group(2), msg)
me.rule = (['me'], r'(#?\S+) (.*)')
me.priority = 'low'

def defend_ground(willie, trigger):
    """
    This function monitors all kicks across all channels willie is in. If he
    detects that she is the one kicked she'll automatically join that channel.

    WARNING: This may not be needed and could cause problems if willie becomes
    annoying. Please use this with caution.
    """
    channel = trigger.sender
    willie.write(['JOIN'], channel)
defend_ground.event = 'KICK'
defend_ground.rule = '.*'
defend_ground.priority = 'low'

def mode(willie, trigger):
    # Can only be done in privmsg by an admin
    if trigger.sender.startswith('#'):
        return
{'fraction_non_alphanumeric': 0.14199781261392636, 'fraction_numerical': 0.008749544294567991, 'mean_word_length': 3.040500736377025, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '459153', 'n_tokens_mistral': 1818, 'n_tokens_neox': 1730, 'n_words': 579}