<commit_before><?php
/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 <NAME>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */


/**
 * Class fileAuthCheck
 * @property int nextCheck
 */
class authCheck
{

    /**
     * @var
     */
    private $config;
    private $db;
    private $dbUser;
    private $dbPass;
    private $dbName;
    private $guildID;
    private $corpTickers;
    private $authGroups;
    private $exempt;
    private $alertChannel;
    private $guild;
    private $nameEnforce;
    private $nameCheck;
    private $discord;
    private $logger;

    /**
     * @param $config
     * @param $discord
     * @param $logger
     */
    public function init($config, $discord, $logger)
    {
        $this->config = $config;
        $this->discord = $discord;
        $this->logger = $logger;
        $this->db = $config['database']['host'];
        $this->dbUser = $config['database']['user'];
        $this->dbPass = $config['database']['pass'];
        $this->dbName = $config['database']['database'];
        $this->guildID = $config['bot']['guild'];
        $this->exempt = $config['plugins']['auth']['exempt'];
        $this->corpTickers = $config['plugins']['auth']['corpTickers'];
        $this->nameEnforce = $config['plugins']['auth']['nameEnforce'];
        $this->authGroups = $config['plugins']['auth']['authGroups'];
        $this->alertChannel = $config['plugins']['auth']['alertChannel'];
        $this->guild = $config['bot']['guild'];
        $this->nextCheck = 0;

        //Set name check to happen if corpTicker or nameEnforce is set
        if ($this->nameEnforce === 'true' || $this->corpTickers === 'true') {
            $this->nameCheck = 'true';
        }

        //check if cache has been set
        $permsChecked = getPermCache('permsLastChecked');
        $namesChecked = getPermCache('nextRename');
        if ($namesChecked === NULL) {
            setPermCache('nextRename', time());
        }

        //if not set set for now (30 minutes from now for role removal)
        if ($permsChecked === NULL) {
            setPermCache('permsLastChecked', time() - 5);
            setPermCache('authStateLastChecked', time() + 7200);
        }
    }

    public function tick()
    {
        // What was the servers last reported state
        $lastStatus = getPermCache('serverState');
        if ($lastStatus === 'online') {
            $permsChecked = getPermCache('permsLastChecked');
            $stateChecked = getPermCache('authStateLastChecked');
            $namesChecked = getPermCache('nextRename');

            if ($permsChecked <= time()) {
                $this->logger->addInfo('AuthCheck: Checking for users who have left corp/alliance....');
                $this->checkPermissions();
                $this->logger->addInfo('AuthCheck: Corp/alliance check complete.');
            }

            if ($stateChecked <= time()) {
                $this->logger->addInfo('AuthCheck: Checking for users who have been wrongly given roles....');
                $this->checkAuthState();
                $this->logger->addInfo('AuthCheck: Role check complete.');
            }

            if ($this->nameCheck === 'true' && $namesChecked <= time()) {
                $this->logger->addInfo('AuthCheck: Resetting player names....');
                $this->nameReset();
                $this->logger->addInfo('AuthCheck: Names reset.');
            }
        }
    }

    /**
     * @return null
     */

