@@ -25,80 +25,80 @@ |
||
| 25 | 25 | /** |
| 26 | 26 | * @property message |
| 27 | 27 | */ |
| 28 | - class motd { |
|
| 29 | - public $config; |
|
| 30 | - public $discord; |
|
| 31 | - public $logger; |
|
| 32 | - public $message; |
|
| 33 | - private $excludeChannel; |
|
| 34 | - private $triggers; |
|
| 35 | - public function init($config, $discord, $logger) { |
|
| 36 | - $this->config = $config; |
|
| 37 | - $this->discord = $discord; |
|
| 38 | - $this->logger = $logger; |
|
| 39 | - $this->excludeChannel = $this->config['bot']['restrictedChannels']; |
|
| 40 | - $this->triggers[] = $this->config['bot']['trigger'] . 'motd'; |
|
| 41 | - $this->triggers[] = $this->config['bot']['trigger'] . 'Motd'; |
|
| 42 | - $this->triggers[] = $this->config['bot']['trigger'] . 'MOTD'; |
|
| 43 | - $this->keyID = $config['plugins']['motd']['keyID']; |
|
| 44 | - $this->vCode = $config['plugins']['motd']['vCode']; |
|
| 45 | - $this->characterID = $config['plugins']['motd']['characterID']; |
|
| 46 | - $this->channelname = $config['plugins']['motd']['channelname']; |
|
| 47 | - } |
|
| 48 | - public function onMessage($msgData, $message) { |
|
| 49 | - $channelID = (int) $msgData['message']['channelID']; |
|
| 50 | - if (in_array($channelID, $this->excludeChannel, true)) { |
|
| 51 | - return null; |
|
| 52 | - } |
|
| 53 | - $this->message = $message; |
|
| 54 | - $user = $msgData['message']['from']; |
|
| 55 | - $message = $msgData['message']['message']; |
|
| 56 | - $data = command($message, $this->information() ['trigger'], $this->config['bot']['trigger']); |
|
| 57 | - if (isset($data['trigger'])) { |
|
| 58 | - $keyID = $this->keyID; |
|
| 59 | - $vCode = $this->vCode; |
|
| 60 | - $characterID = $this->characterID; |
|
| 61 | - $channelname = $this->channelname; |
|
| 28 | + class motd { |
|
| 29 | + public $config; |
|
| 30 | + public $discord; |
|
| 31 | + public $logger; |
|
| 32 | + public $message; |
|
| 33 | + private $excludeChannel; |
|
| 34 | + private $triggers; |
|
| 35 | + public function init($config, $discord, $logger) { |
|
| 36 | + $this->config = $config; |
|
| 37 | + $this->discord = $discord; |
|
| 38 | + $this->logger = $logger; |
|
| 39 | + $this->excludeChannel = $this->config['bot']['restrictedChannels']; |
|
| 40 | + $this->triggers[] = $this->config['bot']['trigger'] . 'motd'; |
|
| 41 | + $this->triggers[] = $this->config['bot']['trigger'] . 'Motd'; |
|
| 42 | + $this->triggers[] = $this->config['bot']['trigger'] . 'MOTD'; |
|
| 43 | + $this->keyID = $config['plugins']['motd']['keyID']; |
|
| 44 | + $this->vCode = $config['plugins']['motd']['vCode']; |
|
| 45 | + $this->characterID = $config['plugins']['motd']['characterID']; |
|
| 46 | + $this->channelname = $config['plugins']['motd']['channelname']; |
|
| 47 | + } |
|
| 48 | + public function onMessage($msgData, $message) { |
|
| 49 | + $channelID = (int) $msgData['message']['channelID']; |
|
| 50 | + if (in_array($channelID, $this->excludeChannel, true)) { |
|
| 51 | + return null; |
|
| 52 | + } |
|
| 53 | + $this->message = $message; |
|
| 54 | + $user = $msgData['message']['from']; |
|
| 55 | + $message = $msgData['message']['message']; |
|
| 56 | + $data = command($message, $this->information() ['trigger'], $this->config['bot']['trigger']); |
|
| 57 | + if (isset($data['trigger'])) { |
|
| 58 | + $keyID = $this->keyID; |
|
| 59 | + $vCode = $this->vCode; |
|
| 60 | + $characterID = $this->characterID; |
|
| 61 | + $channelname = $this->channelname; |
|
| 62 | 62 | |
| 63 | 63 | $urlChar = "https://api.eveonline.com/char/ChatChannels.xml.aspx?keyID=$keyID&vCode=$vCode&characterID=$characterID"; |
| 64 | - $data = file_get_contents($urlChar); |
|
| 65 | - $list = new SimpleXMLElement($data); |
|
| 64 | + $data = file_get_contents($urlChar); |
|
| 65 | + $list = new SimpleXMLElement($data); |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | - foreach ($list->result->rowset->row as $row) { |
|
| 69 | - $channeln = $row["displayName"]; |
|
| 68 | + foreach ($list->result->rowset->row as $row) { |
|
| 69 | + $channeln = $row["displayName"]; |
|
| 70 | 70 | |
| 71 | - if ($channeln == $channelname) { |
|
| 72 | - //scrub the motd, then break it into 1900 chars or less. Limit is 2000 and want to leave room for the name of the person being replied too |
|
| 73 | - $comment = $row["motd"]; |
|
| 74 | - $comment = str_replace("<BR>", "\n", $comment); |
|
| 75 | - $comment = str_replace("<br>", "\n", $comment); |
|
| 76 | - $comment = str_replace("<u>", "__", $comment); |
|
| 77 | - $comment = str_replace("</u>", "__", $comment); |
|
| 78 | - $comment = str_replace("<b>", "**", $comment); |
|
| 79 | - $comment = str_replace("</b>", "**", $comment); |
|
| 80 | - $comment = str_replace("<i>", "*", $comment); |
|
| 81 | - $comment = str_replace("</i>", "*", $comment); |
|
| 82 | - $comment = str_replace("&", "&", $comment); |
|
| 83 | - $comment = strip_tags($comment); |
|
| 84 | - $comment2 = str_split($comment, 1900); |
|
| 71 | + if ($channeln == $channelname) { |
|
| 72 | + //scrub the motd, then break it into 1900 chars or less. Limit is 2000 and want to leave room for the name of the person being replied too |
|
| 73 | + $comment = $row["motd"]; |
|
| 74 | + $comment = str_replace("<BR>", "\n", $comment); |
|
| 75 | + $comment = str_replace("<br>", "\n", $comment); |
|
| 76 | + $comment = str_replace("<u>", "__", $comment); |
|
| 77 | + $comment = str_replace("</u>", "__", $comment); |
|
| 78 | + $comment = str_replace("<b>", "**", $comment); |
|
| 79 | + $comment = str_replace("</b>", "**", $comment); |
|
| 80 | + $comment = str_replace("<i>", "*", $comment); |
|
| 81 | + $comment = str_replace("</i>", "*", $comment); |
|
| 82 | + $comment = str_replace("&", "&", $comment); |
|
| 83 | + $comment = strip_tags($comment); |
|
| 84 | + $comment2 = str_split($comment, 1900); |
|
| 85 | 85 | |
| 86 | - $this->message->reply("\n $comment2[0]"); |
|
| 87 | - if (!empty($comment2[1])) { |
|
| 88 | - $this->message->reply("\n $comment2[1]"); |
|
| 89 | - } |
|
| 90 | - if (!empty($comment2[2])) { |
|
| 91 | - $this->message->reply("\n $comment2[2]"); |
|
| 92 | - } |
|
| 93 | - if (!empty($comment2[3])) { |
|
| 94 | - $this->message->reply("\n $comment2[3]"); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - public function information() { |
|
| 86 | + $this->message->reply("\n $comment2[0]"); |
|
| 87 | + if (!empty($comment2[1])) { |
|
| 88 | + $this->message->reply("\n $comment2[1]"); |
|
| 89 | + } |
|
| 90 | + if (!empty($comment2[2])) { |
|
| 91 | + $this->message->reply("\n $comment2[2]"); |
|
| 92 | + } |
|
| 93 | + if (!empty($comment2[3])) { |
|
| 94 | + $this->message->reply("\n $comment2[3]"); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + public function information() { |
|
| 101 | 101 | return array('name' => 'motd', 'trigger' => $this->triggers, 'information' => 'Displays the MOTD, useful for seeing information displayed there when not in-game.'); |
| 102 | - } |
|
| 103 | - } |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | ?> |
@@ -57,8 +57,8 @@ |
||
| 57 | 57 | //Check we are not running on a 32bit platform |
| 58 | 58 | if(PHP_INT_SIZE == 4) |
| 59 | 59 | { |
| 60 | - $logger->error('32bit PHP found, if you are running a 64bit OS please install 64bit PHP'); |
|
| 61 | - die(); |
|
| 60 | + $logger->error('32bit PHP found, if you are running a 64bit OS please install 64bit PHP'); |
|
| 61 | + die(); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Require the config |
@@ -174,68 +174,68 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | if ($result->num_rows >= 1) { |
| 176 | 176 | while ($rows = $result->fetch_assoc()) { |
| 177 | - $charID = $rows['characterID']; |
|
| 178 | - $discordID = $rows['discordID']; |
|
| 179 | - $role = $rows['role']; |
|
| 180 | - $member = $guild->members->get('id', $discordID); |
|
| 181 | - $eveName = $rows['eveName']; |
|
| 182 | - //Check if member has roles |
|
| 183 | - if (null === @$member->roles) { |
|
| 184 | - continue; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - //Auth things |
|
| 188 | - $character = characterDetails($charID); |
|
| 189 | - //if issue with esi, skip |
|
| 190 | - $timeout = 0; |
|
| 191 | - while (null === $character) { //try 10 times to pull characterDetails |
|
| 192 | - if ($timeout > 9) { |
|
| 193 | - continue; |
|
| 194 | - } |
|
| 195 | - else{ |
|
| 196 | - $character = characterDetails($charID); |
|
| 197 | - $timeout++; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - $corporationID = $character['corporation_id']; |
|
| 201 | - $corporationDetails = corpDetails($corporationID); |
|
| 202 | - $timeout = 0; |
|
| 203 | - while (null === $corporationDetails) { //try 10 times to pull corporationDetails |
|
| 204 | - if ($timeout > 9) { |
|
| 205 | - continue; |
|
| 206 | - } |
|
| 207 | - else{ |
|
| 208 | - $corporationDetails = corpDetails($corporationID); |
|
| 209 | - $timeout++; |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - $allianceID = @$corporationDetails['alliance_id']; |
|
| 213 | - //check if user authed based on standings |
|
| 214 | - $standings = null; |
|
| 215 | - if ($role === 'blue' || 'neut' || 'red') { |
|
| 216 | - $allianceContacts = getContacts($allianceID); |
|
| 217 | - $corpContacts = getContacts($corporationID); |
|
| 218 | - if ($role === 'blue' && ((int) $allianceContacts['standing'] === 5 || 10 || (int) $corpContacts['standing'] === 5 || 10)) { |
|
| 219 | - $standings = 1; |
|
| 220 | - } |
|
| 221 | - if ($role === 'red' && ((int) $allianceContacts['standing'] === -5 || -10 || (int) $corpContacts['standing'] === -5 || -10)) { |
|
| 222 | - $standings = 1; |
|
| 223 | - } |
|
| 224 | - if ($role === 'neut' && ((int) $allianceContacts['standing'] === 0 || (int) $corpContacts['standing'] === 0 || (@(int) $allianceContacts['standings'] === null || '' && @(int) $corpContacts['standings'] === null || ''))) { |
|
| 225 | - $standings = 1; |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - if (!in_array((int) $allianceID, $allianceArray) && !in_array((int) $corporationID, $corpArray) && null === $standings) { |
|
| 229 | - // Deactivate user in database |
|
| 230 | - $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'"; |
|
| 231 | - $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are no longer in a correct corp/alliance."); |
|
| 232 | - $conn->query($sql); |
|
| 233 | - continue; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - $nextCheck = time() + 10800; |
|
| 237 | - setPermCache('permsLastChecked', $nextCheck); |
|
| 238 | - } |
|
| 177 | + $charID = $rows['characterID']; |
|
| 178 | + $discordID = $rows['discordID']; |
|
| 179 | + $role = $rows['role']; |
|
| 180 | + $member = $guild->members->get('id', $discordID); |
|
| 181 | + $eveName = $rows['eveName']; |
|
| 182 | + //Check if member has roles |
|
| 183 | + if (null === @$member->roles) { |
|
| 184 | + continue; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + //Auth things |
|
| 188 | + $character = characterDetails($charID); |
|
| 189 | + //if issue with esi, skip |
|
| 190 | + $timeout = 0; |
|
| 191 | + while (null === $character) { //try 10 times to pull characterDetails |
|
| 192 | + if ($timeout > 9) { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 195 | + else{ |
|
| 196 | + $character = characterDetails($charID); |
|
| 197 | + $timeout++; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + $corporationID = $character['corporation_id']; |
|
| 201 | + $corporationDetails = corpDetails($corporationID); |
|
| 202 | + $timeout = 0; |
|
| 203 | + while (null === $corporationDetails) { //try 10 times to pull corporationDetails |
|
| 204 | + if ($timeout > 9) { |
|
| 205 | + continue; |
|
| 206 | + } |
|
| 207 | + else{ |
|
| 208 | + $corporationDetails = corpDetails($corporationID); |
|
| 209 | + $timeout++; |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + $allianceID = @$corporationDetails['alliance_id']; |
|
| 213 | + //check if user authed based on standings |
|
| 214 | + $standings = null; |
|
| 215 | + if ($role === 'blue' || 'neut' || 'red') { |
|
| 216 | + $allianceContacts = getContacts($allianceID); |
|
| 217 | + $corpContacts = getContacts($corporationID); |
|
| 218 | + if ($role === 'blue' && ((int) $allianceContacts['standing'] === 5 || 10 || (int) $corpContacts['standing'] === 5 || 10)) { |
|
| 219 | + $standings = 1; |
|
| 220 | + } |
|
| 221 | + if ($role === 'red' && ((int) $allianceContacts['standing'] === -5 || -10 || (int) $corpContacts['standing'] === -5 || -10)) { |
|
| 222 | + $standings = 1; |
|
| 223 | + } |
|
| 224 | + if ($role === 'neut' && ((int) $allianceContacts['standing'] === 0 || (int) $corpContacts['standing'] === 0 || (@(int) $allianceContacts['standings'] === null || '' && @(int) $corpContacts['standings'] === null || ''))) { |
|
| 225 | + $standings = 1; |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + if (!in_array((int) $allianceID, $allianceArray) && !in_array((int) $corporationID, $corpArray) && null === $standings) { |
|
| 229 | + // Deactivate user in database |
|
| 230 | + $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'"; |
|
| 231 | + $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are no longer in a correct corp/alliance."); |
|
| 232 | + $conn->query($sql); |
|
| 233 | + continue; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + $nextCheck = time() + 10800; |
|
| 237 | + setPermCache('permsLastChecked', $nextCheck); |
|
| 238 | + } |
|
| 239 | 239 | } |
| 240 | 240 | $nextCheck = time() + 10800; |
| 241 | 241 | setPermCache('permsLastChecked', $nextCheck); |
@@ -386,17 +386,17 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | //corp ticker |
| 388 | 388 | if ($this->corpTickers === 'true') { |
| 389 | - $timeout = 0; |
|
| 390 | - $character = characterDetails($charID); |
|
| 391 | - while (null === $character) { //try 10 times to pull characterDetails |
|
| 392 | - if ($timeout > 9) { |
|
| 393 | - continue; |
|
| 394 | - } |
|
| 395 | - else{ |
|
| 396 | - $character = characterDetails($charID); |
|
| 397 | - $timeout++; |
|
| 398 | - } |
|
| 399 | - } |
|
| 389 | + $timeout = 0; |
|
| 390 | + $character = characterDetails($charID); |
|
| 391 | + while (null === $character) { //try 10 times to pull characterDetails |
|
| 392 | + if ($timeout > 9) { |
|
| 393 | + continue; |
|
| 394 | + } |
|
| 395 | + else{ |
|
| 396 | + $character = characterDetails($charID); |
|
| 397 | + $timeout++; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | 400 | if (!array_key_exists('corporation_id', $character)) { |
| 401 | 401 | continue; |
| 402 | 402 | } |