<commit_before>import commands
from config import YAMLConfig
import json
import os
import packetFactory
from packetFactory import SystemMessagePacket
import plugins
whitelist = []

ircSettings = YAMLConfig("cfg/pso2proxy.whitelist.config.yml",
                         {'enabled': True}, True)

whitelistmode = ircSettings.get_key('enabled')


@plugins.on_start_hook
def load_whitelist():
    global whitelist
    if not os.path.exists("cfg/pso2proxy.whitelist.json"):
        f = open("cfg/pso2proxy.whitelist.json", "w")
        f.write(json.dumps(whitelist))
        f.close()
        print('[Whitelist] Blank whitelist created.')
    else:
        f = open("cfg/pso2proxy.whitelist.json", "r")
        whitelist = json.loads(f.read())
        f.close()
        print("[Whitelist] Loaded %i whitelisted SEGA IDs." % len(whitelist))


def save_whitelist():
    f = open("cfg/pso2proxy.whitelist.json", "w")
    f.write(json.dumps(whitelist))
    f.close()
    print('[Whitelist] Saved whitelist.')


@plugins.CommandHook("whitelistmode", "Toggle whitelist mode", True)
class DisableGChat(commands.Command):
    def call_from_client(self, client):
        global whitelistmode
        whitelistmode = not whitelistmode
        if whitelistmode:
            client.send_crypto_packet(packetFactory.SystemMessagePacket("[Whitelist] Whitelist turn on.", 0x3).build())
            return
        else:
            client.send_crypto_packet(packetFactory.SystemMessagePacket("[Whitelist] Whitelist turn off.", 0x3).build())
            return

    def call_from_console(self):
        global whitelistmode
        whitelistmode = not whitelistmode
        if whitelistmode:
            return "[Whitelist] Whitelist turn on."<commit_msg>whitelist: added Admin only tag<commit_after>import commands
from config import YAMLConfig
import json
import os
import packetFactory
from packetFactory import SystemMessagePacket
import plugins
whitelist = []

ircSettings = YAMLConfig("cfg/pso2proxy.whitelist.config.yml",
                         {'enabled': True}, True)

whitelistmode = ircSettings.get_key('enabled')


@plugins.on_start_hook
def load_whitelist():
    global whitelist
    if not os.path.exists("cfg/pso2proxy.whitelist.json"):
        f = open("cfg/pso2proxy.whitelist.json", "w")
        f.write(json.dumps(whitelist))
        f.close()
        print('[Whitelist] Blank whitelist created.')
    else:
        f = open("cfg/pso2proxy.whitelist.json", "r")
        whitelist = json.loads(f.read())
        f.close()
        print("[Whitelist] Loaded %i whitelisted SEGA IDs." % len(whitelist))


def save_whitelist():
    f = open("cfg/pso2proxy.whitelist.json", "w")
    f.write(json.dumps(whitelist))
    f.close()
    print('[Whitelist] Saved whitelist.')


@plugins.CommandHook("whitelistmode", "[Admin Only] Toggle whitelist mode", True)
class Whitelistmode(commands.Command):
    def call_from_client(self, client):
        global whitelistmode
        whitelistmode = not whitelistmode
        if whitelistmode:
            client.send_crypto_packet(packetFactory.SystemMessagePacket("[Whitelist] Whitelist turn on.", 0x3).build())
            return
        else:
            client.send_crypto_packet(packetFactory.SystemMessagePacket("[Whitelist] Whitelist turn off.", 0x3).build())
            return

    def call_from_console(self):
        global whitelistmode
        whitelistmode = not whitelistmode
        if whitelistmode:
            return "[Whitelist] Whitelist turn on."
{'fraction_non_alphanumeric': 0.11177815894797027, 'fraction_numerical': 0.005145797598627788, 'mean_word_length': 3.1904191616766466, 'pattern_counts': {'":': 0, '<': 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': '6628160', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1064, 'n_words': 227}