    //Remove members who have roles but never authed
    private function checkPermissions()
    {
        //Get guild object
        $guild = $this->discord->guilds->get('id', $this->guildID);

        //Establish connection to mysql
        $conn = new mysqli($this->db, $this->dbUser, $this->dbPass, $this->dbName);

        $sql = "SELECT characterID, discordID, eveName FROM authUsers WHERE active='yes'";

        $result = $conn->query($sql);

        //Set empty arrays
        $corpArray = array();
        $allianceArray = array();

        // If config is outdated
        if (null === $this->authGroups) {
            $msg = '**Auth Failure:** Please update the bots config to the latest version.';
            queueMessage($msg, $this->alertChannel, $this->guild);
            $nextCheck = time() + 10800;
            setPermCache('permsLastChecked', $nextCheck);
            return null;
        }

        //Set corp/ally id arrays
        foreach ($this->authGroups as $authGroup) {
            if ($authGroup['corpID'] !== 0) {
                $corpArray[] = (int)$authGroup['corpID'];
            }
            if ($authGroup['allianceID'] !== 0) {
                $allianceArray[] = (int)$authGroup['allianceID'];
            }
        }

        if ($result->num_rows >= 1) {
            while ($rows = $result->fetch_assoc()) {
                $charID = $rows['characterID'];
                $discordID = $rows['discordID'];
                $member = $guild->members->get('id', $discordID);
                $eveName = $rows['eveName'];
                //Check if member has roles
                if (null === @$member->roles) {
                    continue;
                }

                //Auth things
                $character = characterDetails($charID);
                $corporationID = $character['corporation_id'];
                $corporationDetails = corpDetails($corporationID);
                $allianceID = $corporationDetails['alliance_id'];
                if (!in_array((int)$allianceID, $allianceArray) && !in_array((int)$corporationID, $corpArray)) {
                    // Deactivate user in database
                    $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'";
                    $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are no longer in a correct corp/alliance.");
                    $conn->query($sql);
                    continue;
                }
            }
            $nextCheck = time() + 10800;
            setPermCache('permsLastChecked', $nextCheck);
            return null;
        }
        $nextCheck = time() + 10800;
        setPermCache('permsLastChecked', $nextCheck);
        return null;
    }

    //Check user corp/alliance affiliation


    private function checkAuthState()
    {

        //Check if exempt roles are set
        if (null === $this->exempt) {
            $this->exempt = '0';
        }

        // If config is outdated
        if (null === $this->authGroups) {
            $msg = '**Auth Failure:** Please update the bots config to the latest version.';
            queueMessage($msg, $this->alertChannel, $this->guild);
            //queue up next check
            $nextCheck = time() + 1800;
            setPermCache('authStateLastChecked', $nextCheck);
            return null;
        }

        //Establish connection to mysql
        $conn = new mysqli($this->db, $this->dbUser, $this->dbPass, $this->dbName);

        //get bot ID so we don't remove out own roles
        $botID = $this->discord->id;

        //Get guild object
        $guild = $this->discord->guilds->get('id', $this->guildID);

        //Check to make sure guildID is set correctly
        if (null === $guild) {
            $this->logger->addError('Config Error: Ensure the guild entry in the config is the guildID (aka serverID) for the main server that the bot is in.');
            $nextCheck = time() + 7200;
            setPermCache('authLastChecked', $nextCheck);
            return null;
        }

        //create empty array to store names
        $removedRoles = array();
        $userCount = 0;

        //Perform check if roles were added without permission
        foreach ($guild->members as $member) {
            $id = $member->id;
            $username = $member->username;
            $roles = $member->roles;

            //Skip to next member if this user has no roles
            if (null === $roles) {
                continue;
            }
            $sql = "SELECT * FROM authUsers WHERE discordID='$id' AND active='yes'";
            $result = $conn->query($sql);

            //If they are NOT active in the db, check for roles to remove
            if ($result->num_rows === 0) {
                $userCount++;
                foreach ($roles as $role) {
                    if ($id !== $botID && !in_array($role->name, $this->exempt, true)) {
                        $member->removeRole($role);
                        $guild->members->save($member);
                        // Add users name to array
                        $removedRoles[] = $username;
                    }
                }
            }
        }
        //Report removed users to log and channel
        $nameList = implode(', ', $removedRoles);
        if ($userCount > 0 && strlen($nameList) > 3 && null !== $nameList) {
            $msg = "Following users roles have been removed - {$nameList}";
            queueMessage($msg, $this->alertChannel, $this->guild);
            $this->logger->addInfo("AuthCheck: Roles removed from {$nameList}");
        }
        //queue up next check
        $nextCheck = time() + 1800;
        setPermCache('authStateLastChecked', $nextCheck);
        return null;
    }

