@@ -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 | } |