|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* The MIT License (MIT) |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) 2016 Robert Sardinia |
|
6
|
|
|
* |
|
7
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
9
|
|
|
* in the Software without restriction, including without limitation the rights |
|
10
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
11
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
12
|
|
|
* furnished to do so, subject to the following conditions: |
|
13
|
|
|
* |
|
14
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
15
|
|
|
* copies or substantial portions of the Software. |
|
16
|
|
|
* |
|
17
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
18
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
19
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
20
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
21
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
22
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
23
|
|
|
* SOFTWARE. |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
use discord\discord; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class notifications |
|
31
|
|
|
* @property keyID |
|
32
|
|
|
* @property vCode |
|
33
|
|
|
*/ |
|
34
|
|
|
class notifications |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
/** |
|
37
|
|
|
* @var |
|
38
|
|
|
*/ |
|
39
|
|
|
var $config; |
|
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var |
|
42
|
|
|
*/ |
|
43
|
|
|
var $discord; |
|
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var |
|
46
|
|
|
*/ |
|
47
|
|
|
var $logger; |
|
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var |
|
50
|
|
|
*/ |
|
51
|
|
|
var $nextCheck; |
|
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var |
|
54
|
|
|
*/ |
|
55
|
|
|
var $keys; |
|
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @var |
|
58
|
|
|
*/ |
|
59
|
|
|
var $keyCount; |
|
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @var |
|
62
|
|
|
*/ |
|
63
|
|
|
var $toDiscordChannel; |
|
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var |
|
66
|
|
|
*/ |
|
67
|
|
|
var $newestNotificationID; |
|
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @var |
|
70
|
|
|
*/ |
|
71
|
|
|
var $maxID; |
|
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @var |
|
74
|
|
|
*/ |
|
75
|
|
|
var $charApi; |
|
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @var |
|
78
|
|
|
*/ |
|
79
|
|
|
var $corpApi; |
|
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @var |
|
82
|
|
|
*/ |
|
83
|
|
|
var $alliApi; |
|
|
|
|
|
|
84
|
|
|
public $fuelChannel; |
|
85
|
|
|
public $fuelSkip; |
|
86
|
|
|
public $keyID; |
|
87
|
|
|
public $vCode; |
|
88
|
|
|
public $characterID; |
|
89
|
|
|
public $guild; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @param $config |
|
93
|
|
|
* @param $discord |
|
94
|
|
|
* @param $logger |
|
95
|
|
|
*/ |
|
96
|
|
|
function init($config, $discord, $logger) |
|
|
|
|
|
|
97
|
|
|
{ |
|
98
|
|
|
$this->config = $config; |
|
99
|
|
|
$this->discord = $discord; |
|
100
|
|
|
$this->logger = $logger; |
|
101
|
|
|
$this->toDiscordChannel = $config["plugins"]["notifications"]["channelID"]; |
|
102
|
|
|
$this->fuelChannel = $config["plugins"]["fuel"]["channelID"]; |
|
103
|
|
|
$this->fuelSkip = $config["plugins"]["fuel"]["skip"]; |
|
104
|
|
|
$this->newestNotificationID = getPermCache("newestNotificationID"); |
|
105
|
|
|
$this->maxID = 0; |
|
106
|
|
|
$this->keyID = $config["eve"]["apiKeys"]["user1"]["keyID"]; |
|
107
|
|
|
$this->vCode = $config["eve"]["apiKeys"]["user1"]["vCode"]; |
|
108
|
|
|
$this->characterID = $config["eve"]["apiKeys"]["user1"]["characterID"]; |
|
109
|
|
|
$this->guild = $config["bot"]["guild"]; |
|
110
|
|
|
$lastCheck = getPermCache("notificationsLastChecked{$this->keyID}"); |
|
111
|
|
|
if ($lastCheck == NULL) { |
|
112
|
|
|
// Schedule it for right now if first run |
|
113
|
|
|
setPermCache("notificationsLastChecked{$this->keyID}", time() - 5); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
/** |
|
117
|
|
|
* |
|
118
|
|
|
*/ |
|
119
|
|
View Code Duplication |
function tick() |
|
|
|
|
|
|
120
|
|
|
{ |
|
121
|
|
|
$lastChecked = getPermCache("notificationsLastChecked{$this->keyID}"); |
|
122
|
|
|
$keyID = $this->keyID; |
|
123
|
|
|
$vCode = $this->vCode; |
|
124
|
|
|
$characterID = $this->characterID; |
|
125
|
|
|
|
|
126
|
|
|
if ($lastChecked <= time()) { |
|
127
|
|
|
$this->logger->addInfo("Checking API Key {$keyID} for notifications.."); |
|
128
|
|
|
$this->getNotifications($keyID, $vCode, $characterID); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @param $keyID |
|
135
|
|
|
* @param $vCode |
|
136
|
|
|
* @param $characterID |
|
137
|
|
|
* @return null |
|
138
|
|
|
*/ |
|
139
|
|
|
function getNotifications($keyID, $vCode, $characterID) |
|
|
|
|
|
|
140
|
|
|
{ |
|
141
|
|
|
$discord = $this->discord; |
|
142
|
|
|
|
|
143
|
|
|
try { |
|
144
|
|
|
$url = "https://api.eveonline.com/char/Notifications.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}"; |
|
145
|
|
|
$xml = makeApiRequest($url); |
|
146
|
|
|
date_default_timezone_set('UTC'); |
|
147
|
|
|
$cached = $xml->cachedUntil[0]; |
|
148
|
|
|
$baseUnix = strtotime($cached); |
|
149
|
|
|
$cacheClr = $baseUnix - 13500; |
|
150
|
|
|
if (!isset($this->fuelChannel)) { |
|
151
|
|
|
$this->fuelChannel = $this->toDiscordChannel; |
|
152
|
|
|
} |
|
153
|
|
View Code Duplication |
if ($cacheClr <= time()) { |
|
|
|
|
|
|
154
|
|
|
$weirdTime = time() + 1830; |
|
155
|
|
|
$cacheTimer = gmdate("Y-m-d H:i:s", $weirdTime); |
|
156
|
|
|
setPermCache("notificationsLastChecked{$keyID}", $weirdTime); |
|
157
|
|
|
} else { |
|
158
|
|
|
$cacheTimer = gmdate("Y-m-d H:i:s", $cacheClr); |
|
159
|
|
|
setPermCache("notificationsLastChecked{$keyID}", $cacheClr); |
|
160
|
|
|
} |
|
161
|
|
|
$data = json_decode(json_encode(simplexml_load_string(downloadData($url), |
|
162
|
|
|
"SimpleXMLElement", LIBXML_NOCDATA)), true); |
|
163
|
|
|
$data = $data["result"]["rowset"]["row"]; |
|
164
|
|
|
// If there is no data, just quit.. |
|
165
|
|
|
if (empty($data)) { |
|
166
|
|
|
return; |
|
167
|
|
|
} |
|
168
|
|
|
$fixedData = array(); |
|
169
|
|
|
// Sometimes there is only ONE notification, so.. yeah.. |
|
170
|
|
|
if (isset($data["@attributes"])) { $fixedData[] = $data["@attributes"]; } |
|
171
|
|
|
if (count($data) > 1) { |
|
172
|
|
|
foreach ($data as $multiNotif) { |
|
173
|
|
|
$fixedData[] = $multiNotif["@attributes"]; |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
foreach ($fixedData as $notification) { |
|
177
|
|
|
$notificationID = $notification["notificationID"]; |
|
178
|
|
|
$typeID = $notification["typeID"]; |
|
179
|
|
|
$sentDate = $notification["sentDate"]; |
|
180
|
|
|
$channelID = $this->toDiscordChannel; |
|
181
|
|
|
if ($notificationID > $this->newestNotificationID) { |
|
182
|
|
|
$notificationString = explode("\n", $this->getNotificationText($keyID, $vCode, $characterID, |
|
183
|
|
|
$notificationID)); |
|
184
|
|
|
switch ($typeID) { |
|
185
|
|
View Code Duplication |
case 5: // War Declared |
|
|
|
|
|
|
186
|
|
|
$aggAllianceID = trim(explode(": ", $notificationString[2])[1]); |
|
187
|
|
|
$aggAllianceName = apiCharacterName($aggAllianceID); |
|
188
|
|
|
$msg = "@everyone | War declared by {$aggAllianceName}. Fighting begins in roughly 24 hours."; |
|
189
|
|
|
break; |
|
190
|
|
View Code Duplication |
case 7: // War Declared corp |
|
|
|
|
|
|
191
|
|
|
$aggCorpID = trim(explode(": ", $notificationString[2])[1]); |
|
192
|
|
|
$aggCorpName = apiCharacterName($aggCorpID); |
|
193
|
|
|
$msg = "@everyone | War declared by {$aggCorpName}. Fighting begins in roughly 24 hours."; |
|
194
|
|
|
break; |
|
195
|
|
View Code Duplication |
case 8: // Alliance war invalidated by CONCORD |
|
|
|
|
|
|
196
|
|
|
$aggAllianceID = trim(explode(": ", $notificationString[2])[1]); |
|
197
|
|
|
$aggAllianceName = apiCharacterName($aggAllianceID); |
|
198
|
|
|
$msg = "War with {$aggAllianceName} has been invalidated. Fighting ends in roughly 24 hours."; |
|
199
|
|
|
break; |
|
200
|
|
|
case 10: // Bill issued |
|
201
|
|
|
$msg = "skip"; |
|
202
|
|
|
break; |
|
203
|
|
|
case 13: // Bill issued |
|
204
|
|
|
$msg = "skip"; |
|
205
|
|
|
break; |
|
206
|
|
|
case 14: // Bounty payment |
|
207
|
|
|
$msg = "skip"; |
|
208
|
|
|
break; |
|
209
|
|
|
case 16: // Mail |
|
210
|
|
|
$msg = "skip"; |
|
211
|
|
|
break; |
|
212
|
|
|
case 19: // corp tax changed |
|
213
|
|
|
$corpID = trim(explode(": ", $notificationString[0])[1]); |
|
214
|
|
|
$corpName = apiCharacterName($corpID); |
|
215
|
|
|
$oldTax = trim(explode(": ", $notificationString[2])[1]); |
|
216
|
|
|
$newTax = trim(explode(": ", $notificationString[1])[1]); |
|
217
|
|
|
$msg = "{$corpName} tax changed from {$oldTax}% to {$newTax}%"; |
|
218
|
|
|
break; |
|
219
|
|
|
case 21: // member left corp |
|
220
|
|
|
$msg = "skip"; |
|
221
|
|
|
break; |
|
222
|
|
View Code Duplication |
case 31: // Alliance war invalidated by CONCORD |
|
|
|
|
|
|
223
|
|
|
$aggAllianceID = trim(explode(": ", $notificationString[2])[1]); |
|
224
|
|
|
$aggAllianceName = apiCharacterName($aggAllianceID); |
|
225
|
|
|
$msg = "War with {$aggAllianceName} has been invalidated. Fighting ends in roughly 24 hours."; |
|
226
|
|
|
break; |
|
227
|
|
|
case 35: // Insurance payment |
|
228
|
|
|
$msg = "skip"; |
|
229
|
|
|
break; |
|
230
|
|
View Code Duplication |
case 41: // System lost |
|
|
|
|
|
|
231
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[2])[1]); |
|
232
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
233
|
|
|
$allianceID = trim(explode(": ", $notificationString[0])[1]); |
|
234
|
|
|
$allianceName = apiCharacterName($allianceID); |
|
235
|
|
|
$msg = "{$allianceName} has lost control of **{$systemName}**"; |
|
236
|
|
|
break; |
|
237
|
|
View Code Duplication |
case 43: // System captured |
|
|
|
|
|
|
238
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[2])[1]); |
|
239
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
240
|
|
|
$allianceID = trim(explode(": ", $notificationString[0])[1]); |
|
241
|
|
|
$allianceName = apiCharacterName($allianceID); |
|
242
|
|
|
$msg = "{$allianceName} now controls **{$systemName}**"; |
|
243
|
|
|
break; |
|
244
|
|
|
case 52: // clone revoked |
|
245
|
|
|
$msg = "skip"; |
|
246
|
|
|
break; |
|
247
|
|
|
case 54: // insurance |
|
248
|
|
|
$msg = "skip"; |
|
249
|
|
|
break; |
|
250
|
|
|
case 57: // jump clone destruction |
|
251
|
|
|
$msg = "skip"; |
|
252
|
|
|
break; |
|
253
|
|
|
case 71: // Mission Expiration |
|
254
|
|
|
$msg = "skip"; |
|
255
|
|
|
break; |
|
256
|
|
|
case 75: // POS / POS Module under attack |
|
257
|
|
|
$aggAllianceID = trim(explode(": ", $notificationString[0])[1]); |
|
258
|
|
|
$aggAllianceName = apiCharacterName($aggAllianceID); |
|
259
|
|
|
$aggCorpID = trim(explode(": ", $notificationString[1])[1]); |
|
260
|
|
|
$aggCorpName = apiCharacterName($aggCorpID); |
|
261
|
|
|
$aggID = trim(explode(": ", $notificationString[2])[1]); |
|
262
|
|
|
$aggCharacterName = apiCharacterName($aggID); |
|
263
|
|
|
$moonID = trim(explode(": ", $notificationString[5])[1]); |
|
264
|
|
|
$moonName = apiCharacterName($moonID); |
|
265
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[7])[1]); |
|
266
|
|
|
$typeID = trim(explode(": ", $notificationString[8])[1]); |
|
267
|
|
|
$typeName = apiTypeName($typeID); |
|
268
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
269
|
|
|
$msg = "**{$typeName}** under attack in **{$systemName} - {$moonName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName})."; |
|
270
|
|
|
break; |
|
271
|
|
|
case 76: // Tower resource alert |
|
272
|
|
|
$moonID = trim(explode(": ", $notificationString[2])[1]); |
|
273
|
|
|
$moonName = apiCharacterName($moonID); |
|
274
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[3])[1]); |
|
275
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
276
|
|
|
$blocksRemaining = trim(explode(": ", $notificationString[6])[1]); |
|
277
|
|
|
$typeID = trim(explode(": ", $notificationString[7])[1]); |
|
278
|
|
|
$channelID = $this->fuelChannel; |
|
279
|
|
|
$typeName = apiTypeName($typeID); |
|
280
|
|
|
$msg = "POS in {$systemName} - {$moonName} needs fuel. Only {$blocksRemaining} {$typeName}'s remaining."; |
|
281
|
|
|
if ($this->fuelSkip != "false") { |
|
282
|
|
|
$msg = "skip"; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
break; |
|
286
|
|
|
case 88: // IHUB is being attacked |
|
287
|
|
|
$aggAllianceID = trim(explode(": ", $notificationString[0])[1]); |
|
288
|
|
|
$aggAllianceName = apiCharacterName($aggAllianceID); |
|
289
|
|
|
$aggCorpID = trim(explode(": ", $notificationString[0])[1]); |
|
290
|
|
|
$aggCorpName = apiCharacterName($aggCorpID); |
|
291
|
|
|
$aggID = trim(explode(": ", $notificationString[1])[1]); |
|
292
|
|
|
$aggCharacterName = apiCharacterName($aggID); |
|
293
|
|
|
$armorValue = trim(explode(": ", $notificationString[3])[1]); |
|
294
|
|
|
$hullValue = trim(explode(": ", $notificationString[4])[1]); |
|
295
|
|
|
$shieldValue = trim(explode(": ", $notificationString[5])[1]); |
|
296
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[6])[1]); |
|
297
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
298
|
|
|
$msg = "IHUB under attack in **{$systemName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName}). Status: Hull: {$hullValue}, Armor: {$armorValue}, Shield: {$shieldValue}"; |
|
299
|
|
|
break; |
|
300
|
|
|
case 93: // Customs office is being attacked |
|
301
|
|
|
$aggAllianceID = trim(explode(": ", $notificationString[0])[1]); |
|
302
|
|
|
$aggAllianceName = apiCharacterName($aggAllianceID); |
|
303
|
|
|
$aggCorpID = trim(explode(": ", $notificationString[0])[1]); |
|
304
|
|
|
$aggCorpName = apiCharacterName($aggCorpID); |
|
305
|
|
|
$aggID = trim(explode(": ", $notificationString[2])[1]); |
|
306
|
|
|
$aggCharacterName = apiCharacterName($aggID); |
|
307
|
|
|
$shieldValue = trim(explode(": ", $notificationString[5])[1]); |
|
308
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[6])[1]); |
|
309
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
310
|
|
|
$msg = "Customs Office under attack in **{$systemName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName}). Shield Status: {$shieldValue}"; |
|
311
|
|
|
break; |
|
312
|
|
|
case 94: // POCO Reinforced |
|
313
|
|
|
$msg = "Customs Office reinforced."; |
|
314
|
|
|
break; |
|
315
|
|
|
case 95: // IHub Transfer |
|
316
|
|
|
$msg = "skip"; |
|
317
|
|
|
break; |
|
318
|
|
|
case 102: // War support offer? I think? |
|
319
|
|
|
$msg = "skip"; |
|
320
|
|
|
break; |
|
321
|
|
|
case 103: // War support offer? I think? |
|
322
|
|
|
$msg = "skip"; |
|
323
|
|
|
break; |
|
324
|
|
|
case 111: // Bounty |
|
325
|
|
|
$msg = "skip"; |
|
326
|
|
|
break; |
|
327
|
|
|
case 128: // Corp App |
|
328
|
|
|
$msg = "skip"; |
|
329
|
|
|
break; |
|
330
|
|
|
case 129: // App denied |
|
331
|
|
|
$msg = "skip"; |
|
332
|
|
|
break; |
|
333
|
|
|
case 130: // Corp app withdrawn? |
|
334
|
|
|
$msg = "skip"; |
|
335
|
|
|
break; |
|
336
|
|
|
case 138: // Clone activation |
|
337
|
|
|
$msg = "skip"; |
|
338
|
|
|
break; |
|
339
|
|
|
case 140: // Kill report |
|
340
|
|
|
$msg = "skip"; |
|
341
|
|
|
break; |
|
342
|
|
|
case 141: // Kill report |
|
343
|
|
|
$msg = "skip"; |
|
344
|
|
|
break; |
|
345
|
|
View Code Duplication |
case 147: // Entosis has started |
|
|
|
|
|
|
346
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[0])[1]); |
|
347
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
348
|
|
|
$typeID = trim(explode(": ", $notificationString[1])[1]); |
|
349
|
|
|
$typeName = apiTypeName($typeID); |
|
350
|
|
|
$msg = "Entosis has started in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
|
351
|
|
|
break; |
|
352
|
|
View Code Duplication |
case 148: // Entosis enabled a module ?????? |
|
|
|
|
|
|
353
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[0])[1]); |
|
354
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
355
|
|
|
$typeID = trim(explode(": ", $notificationString[1])[1]); |
|
356
|
|
|
$typeName = apiTypeName($typeID); |
|
357
|
|
|
$msg = "Entosis has enabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
|
358
|
|
|
break; |
|
359
|
|
View Code Duplication |
case 149: // Entosis disabled a module |
|
|
|
|
|
|
360
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[0])[1]); |
|
361
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
362
|
|
|
$typeID = trim(explode(": ", $notificationString[1])[1]); |
|
363
|
|
|
$typeName = apiTypeName($typeID); |
|
364
|
|
|
$msg = "Entosis has disabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
|
365
|
|
|
break; |
|
366
|
|
View Code Duplication |
case 160: // Entosis successful |
|
|
|
|
|
|
367
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[2])[1]); |
|
368
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
369
|
|
|
$msg = "Hostile entosis successful. A structure in **{$systemName}** has entered reinforced mode."; |
|
370
|
|
|
break; |
|
371
|
|
View Code Duplication |
case 161: // Command Nodes Decloaking |
|
|
|
|
|
|
372
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[2])[1]); |
|
373
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
374
|
|
|
$msg = "Command nodes decloaking for **{$systemName}**"; |
|
375
|
|
|
break; |
|
376
|
|
View Code Duplication |
case 162: // TCU Destroyed |
|
|
|
|
|
|
377
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[0])[1]); |
|
378
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
379
|
|
|
$msg = "Entosis successful, TCU in **{$systemName}** has been destroyed."; |
|
380
|
|
|
break; |
|
381
|
|
View Code Duplication |
case 163: // Outpost freeport |
|
|
|
|
|
|
382
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[1])[1]); |
|
383
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
384
|
|
|
$msg = "Station in **{$systemName}** has now entered freeport mode."; |
|
385
|
|
|
break; |
|
386
|
|
View Code Duplication |
case 182: // Citadel being anchored |
|
|
|
|
|
|
387
|
|
|
$corpName = trim(explode(": ", $notificationString[1])[1]); |
|
388
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[2])[1]); |
|
389
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
390
|
|
|
$msg = "Citadel owned by **{$corpName}** is being anchored in **{$systemName}**."; |
|
391
|
|
|
break; |
|
392
|
|
|
case 184: // Citadel under attack |
|
393
|
|
|
$aggID = trim(explode(": ", $notificationString[7])[1]); |
|
394
|
|
|
$aggCharacterName = apiCharacterName($aggID); |
|
395
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[15])[1]); |
|
396
|
|
|
$aggAllianceID = trim(explode(": ", $notificationString[0])[1]); |
|
397
|
|
|
$aggAllianceName = apiCharacterName($aggAllianceID); |
|
398
|
|
|
$aggCorpID = trim(explode("- ", $notificationString[11])[1]); |
|
399
|
|
|
$aggCorpName = apiCharacterName($aggCorpID); |
|
400
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
401
|
|
|
$msg = "@everyone | Citadel under attack in **{$systemName}** by **{$aggCharacterName}** ({$aggCorpName} / {$aggAllianceName})."; |
|
402
|
|
|
break; |
|
403
|
|
View Code Duplication |
case 185: // Citadel online |
|
|
|
|
|
|
404
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[0])[1]); |
|
405
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
406
|
|
|
$msg = "Citadel now online in **{$systemName}**."; |
|
407
|
|
|
break; |
|
408
|
|
View Code Duplication |
case 188: // Citadel destroyed |
|
|
|
|
|
|
409
|
|
|
$corpID = trim(explode("- ", $notificationString[3])[1]); |
|
410
|
|
|
$corpName = apiCharacterName($corpID); |
|
411
|
|
|
$solarSystemID = trim(explode(": ", $notificationString[5])[1]); |
|
412
|
|
|
$systemName = apiCharacterName($solarSystemID); |
|
413
|
|
|
$msg = "Citadel owned by **{$corpName}** in **{$systemName}** has been destroyed."; |
|
414
|
|
|
break; |
|
415
|
|
|
case 199: // citadel delivery |
|
416
|
|
|
$msg = "skip"; |
|
417
|
|
|
break; |
|
418
|
|
|
default: // Unknown typeID |
|
419
|
|
|
$string = implode(" ", $notificationString); |
|
420
|
|
|
$msg = "typeID {$typeID} is an unmapped notification, please create a Github issue with this entire message and please include what the in-game notification is. {$string}"; |
|
421
|
|
|
break; |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
if ($msg == "skip") { |
|
425
|
|
|
return null; |
|
426
|
|
|
} |
|
427
|
|
|
$this->logger->addInfo("Notification sent to channel {$this->toDiscordChannel}, Message - {$msg}"); |
|
428
|
|
|
$guild = $discord->guilds->get('id', $this->guild); |
|
429
|
|
|
$channel = $guild->channels->get('id', $channelID); |
|
430
|
|
|
$channel->sendMessage($msg, false); |
|
431
|
|
|
// Find the maxID so we don't output this message again in the future |
|
432
|
|
|
$this->maxID = max($notificationID, $this->maxID); |
|
433
|
|
|
$this->newestNotificationID = $this->maxID; |
|
434
|
|
|
setPermCache("newestNotificationID", $this->maxID); |
|
435
|
|
|
} |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
$this->logger->addInfo("Next Notification Check At: {$cacheTimer} EVE Time"); |
|
439
|
|
|
} catch (Exception $e) { |
|
440
|
|
|
$this->logger->addInfo("Notification Error: " . $e->getMessage()); |
|
441
|
|
|
} |
|
442
|
|
|
return null; |
|
443
|
|
|
} |
|
444
|
|
|
/** |
|
445
|
|
|
* @param $keyID |
|
446
|
|
|
* @param $vCode |
|
447
|
|
|
* @param $characterID |
|
448
|
|
|
* @param $notificationID |
|
449
|
|
|
* @return string |
|
450
|
|
|
*/ |
|
451
|
|
|
function getNotificationText($keyID, $vCode, $characterID, $notificationID) |
|
|
|
|
|
|
452
|
|
|
{ |
|
453
|
|
|
$url = "https://api.eveonline.com/char/NotificationTexts.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}&IDs={$notificationID}"; |
|
454
|
|
|
$data = json_decode(json_encode(simplexml_load_string(downloadData($url), |
|
455
|
|
|
"SimpleXMLElement", LIBXML_NOCDATA)), true); |
|
456
|
|
|
$data = $data["result"]["rowset"]["row"]; |
|
457
|
|
|
return $data; |
|
458
|
|
|
} |
|
459
|
|
|
/** |
|
460
|
|
|
* |
|
461
|
|
|
*/ |
|
462
|
|
|
function onMessage() |
|
|
|
|
|
|
463
|
|
|
{ |
|
464
|
|
|
} |
|
465
|
|
|
|
|
466
|
|
|
|
|
467
|
|
|
/** |
|
468
|
|
|
* @return array |
|
469
|
|
|
*/ |
|
470
|
|
|
function information() |
|
|
|
|
|
|
471
|
|
|
{ |
|
472
|
|
|
return array( |
|
473
|
|
|
"name" => "", |
|
474
|
|
|
"trigger" => array(""), |
|
475
|
|
|
"information" => ""); |
|
476
|
|
|
} |
|
477
|
|
|
} |
|
478
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.