    private function nameReset()
    {
        //Get guild object
        $guild = $this->discord->guilds->get('id', $this->guildID);

        //Get name queue status
        $x = (int)getPermCache('nameQueueState');

        //Establish connection to mysql
        $conn = new mysqli($this->db, $this->dbUser, $this->dbPass, $this->dbName);
        $sql = "SELECT id FROM authUsers WHERE active='yes'";
        $count = $conn->query($sql);
        $rowAmount = $count->num_rows / 2;
        if ($x == 1) {
            $sql = "SELECT characterID, discordID, eveName  FROM authUsers WHERE active='yes' ORDER BY id ASC LIMIT {$rowAmount} OFFSET {$rowAmount}";
            setPermCache('nameQueueState', 0);
        } else {
            $sql = "SELECT characterID, discordID, eveName  FROM authUsers WHERE active='yes' ORDER BY id ASC LIMIT {$rowAmount}";
            setPermCache('nameQueueState', 1);
        }
        $result = $conn->query($sql);

        // If config is outdated
        if (null === $this->authGroups) {
            $msg = '**Auth Failure:** Please update the bots config to the latest version.';
            queueMessage($msg, $this->alertChannel, $this->guild);
            $nextCheck = time() + 1800;
            setPermCache('nextRename', $nextCheck);
            return null;
        }

        if (@$result->num_rows >= 1) {
            while ($rows = $result->fetch_assoc()) {
                $charID = $rows['characterID'];
                $discordID = $rows['discordID'];
                $member = $guild->members->get('id', $discordID);
                $eveName = $rows['eveName'];
                //Check if member has roles
                if (null === @$member->roles) {
                    continue;
                }

                //Get current nickname
                $guild = $this->discord->guilds->get('id', $this->guildID);
                $member = $guild->members->get('id', $discordID);
                $nickName = $member->nick;
                $userName = $member->user->username;
                //If nick isn't set than make it username
                if ($nickName === '' || null === $nickName) {
                    $nickName = $userName;
                }

                //corp ticker
                if ($this->corpTickers === 'true') {
                    $character = characterDetails($charID);
                    $corporationID = $character['corporation_id'];
                    $corporationDetails = corpDetails($corporationID);
                    $corpTicker = (string)$corporationDetails['ticker'];
                    $corpName = (string)$corporationDetails['corporation_name'];
                    if (null !== $corporationDetails) {
                                if ($this->nameEnforce === 'true') {
                                    $nick = "[{$corpTicker}] {$eveName}";
                                } elseif ((string)$nickName === "[{$corpTicker}]") {
                                    $nick = "[{$corpTicker}] {$userName}";
                                } elseif (strpos($nickName, $corpTicker) === false) {
                                    $nick = "[{$corpTicker}] {$nickName}";
                                } elseif (strpos($nickName, $corpTicker) !== false) {
                                    $nick = "{$nickName}";
                                    continue;
                                }
                        if ($nick !== $nickName) {
                                    queueRename($discordID, $nick, $this->guildID);
                                }
                                continue;
                            }
                            if ($this->nameEnforce === 'true') {
                                $nick = "[{$corpTicker}] {$eveName}";
                            } elseif ((string)$nickName === "[{$corpTicker}]") {
                                $nick = "[{$corpTicker}] {$userName}";
                            } elseif (strpos($nickName, $corpTicker) == false) {
                                $nick = "[{$corpTicker}] {$nickName}";
                            } elseif (strpos($nickName, $corpTicker) !== false) {
                                $nick = "{$nickName}";
                                continue;
                            }
                            if ($nick !== $nickName) {
                                queueRename($discordID, $nick, $this->guildID);
                            }
                            addCorpInfo($character->attributes()->corporationID, $corpTicker, $corpName);
                            continue;
                }
                $nick = "{$eveName}";
                if ($nick !== $nickName && $this->corpTickers !== 'true') {
                    queueRename($discordID, $nick, $this->guildID);
                }
                continue;
            }
            $nextCheck = time() + 1800;
            setPermCache('nextRename', $nextCheck);
            return null;
        }
        $nextCheck = time() + 1800;
        setPermCache('nextRename', $nextCheck);
        return null;

    }
}
<commit_msg>error silencing<commit_after><?php
/**
 * The MIT License (MIT)
 *
 * Copyright (c) 2016 <NAME>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */


/**
 * Class fileAuthCheck
 * @property int nextCheck
 */
