@@ -112,7 +112,7 @@ |
||
| 112 | 112 | $cacheClr = $baseUnix - 13500; |
| 113 | 113 | |
| 114 | 114 | //Set timer for next key based on number of keys |
| 115 | - $nextKey = (1900 / (int)$this->numberOfKeys) + time(); |
|
| 115 | + $nextKey = (1900 / (int) $this->numberOfKeys) + time(); |
|
| 116 | 116 | $nextKeyTime = gmdate('Y-m-d H:i:s', $nextKey); |
| 117 | 117 | setPermCache('mailLastChecked', $nextKey); |
| 118 | 118 | |
@@ -125,7 +125,7 @@ |
||
| 125 | 125 | $this->fuelChannel = $this->toDiscordChannel; |
| 126 | 126 | } |
| 127 | 127 | //Set timer for next key based on number of keys |
| 128 | - $nextKey = (1900 / (int)$this->numberOfKeys) + time(); |
|
| 128 | + $nextKey = (1900 / (int) $this->numberOfKeys) + time(); |
|
| 129 | 129 | $nextKeyTime = gmdate('Y-m-d H:i:s', $nextKey); |
| 130 | 130 | setPermCache('notificationsLastChecked', $nextKey); |
| 131 | 131 | //Set cache timer for api key |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $roles = $member->roles; |
| 72 | 72 | foreach ($roles as $role) { |
| 73 | 73 | if (in_array(strtolower($role->name), $adminRoles, true)) { |
| 74 | - $avatarURL = strtolower((string)$data['messageString']); |
|
| 74 | + $avatarURL = strtolower((string) $data['messageString']); |
|
| 75 | 75 | $ch = curl_init($avatarURL); |
| 76 | 76 | if (substr($avatarURL, -4) === '.jpg') { |
| 77 | 77 | $fp = fopen('/tmp/avatar.jpg', 'wb'); |
@@ -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 |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | GLOBAL $logger; |
| 56 | 56 | |
| 57 | 57 | //Check we are not running on a 32bit platform |
| 58 | -if(PHP_INT_SIZE == 4) |
|
| 58 | +if (PHP_INT_SIZE == 4) |
|
| 59 | 59 | { |
| 60 | 60 | $logger->error('32bit PHP found, if you are running a 64bit OS please install 64bit PHP'); |
| 61 | 61 | die(); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | clearQueuedMessages($id); |
| 207 | 207 | continue; |
| 208 | 208 | } |
| 209 | - $channel = $guild->channels->get('id', (int)$queuedMessage['channel']); |
|
| 209 | + $channel = $guild->channels->get('id', (int) $queuedMessage['channel']); |
|
| 210 | 210 | //Check if channel is bad |
| 211 | 211 | if (null === $channel) { |
| 212 | 212 | $logger->addInfo("QueueProcessing Error- Item #{$id} : Channel provided is incorrect, removing it from the queue"); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public $itemTitle; |
| 39 | 39 | public $itemUrl; |
| 40 | 40 | public $itemDate; |
| 41 | - public $strDate; |
|
| 41 | + public $strDate; |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @param $config |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $rss = new SimpleXMLElement($rssUrl, null, true); // XML parser |
| 94 | - if ($rss===null || !is_object($rss)) { |
|
| 95 | - $this->logger->addInfo("Failed to load xml file: {$rssUrl}"); |
|
| 96 | - break; |
|
| 97 | - } |
|
| 98 | - if (!is_object($rss->feed)) { |
|
| 99 | - $this->logger->addInfo("Feed is not an object at: {$rssUrl}"); |
|
| 100 | - break; |
|
| 101 | - } |
|
| 102 | - $feedLink = $rss->feed->id; |
|
| 94 | + if ($rss===null || !is_object($rss)) { |
|
| 95 | + $this->logger->addInfo("Failed to load xml file: {$rssUrl}"); |
|
| 96 | + break; |
|
| 97 | + } |
|
| 98 | + if (!is_object($rss->feed)) { |
|
| 99 | + $this->logger->addInfo("Feed is not an object at: {$rssUrl}"); |
|
| 100 | + break; |
|
| 101 | + } |
|
| 102 | + $feedLink = $rss->feed->id; |
|
| 103 | 103 | $latestTopicDate = getPermCache("rssFeed{$feedLink}"); |
| 104 | 104 | |
| 105 | 105 | //Check if feed has been checked before |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | $itemUrl = $rss->entry->id; |
| 115 | 115 | $strDate = $rss->entry->published; |
| 116 | 116 | |
| 117 | - $itemDate = strtotime($strDate); |
|
| 117 | + $itemDate = strtotime($strDate); |
|
| 118 | 118 | |
| 119 | 119 | //Check to see if feed is formatted correctly |
| 120 | 120 | if (is_null($itemTitle) || is_null($itemUrl) || is_null($itemDate)) { |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $rss = new SimpleXMLElement($rssUrl, null, true); // XML parser |
| 94 | - if ($rss===null || !is_object($rss)) { |
|
| 94 | + if ($rss === null || !is_object($rss)) { |
|
| 95 | 95 | $this->logger->addInfo("Failed to load xml file: {$rssUrl}"); |
| 96 | 96 | break; |
| 97 | 97 | } |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | $corporationDetails = $this->getCorpDetails($character['corporation_id']); |
| 246 | 246 | $allianceContacts = getContacts($corporationDetails['alliance_id']); |
| 247 | 247 | $corpContacts = getContacts($character['corporation_id']); |
| 248 | - if ($role === 'blue' && ((int)$allianceContacts['standing'] === 5 || 10 || (int)$corpContacts['standing'] === 5 || 10)) { |
|
| 248 | + if ($role === 'blue' && ((int) $allianceContacts['standing'] === 5 || 10 || (int) $corpContacts['standing'] === 5 || 10)) { |
|
| 249 | 249 | $return = true; |
| 250 | 250 | } |
| 251 | - if ($role === 'red' && ((int)$allianceContacts['standing'] === -5 || -10 || (int)$corpContacts['standing'] === -5 || -10)) { |
|
| 251 | + if ($role === 'red' && ((int) $allianceContacts['standing'] === -5 || -10 || (int) $corpContacts['standing'] === -5 || -10)) { |
|
| 252 | 252 | $return = true; |
| 253 | 253 | } |
| 254 | - if ($role === 'neut' && ((int)$allianceContacts['standing'] === 0 || (int)$corpContacts['standing'] === 0 || (@(int)$allianceContacts['standings'] === null || '' && @(int)$corpContacts['standings'] === null || ''))) { |
|
| 254 | + if ($role === 'neut' && ((int) $allianceContacts['standing'] === 0 || (int) $corpContacts['standing'] === 0 || (@(int) $allianceContacts['standings'] === null || '' && @(int) $corpContacts['standings'] === null || ''))) { |
|
| 255 | 255 | $return = true; |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | private function standingsUpdate() |
| 330 | 330 | { |
| 331 | 331 | foreach ($this->apiKey as $apiKey) { |
| 332 | - if ((string)$apiKey['keyID'] === (string)$this->config['plugins']['auth']['standings']['apiKey']) { |
|
| 332 | + if ((string) $apiKey['keyID'] === (string) $this->config['plugins']['auth']['standings']['apiKey']) { |
|
| 333 | 333 | $url = "https://api.eveonline.com/char/ContactList.xml.aspx?keyID={$apiKey['keyID']}&vCode={$apiKey['vCode']}&characterID={$apiKey['characterID']}"; |
| 334 | 334 | $xml = makeApiRequest($url); |
| 335 | 335 | if (empty($xml)) { |
| 336 | 336 | return null; |
| 337 | 337 | } |
| 338 | 338 | foreach ($xml->result->rowset as $contactType) { |
| 339 | - if ((string)$contactType->attributes()->name === 'corporateContactList' || 'allianceContactList') { |
|
| 339 | + if ((string) $contactType->attributes()->name === 'corporateContactList' || 'allianceContactList') { |
|
| 340 | 340 | foreach ($contactType->row as $contact) { |
| 341 | 341 | if (null !== $contact['contactID'] && $contact['contactName'] && $contact['standing']) { |
| 342 | 342 | addContactInfo($contact['contactID'], $contact['contactName'], $contact['standing']); |
@@ -132,12 +132,12 @@ |
||
| 132 | 132 | $data = new SimpleXMLElement(downloadData("https://api.eve-central.com/api/marketstat?usesystem={$solarSystemID}&typeid={$typeID}")); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $lowBuy = str_pad(number_format((float) $data->marketstat->type->buy->min, 2),18," ",STR_PAD_LEFT); |
|
| 136 | - $avgBuy = str_pad(number_format((float) $data->marketstat->type->buy->avg, 2),18," ",STR_PAD_LEFT); |
|
| 137 | - $highBuy = str_pad(number_format((float) $data->marketstat->type->buy->max, 2),18," ",STR_PAD_LEFT); |
|
| 138 | - $lowSell = str_pad(number_format((float) $data->marketstat->type->sell->min, 2),18," ",STR_PAD_LEFT); |
|
| 139 | - $avgSell = str_pad(number_format((float) $data->marketstat->type->sell->avg, 2),18," ",STR_PAD_LEFT); |
|
| 140 | - $highSell = str_pad(number_format((float) $data->marketstat->type->sell->max, 2),18," ",STR_PAD_LEFT); |
|
| 135 | + $lowBuy = str_pad(number_format((float) $data->marketstat->type->buy->min, 2), 18, " ", STR_PAD_LEFT); |
|
| 136 | + $avgBuy = str_pad(number_format((float) $data->marketstat->type->buy->avg, 2), 18, " ", STR_PAD_LEFT); |
|
| 137 | + $highBuy = str_pad(number_format((float) $data->marketstat->type->buy->max, 2), 18, " ", STR_PAD_LEFT); |
|
| 138 | + $lowSell = str_pad(number_format((float) $data->marketstat->type->sell->min, 2), 18, " ", STR_PAD_LEFT); |
|
| 139 | + $avgSell = str_pad(number_format((float) $data->marketstat->type->sell->avg, 2), 18, " ", STR_PAD_LEFT); |
|
| 140 | + $highSell = str_pad(number_format((float) $data->marketstat->type->sell->max, 2), 18, " ", STR_PAD_LEFT); |
|
| 141 | 141 | |
| 142 | 142 | $this->logger->addInfo("Price: Sending pricing info to {$user}"); |
| 143 | 143 | $solarSystemName = $systemName === 'pc' ? 'Global' : ucfirst($systemName); |
@@ -1,7 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -use Discord\Discord; |
|
| 4 | - |
|
| 5 | 3 | class sysInfo |
| 6 | 4 | { |
| 7 | 5 | public $config; |
@@ -4,71 +4,71 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class sysInfo |
| 6 | 6 | { |
| 7 | - public $config; |
|
| 8 | - public $discord; |
|
| 9 | - public $logger; |
|
| 10 | - private $excludeChannel; |
|
| 11 | - private $message; |
|
| 12 | - private $triggers; |
|
| 13 | - |
|
| 14 | - public function init($config, $discord, $logger) |
|
| 15 | - { |
|
| 16 | - $this->config = $config; |
|
| 17 | - $this->discord = $discord; |
|
| 18 | - $this->logger = $logger; |
|
| 19 | - $this->excludeChannel = $this->config['bot']['restrictedChannels']; |
|
| 20 | - $this->triggers[] = $this->config['bot']['trigger'] . 'sys'; |
|
| 21 | - $this->triggers[] = $this->config['bot']['trigger'] . 'Sys'; |
|
| 22 | - $this->triggers[] = $this->config['bot']['trigger'] . 'sysinfo'; |
|
| 23 | - $this->triggers[] = $this->config['bot']['trigger'] . 'system'; |
|
| 24 | - $this->triggers[] = $this->config['bot']['trigger'] . 'System'; |
|
| 25 | - $this->triggers[] = $this->config['bot']['trigger'] . 'Sysinfo'; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function onMessage($msgData, $message) |
|
| 29 | - { |
|
| 30 | - $channelID = (int) $msgData['message']['channelID']; |
|
| 31 | - |
|
| 32 | - if(in_array($channelID, $this->excludeChannel, true)) |
|
| 33 | - { |
|
| 34 | - return null; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - $this->message = $message; |
|
| 38 | - |
|
| 39 | - $message = $msgData['message']['message']; |
|
| 40 | - $user = $msgData['message']['from']; |
|
| 41 | - |
|
| 42 | - $data = command($message, $this->information()['trigger'], $this->config['bot']['trigger']); |
|
| 43 | - if(isset($data['trigger'])) |
|
| 44 | - { |
|
| 45 | - $messageString = strstr($data['messageString'], '@') ? str_replace('<@', '', str_replace('>', '', $data['messageString'])) : $data['messageString']; |
|
| 46 | - if(is_numeric($messageString)) |
|
| 47 | - { |
|
| 48 | - $messageString = dbQueryField('SELECT name FROM usersSeen WHERE id = :id', 'name', array(':id' => $messageString)); |
|
| 49 | - } |
|
| 50 | - $cleanString = urlencode($messageString); |
|
| 51 | - $sysID = urlencode(getSystemID($cleanString)); |
|
| 52 | - |
|
| 53 | - //Check if we get a system back, otherwise check for partials |
|
| 54 | - if(empty($sysID)) |
|
| 55 | - { |
|
| 7 | + public $config; |
|
| 8 | + public $discord; |
|
| 9 | + public $logger; |
|
| 10 | + private $excludeChannel; |
|
| 11 | + private $message; |
|
| 12 | + private $triggers; |
|
| 13 | + |
|
| 14 | + public function init($config, $discord, $logger) |
|
| 15 | + { |
|
| 16 | + $this->config = $config; |
|
| 17 | + $this->discord = $discord; |
|
| 18 | + $this->logger = $logger; |
|
| 19 | + $this->excludeChannel = $this->config['bot']['restrictedChannels']; |
|
| 20 | + $this->triggers[] = $this->config['bot']['trigger'] . 'sys'; |
|
| 21 | + $this->triggers[] = $this->config['bot']['trigger'] . 'Sys'; |
|
| 22 | + $this->triggers[] = $this->config['bot']['trigger'] . 'sysinfo'; |
|
| 23 | + $this->triggers[] = $this->config['bot']['trigger'] . 'system'; |
|
| 24 | + $this->triggers[] = $this->config['bot']['trigger'] . 'System'; |
|
| 25 | + $this->triggers[] = $this->config['bot']['trigger'] . 'Sysinfo'; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public function onMessage($msgData, $message) |
|
| 29 | + { |
|
| 30 | + $channelID = (int) $msgData['message']['channelID']; |
|
| 31 | + |
|
| 32 | + if(in_array($channelID, $this->excludeChannel, true)) |
|
| 33 | + { |
|
| 34 | + return null; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + $this->message = $message; |
|
| 38 | + |
|
| 39 | + $message = $msgData['message']['message']; |
|
| 40 | + $user = $msgData['message']['from']; |
|
| 41 | + |
|
| 42 | + $data = command($message, $this->information()['trigger'], $this->config['bot']['trigger']); |
|
| 43 | + if(isset($data['trigger'])) |
|
| 44 | + { |
|
| 45 | + $messageString = strstr($data['messageString'], '@') ? str_replace('<@', '', str_replace('>', '', $data['messageString'])) : $data['messageString']; |
|
| 46 | + if(is_numeric($messageString)) |
|
| 47 | + { |
|
| 48 | + $messageString = dbQueryField('SELECT name FROM usersSeen WHERE id = :id', 'name', array(':id' => $messageString)); |
|
| 49 | + } |
|
| 50 | + $cleanString = urlencode($messageString); |
|
| 51 | + $sysID = urlencode(getSystemID($cleanString)); |
|
| 52 | + |
|
| 53 | + //Check if we get a system back, otherwise check for partials |
|
| 54 | + if(empty($sysID)) |
|
| 55 | + { |
|
| 56 | 56 | return $this->message->reply('**Error:** no data available'); |
| 57 | - } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $systemDetails = systemDetails($sysID); |
|
| 60 | - if (null === $systemDetails) |
|
| 61 | - { |
|
| 62 | - return $this->message->reply('**Error:** ESI is down. Try again later.'); |
|
| 63 | - } |
|
| 59 | + $systemDetails = systemDetails($sysID); |
|
| 60 | + if (null === $systemDetails) |
|
| 61 | + { |
|
| 62 | + return $this->message->reply('**Error:** ESI is down. Try again later.'); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $url = "https://zkillboard.com/api/stats/solarSystemID/{$sysID}/"; |
|
| 66 | - $json = json_decode(file_get_contents($url)); |
|
| 65 | + $url = "https://zkillboard.com/api/stats/solarSystemID/{$sysID}/"; |
|
| 66 | + $json = json_decode(file_get_contents($url)); |
|
| 67 | 67 | |
| 68 | - $regionID = $json->info->regionID; |
|
| 69 | - $regionName = getRegionName($regionID); |
|
| 68 | + $regionID = $json->info->regionID; |
|
| 69 | + $regionName = getRegionName($regionID); |
|
| 70 | 70 | |
| 71 | - $thisMonth = (string)date('Ym'); |
|
| 71 | + $thisMonth = (string)date('Ym'); |
|
| 72 | 72 | $lastMonth = (string)date('Ym', strtotime('first day of previous month')); |
| 73 | 73 | |
| 74 | 74 | $thisMonthKill = $json->months->$thisMonth->shipsDestroyed; |
@@ -78,21 +78,21 @@ discard block |
||
| 78 | 78 | $activeKills = $activePVP->kills->count; |
| 79 | 79 | $activeChars = $activePVP->characters->count; |
| 80 | 80 | |
| 81 | - $sysName = $systemDetails['name']; |
|
| 82 | - $secStatus = round($systemDetails['security_status'],2); |
|
| 81 | + $sysName = $systemDetails['name']; |
|
| 82 | + $secStatus = round($systemDetails['security_status'],2); |
|
| 83 | 83 | |
| 84 | - $npc = "https://api.eveonline.com/map/kills.xml.aspx"; |
|
| 85 | - $npc = new SimpleXMLElement(file_get_contents($npc)); |
|
| 86 | - foreach($npc->result->rowset->row as $row){ |
|
| 87 | - if($row->attributes()->solarSystemID == $sysID){ |
|
| 88 | - $npcKills = $row->attributes()->factionKills; |
|
| 89 | - $podKills = $row->attributes()->podKills; |
|
| 90 | - } |
|
| 91 | - } |
|
| 84 | + $npc = "https://api.eveonline.com/map/kills.xml.aspx"; |
|
| 85 | + $npc = new SimpleXMLElement(file_get_contents($npc)); |
|
| 86 | + foreach($npc->result->rowset->row as $row){ |
|
| 87 | + if($row->attributes()->solarSystemID == $sysID){ |
|
| 88 | + $npcKills = $row->attributes()->factionKills; |
|
| 89 | + $podKills = $row->attributes()->podKills; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $url = "https://zkillboard.com/system/{$sysID}/"; |
|
| 93 | + $url = "https://zkillboard.com/system/{$sysID}/"; |
|
| 94 | 94 | |
| 95 | - $msg = "```Systeminfo |
|
| 95 | + $msg = "```Systeminfo |
|
| 96 | 96 | Name: {$sysName} |
| 97 | 97 | Region: {$regionName} |
| 98 | 98 | Security: {$secStatus} |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | ``` |
| 110 | 110 | |
| 111 | 111 | More information: $url"; |
| 112 | - $this->logger->addInfo("sysInfo: Sending system information to {$user}"); |
|
| 113 | - $this->message->reply($msg); |
|
| 114 | - } |
|
| 115 | - return null; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - public function information() |
|
| 119 | - { |
|
| 120 | - return array( |
|
| 121 | - 'name' => 'sys', |
|
| 122 | - 'trigger' => $this->triggers, |
|
| 123 | - 'information' => 'Returns information for the given system' |
|
| 124 | - ); |
|
| 125 | - } |
|
| 112 | + $this->logger->addInfo("sysInfo: Sending system information to {$user}"); |
|
| 113 | + $this->message->reply($msg); |
|
| 114 | + } |
|
| 115 | + return null; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + public function information() |
|
| 119 | + { |
|
| 120 | + return array( |
|
| 121 | + 'name' => 'sys', |
|
| 122 | + 'trigger' => $this->triggers, |
|
| 123 | + 'information' => 'Returns information for the given system' |
|
| 124 | + ); |
|
| 125 | + } |
|
| 126 | 126 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | $channelID = (int) $msgData['message']['channelID']; |
| 31 | 31 | |
| 32 | - if(in_array($channelID, $this->excludeChannel, true)) |
|
| 32 | + if (in_array($channelID, $this->excludeChannel, true)) |
|
| 33 | 33 | { |
| 34 | 34 | return null; |
| 35 | 35 | } |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | $user = $msgData['message']['from']; |
| 41 | 41 | |
| 42 | 42 | $data = command($message, $this->information()['trigger'], $this->config['bot']['trigger']); |
| 43 | - if(isset($data['trigger'])) |
|
| 43 | + if (isset($data['trigger'])) |
|
| 44 | 44 | { |
| 45 | 45 | $messageString = strstr($data['messageString'], '@') ? str_replace('<@', '', str_replace('>', '', $data['messageString'])) : $data['messageString']; |
| 46 | - if(is_numeric($messageString)) |
|
| 46 | + if (is_numeric($messageString)) |
|
| 47 | 47 | { |
| 48 | 48 | $messageString = dbQueryField('SELECT name FROM usersSeen WHERE id = :id', 'name', array(':id' => $messageString)); |
| 49 | 49 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $sysID = urlencode(getSystemID($cleanString)); |
| 52 | 52 | |
| 53 | 53 | //Check if we get a system back, otherwise check for partials |
| 54 | - if(empty($sysID)) |
|
| 54 | + if (empty($sysID)) |
|
| 55 | 55 | { |
| 56 | 56 | return $this->message->reply('**Error:** no data available'); |
| 57 | 57 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | $regionID = $json->info->regionID; |
| 69 | 69 | $regionName = getRegionName($regionID); |
| 70 | 70 | |
| 71 | - $thisMonth = (string)date('Ym'); |
|
| 72 | - $lastMonth = (string)date('Ym', strtotime('first day of previous month')); |
|
| 71 | + $thisMonth = (string) date('Ym'); |
|
| 72 | + $lastMonth = (string) date('Ym', strtotime('first day of previous month')); |
|
| 73 | 73 | |
| 74 | 74 | $thisMonthKill = $json->months->$thisMonth->shipsDestroyed; |
| 75 | 75 | $lastMonthKill = $json->months->$lastMonth->shipsDestroyed; |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | $activeChars = $activePVP->characters->count; |
| 80 | 80 | |
| 81 | 81 | $sysName = $systemDetails['name']; |
| 82 | - $secStatus = round($systemDetails['security_status'],2); |
|
| 82 | + $secStatus = round($systemDetails['security_status'], 2); |
|
| 83 | 83 | |
| 84 | 84 | $npc = "https://api.eveonline.com/map/kills.xml.aspx"; |
| 85 | 85 | $npc = new SimpleXMLElement(file_get_contents($npc)); |
| 86 | - foreach($npc->result->rowset->row as $row){ |
|
| 87 | - if($row->attributes()->solarSystemID == $sysID){ |
|
| 86 | + foreach ($npc->result->rowset->row as $row) { |
|
| 87 | + if ($row->attributes()->solarSystemID == $sysID) { |
|
| 88 | 88 | $npcKills = $row->attributes()->factionKills; |
| 89 | 89 | $podKills = $row->attributes()->podKills; |
| 90 | 90 | } |