class authCheck
{

    /**
     * @var
     */
    private $config;
    private $db;
    private $dbUser;
    private $dbPass;
    private $dbName;
    private $guildID;
    private $corpTickers;
    private $authGroups;
    private $exempt;
    private $alertChannel;
    private $guild;
    private $nameEnforce;
    private $nameCheck;
    private $discord;
    private $logger;

    /**
     * @param $config
     * @param $discord
     * @param $logger
     */
    public function init($config, $discord, $logger)
    {
        $this->config = $config;
        $this->discord = $discord;
        $this->logger = $logger;
        $this->db = $config['database']['host'];
        $this->dbUser = $config['database']['user'];
        $this->dbPass = $config['database']['pass'];
        $this->dbName = $config['database']['database'];
        $this->guildID = $config['bot']['guild'];
        $this->exempt = $config['plugins']['auth']['exempt'];
        $this->corpTickers = $config['plugins']['auth']['corpTickers'];
        $this->nameEnforce = $config['plugins']['auth']['nameEnforce'];
        $this->authGroups = $config['plugins']['auth']['authGroups'];
        $this->alertChannel = $config['plugins']['auth']['alertChannel'];
        $this->guild = $config['bot']['guild'];
        $this->nextCheck = 0;

        //Set name check to happen if corpTicker or nameEnforce is set
        if ($this->nameEnforce === 'true' || $this->corpTickers === 'true') {
            $this->nameCheck = 'true';
        }

        //check if cache has been set
        $permsChecked = getPermCache('permsLastChecked');
        $namesChecked = getPermCache('nextRename');
        if ($namesChecked === NULL) {
            setPermCache('nextRename', time());
        }

        //if not set set for now (30 minutes from now for role removal)
        if ($permsChecked === NULL) {
            setPermCache('permsLastChecked', time() - 5);
            setPermCache('authStateLastChecked', time() + 7200);
        }
    }

    public function tick()
    {
        // What was the servers last reported state
        $lastStatus = getPermCache('serverState');
        if ($lastStatus === 'online') {
            $permsChecked = getPermCache('permsLastChecked');
            $stateChecked = getPermCache('authStateLastChecked');
            $namesChecked = getPermCache('nextRename');

            if ($permsChecked <= time()) {
                $this->logger->addInfo('AuthCheck: Checking for users who have left corp/alliance....');
                $this->checkPermissions();
                $this->logger->addInfo('AuthCheck: Corp/alliance check complete.');
            }

            if ($stateChecked <= time()) {
                $this->logger->addInfo('AuthCheck: Checking for users who have been wrongly given roles....');
                $this->checkAuthState();
                $this->logger->addInfo('AuthCheck: Role check complete.');
            }

            if ($this->nameCheck === 'true' && $namesChecked <= time()) {
                $this->logger->addInfo('AuthCheck: Resetting player names....');
                $this->nameReset();
                $this->logger->addInfo('AuthCheck: Names reset.');
            }
        }
    }

    /**
     * @return null
     */

    //Remove members who have roles but never authed
    private function checkPermissions()
    {
        //Get guild object
        $guild = $this->discord->guilds->get('id', $this->guildID);

        //Establish connection to mysql
        $conn = new mysqli($this->db, $this->dbUser, $this->dbPass, $this->dbName);

        $sql = "SELECT characterID, discordID, eveName FROM authUsers WHERE active='yes'";

        $result = $conn->query($sql);

        //Set empty arrays
        $corpArray = array();
        $allianceArray = array();

        // If config is outdated
        if (null === $this->authGroups) {
            $msg = '**Auth Failure:** Please update the bots config to the latest version.';
            queueMessage($msg, $this->alertChannel, $this->guild);
            $nextCheck = time() + 10800;
            setPermCache('permsLastChecked', $nextCheck);
            return null;
        }

        //Set corp/ally id arrays
        foreach ($this->authGroups as $authGroup) {
            if ($authGroup['corpID'] !== 0) {
                $corpArray[] = (int)$authGroup['corpID'];
            }
            if ($authGroup['allianceID'] !== 0) {
                $allianceArray[] = (int)$authGroup['allianceID'];
            }
        }

        if ($result->num_rows >= 1) {
            while ($rows = $result->fetch_assoc()) {
                $charID = $rows['characterID'];
                $discordID = $rows['discordID'];
                $member = $guild->members->get('id', $discordID);
                $eveName = $rows['eveName'];
                //Check if member has roles
                if (null === @$member->roles) {
                    continue;
                }

                //Auth things
                $character = characterDetails($charID);
                $corporationID = $character['corporation_id'];
                $corporationDetails = corpDetails($corporationID);
                $allianceID = @$corporationDetails['alliance_id'];
                if (!in_array((int)$allianceID, $allianceArray) && !in_array((int)$corporationID, $corpArray)) {
                    // Deactivate user in database
                    $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'";
                    $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are no longer in a correct corp/alliance.");
                    $conn->query($sql);
                    continue;
                }
            }
            $nextCheck = time() + 10800;
            setPermCache('permsLastChecked', $nextCheck);
            return null;
        }
        $nextCheck = time() + 10800;
        setPermCache('permsLastChecked', $nextCheck);
        return null;
    }

    //Check user corp/alliance affiliation


    private function checkAuthState()
    {

        //Check if exempt roles are set
        if (null === $this->exempt) {
            $this->exempt = '0';
        }

        // If config is outdated
        if (null === $this->authGroups) {
            $msg = '**Auth Failure:** Please update the bots config to the latest version.';
            queueMessage($msg, $this->alertChannel, $this->guild);
            //queue up next check
            $nextCheck = time() + 1800;
            setPermCache('authStateLastChecked', $nextCheck);
            return null;
        }

        //Establish connection to mysql
        $conn = new mysqli($this->db, $this->dbUser, $this->dbPass, $this->dbName);

        //get bot ID so we don't remove out own roles
        $botID = $this->discord->id;

        //Get guild object
        $guild = $this->discord->guilds->get('id', $this->guildID);

        //Check to make sure guildID is set correctly
        if (null === $guild) {
            $this->logger->addError('Config Error: Ensure the guild entry in the config is the guildID (aka serverID) for the main server that the bot is in.');
            $nextCheck = time() + 7200;
            setPermCache('authLastChecked', $nextCheck);
            return null;
        }

        //create empty array to store names
        $removedRoles = array();
        $userCount = 0;

        //Perform check if roles were added without permission
        foreach ($guild->members as $member) {
            $id = $member->id;
            $username = $member->username;
            $roles = $member->roles;

            //Skip to next member if this user has no roles
            if (null === $roles) {
                continue;
            }
            $sql = "SELECT * FROM authUsers WHERE discordID='$id' AND active='yes'";
            $result = $conn->query($sql);

            //If they are NOT active in the db, check for roles to remove
            if ($result->num_rows === 0) {
                $userCount++;
                foreach ($roles as $role) {
                    if ($id !== $botID && !in_array($role->name, $this->exempt, true)) {
                        $member->removeRole($role);
                        $guild->members->save($member);
                        // Add users name to array
                        $removedRoles[] = $username;
                    }
                }
            }
        }
        //Report removed users to log and channel
        $nameList = implode(', ', $removedRoles);
        if ($userCount > 0 && strlen($nameList) > 3 && null !== $nameList) {
            $msg = "Following users roles have been removed - {$nameList}";
            queueMessage($msg, $this->alertChannel, $this->guild);
            $this->logger->addInfo("AuthCheck: Roles removed from {$nameList}");
        }
        //queue up next check
        $nextCheck = time() + 1800;
        setPermCache('authStateLastChecked', $nextCheck);
        return null;
    }

    private function nameReset()
    {
        //Get guild object
        $guild = $this->discord->guilds->get('id', $this->guildID);

        //Get name queue status
        $x = (int)getPermCache('nameQueueState');

        //Establish connection to mysql
        $conn = new mysqli($this->db, $this->dbUser, $this->dbPass, $this->dbName);
        $sql = "SELECT id FROM authUsers WHERE active='yes'";
        $count = $conn->query($sql);
        $rowAmount = $count->num_rows / 2;
        if ($x == 1) {
            $sql = "SELECT characterID, discordID, eveName  FROM authUsers WHERE active='yes' ORDER BY id ASC LIMIT {$rowAmount} OFFSET {$rowAmount}";
            setPermCache('nameQueueState', 0);
        } else {
            $sql = "SELECT characterID, discordID, eveName  FROM authUsers WHERE active='yes' ORDER BY id ASC LIMIT {$rowAmount}";
            setPermCache('nameQueueState', 1);
        }
        $result = $conn->query($sql);

        // If config is outdated
        if (null === $this->authGroups) {
            $msg = '**Auth Failure:** Please update the bots config to the latest version.';
            queueMessage($msg, $this->alertChannel, $this->guild);
            $nextCheck = time() + 1800;
            setPermCache('nextRename', $nextCheck);
            return null;
        }

        if (@$result->num_rows >= 1) {
            while ($rows = $result->fetch_assoc()) {
                $charID = $rows['characterID'];
                $discordID = $rows['discordID'];
                $member = $guild->members->get('id', $discordID);
                $eveName = $rows['eveName'];
                //Check if member has roles
                if (null === @$member->roles) {
                    continue;
                }

                //Get current nickname
                $guild = $this->discord->guilds->get('id', $this->guildID);
                $member = $guild->members->get('id', $discordID);
                $nickName = $member->nick;
                $userName = $member->user->username;
                //If nick isn't set than make it username
                if ($nickName === '' || null === $nickName) {
                    $nickName = $userName;
                }

                //corp ticker
                if ($this->corpTickers === 'true') {
                    $character = characterDetails($charID);
                    $corporationID = $character['corporation_id'];
                    $corporationDetails = corpDetails($corporationID);
                    $corpTicker = (string)$corporationDetails['ticker'];
                    $corpName = (string)$corporationDetails['corporation_name'];
                    if (null !== $corporationDetails) {
                                if ($this->nameEnforce === 'true') {
                                    $nick = "[{$corpTicker}] {$eveName}";
                                } elseif ((string)$nickName === "[{$corpTicker}]") {
                                    $nick = "[{$corpTicker}] {$userName}";
                                } elseif (strpos($nickName, $corpTicker) === false) {
                                    $nick = "[{$corpTicker}] {$nickName}";
                                } elseif (strpos($nickName, $corpTicker) !== false) {
                                    $nick = "{$nickName}";
                                    continue;
                                }
                        if ($nick !== $nickName) {
                                    queueRename($discordID, $nick, $this->guildID);
                                }
                                continue;
                            }
                            if ($this->nameEnforce === 'true') {
                                $nick = "[{$corpTicker}] {$eveName}";
                            } elseif ((string)$nickName === "[{$corpTicker}]") {
                                $nick = "[{$corpTicker}] {$userName}";
                            } elseif (strpos($nickName, $corpTicker) == false) {
                                $nick = "[{$corpTicker}] {$nickName}";
                            } elseif (strpos($nickName, $corpTicker) !== false) {
                                $nick = "{$nickName}";
                                continue;
                            }
                            if ($nick !== $nickName) {
                                queueRename($discordID, $nick, $this->guildID);
                            }
                            addCorpInfo($character->attributes()->corporationID, $corpTicker, $corpName);
                            continue;
                }
                $nick = "{$eveName}";
                if ($nick !== $nickName && $this->corpTickers !== 'true') {
                    queueRename($discordID, $nick, $this->guildID);
                }
                continue;
            }
            $nextCheck = time() + 1800;
            setPermCache('nextRename', $nextCheck);
            return null;
        }
        $nextCheck = time() + 1800;
        setPermCache('nextRename', $nextCheck);
        return null;

    }
}

{'fraction_non_alphanumeric': 0.13688324377137273, 'fraction_numerical': 0.004168702165771047, 'mean_word_length': 1.7178261639228183, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 261, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3930511', 'n_tokens_mistral': 8446, 'n_tokens_neox': 7902, 'n_words': 2143}