Conditions | 188 |
Paths | > 20000 |
Total Lines | 586 |
Code Lines | 538 |
Lines | 192 |
Ratio | 32.76 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
115 | private function getNotifications($keyID, $vCode, $characterID) |
||
116 | { |
||
117 | try { |
||
118 | $url = "https://api.eveonline.com/char/Notifications.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}"; |
||
119 | $xml = makeApiRequest($url); |
||
120 | date_default_timezone_set('UTC'); |
||
121 | $cached = $xml->cachedUntil[0]; |
||
122 | $baseUnix = strtotime($cached); |
||
123 | $cacheClr = $baseUnix - 13500; |
||
124 | if (null === $this->fuelChannel) { |
||
125 | $this->fuelChannel = $this->toDiscordChannel; |
||
126 | } |
||
127 | //Set timer for next key based on number of keys |
||
128 | $nextKey = (1900 / (int)$this->numberOfKeys) + time(); |
||
129 | $nextKeyTime = gmdate('Y-m-d H:i:s', $nextKey); |
||
130 | setPermCache('notificationsLastChecked', $nextKey); |
||
131 | //Set cache timer for api key |
||
132 | View Code Duplication | if ($cacheClr <= time()) { |
|
133 | $weirdTime = time() + 1830; |
||
134 | setPermCache("notificationsLastChecked{$keyID}", $weirdTime); |
||
135 | } else { |
||
136 | setPermCache("notificationsLastChecked{$keyID}", $cacheClr); |
||
137 | } |
||
138 | $data = json_decode(json_encode(simplexml_load_string(downloadData($url), |
||
139 | 'SimpleXMLElement', LIBXML_NOCDATA)), true); |
||
140 | // If there is no data, just quit.. |
||
141 | if (empty($data['result']['rowset']['row'])) { |
||
142 | return null; |
||
143 | } |
||
144 | $data = $data['result']['rowset']['row']; |
||
145 | $fixedData = array(); |
||
146 | // Sometimes there is only ONE notification, so.. yeah.. |
||
147 | if (isset($data['@attributes'])) { |
||
148 | $fixedData[] = $data['@attributes']; |
||
149 | } |
||
150 | if (count($data) > 1) { |
||
151 | foreach ($data as $multiNotif) { |
||
152 | $fixedData[] = $multiNotif['@attributes']; |
||
153 | } |
||
154 | } |
||
155 | foreach ($fixedData as $notification) { |
||
156 | $notificationID = $notification['notificationID']; |
||
157 | $typeID = $notification['typeID']; |
||
158 | $sentDate = $notification['sentDate']; |
||
159 | $channelID = $this->toDiscordChannel; |
||
160 | if ($notificationID > $this->newestNotificationID) { |
||
161 | $notificationString = $this->getNotificationText($keyID, $vCode, $characterID, $notificationID); |
||
162 | $notificationArray = explode("\n", $this->getNotificationText($keyID, $vCode, $characterID, $notificationID)); |
||
163 | switch ($typeID) { |
||
164 | case 1: // Old |
||
165 | $msg = 'skip'; |
||
166 | break; |
||
167 | case 2: // biomassed |
||
168 | $msg = 'skip'; |
||
169 | break; |
||
170 | case 3: // medal awarded |
||
171 | $msg = 'skip'; |
||
172 | break; |
||
173 | case 4: // alliance bill |
||
174 | $msg = 'skip'; |
||
175 | break; |
||
176 | View Code Duplication | case 5: // War Declared |
|
177 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
178 | $defAllianceName = allianceName($defAllianceID[0]); |
||
179 | if ($defAllianceName === '' || ' ' || null) { |
||
180 | $defAllianceName = corpName($defAllianceID[0]); |
||
181 | } |
||
182 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
183 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
184 | if ($aggAllianceName === '' || ' ' || null) { |
||
185 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
186 | } |
||
187 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
188 | $msg = '@everyone | War declared. Fighting begins in roughly 24 hours.'; |
||
189 | } else { |
||
190 | $msg = "@everyone | War declared by {$aggAllianceName} against {$defAllianceName}. Fighting begins in roughly 24 hours."; |
||
191 | } |
||
192 | break; |
||
193 | case 6: // Corp joins war (Not enough info in api to say who the 3rd party is) |
||
194 | $defAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
195 | $aggAllianceID = trim(explode(': ', $notificationArray[2])[1]); |
||
196 | $defAllianceName = allianceName($defAllianceID); |
||
197 | $aggAllianceName = allianceName($aggAllianceID); |
||
198 | $msg = "The war between {$aggAllianceName} and {$defAllianceName} has been joined by a third party. This new group may begin fighting in roughly 24 hours."; |
||
199 | break; |
||
200 | case 7: // War Declared corp |
||
201 | $defCorpID = trim(explode(': ', $notificationArray[0])[1]); |
||
202 | $aggCorpID = trim(explode(': ', $notificationArray[2])[1]); |
||
203 | $defCorpName = corpName($defCorpID); |
||
204 | $aggCorpName = corpName($aggCorpID); |
||
205 | $msg = "@everyone | War declared by {$aggCorpName} against {$defCorpName}. Fighting begins in roughly 24 hours."; |
||
206 | break; |
||
207 | View Code Duplication | case 8: // Alliance war invalidated by CONCORD |
|
208 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
209 | $defAllianceName = allianceName($defAllianceID[0]); |
||
210 | if ($defAllianceName === 'Unknown' || '' || ' ' || null) { |
||
211 | $defAllianceName = corpName($defAllianceID[0]); |
||
212 | } |
||
213 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
214 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
215 | if ($aggAllianceName === 'Unknown' || '' || ' ' || null) { |
||
216 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
217 | } |
||
218 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
219 | $msg = 'The war has been invalidated. Fighting ends in roughly 24 hours.'; |
||
220 | } else { |
||
221 | $msg = "The war between {$aggAllianceName} and {$defAllianceName} has been invalidated. Fighting ends in roughly 24 hours."; |
||
222 | } |
||
223 | break; |
||
224 | case 9: // Pilot bill |
||
225 | $msg = 'skip'; |
||
226 | break; |
||
227 | case 10: // Bill issued |
||
228 | $msg = 'skip'; |
||
229 | break; |
||
230 | case 11: // Bill stuff |
||
231 | $msg = 'skip'; |
||
232 | break; |
||
233 | case 12: // Bill Stuff |
||
234 | $msg = 'skip'; |
||
235 | break; |
||
236 | case 13: // Bill issued |
||
237 | $msg = 'skip'; |
||
238 | break; |
||
239 | case 14: // Bounty payment |
||
240 | $msg = 'skip'; |
||
241 | break; |
||
242 | case 16: // Mail |
||
243 | $msg = 'skip'; |
||
244 | break; |
||
245 | case 17: // Corp app |
||
246 | $msg = 'skip'; |
||
247 | break; |
||
248 | case 18: // Corp app |
||
249 | $msg = 'skip'; |
||
250 | break; |
||
251 | case 19: // corp tax changed |
||
252 | $corpID = trim(explode(': ', $notificationArray[0])[1]); |
||
253 | $corpName = corpName($corpID); |
||
254 | $oldTax = trim(explode(': ', $notificationArray[2])[1]); |
||
255 | $newTax = trim(explode(': ', $notificationArray[1])[1]); |
||
256 | $msg = "{$corpName} tax changed from {$oldTax}% to {$newTax}%"; |
||
257 | if ($this->allianceOnly === 'true') { |
||
258 | $msg = 'skip'; |
||
259 | } |
||
260 | break; |
||
261 | case 20: // Corp news? |
||
262 | $msg = 'skip'; |
||
263 | break; |
||
264 | case 21: // member left corp |
||
265 | $msg = 'skip'; |
||
266 | break; |
||
267 | case 22: // ceo resign |
||
268 | preg_match('/(?<=newCeoID: )\S+/i', $notificationString, $newCeoID); |
||
269 | preg_match('/(?<=oldCeoID: )\S+/i', $notificationString, $oldCeoID); |
||
270 | preg_match('/(?<=corpID: )\S+/i', $notificationString, $corpID); |
||
271 | $newCeoName = characterName($newCeoID); |
||
272 | $oldCeoName = characterName($oldCeoID); |
||
273 | $corpName = corpName($corpID); |
||
274 | $msg = "$oldCeoName has resigned as CEO for $corpName, $newCeoName has been appointed as the new CEO."; |
||
275 | break; |
||
276 | case 25: // corp vote |
||
277 | $msg = 'skip'; |
||
278 | break; |
||
279 | View Code Duplication | case 27: // Corp declares war |
|
280 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
281 | $defAllianceName = allianceName($defAllianceID[0]); |
||
282 | if ($defAllianceName === '' || ' ' || null) { |
||
283 | $defAllianceName = corpName($defAllianceID[0]); |
||
284 | } |
||
285 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
286 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
287 | if ($aggAllianceName === '' || ' ' || null) { |
||
288 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
289 | } |
||
290 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
291 | $msg = '@everyone | War declared. Fighting begins in roughly 24 hours.'; |
||
292 | } else { |
||
293 | $msg = "**{$aggAllianceName}** has declared war on **{$defAllianceName}**. |
||
294 | Within 24 hours fighting can legally occur between those involved. If war is due to a corporation at war joining or leaving an alliance, then the war starts immediately instead."; |
||
295 | } |
||
296 | break; |
||
297 | View Code Duplication | case 29: // War Surrender |
|
298 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defCorpID); |
||
299 | $defCorpName = allianceName($defCorpID[0]); |
||
300 | if ($defCorpName === '' || ' ' || null) { |
||
301 | $defCorpName = corpName($defCorpID[0]); |
||
302 | } |
||
303 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggCorpID); |
||
304 | $aggCorpName = allianceName($aggCorpID[0]); |
||
305 | if ($aggCorpName === '' || ' ' || null) { |
||
306 | $aggCorpName = corpName($aggCorpID[0]); |
||
307 | } |
||
308 | if ($aggCorpName === null || '' || $defCorpName === null || '') { |
||
309 | $msg = 'A war has ended. Fighting ends in roughly 24 hours.'; |
||
310 | } else { |
||
311 | $msg = "The war between **{$aggCorpName}** and **{$defCorpName}** has ended. Fighting ends in roughly 24 hours."; |
||
312 | } |
||
313 | break; |
||
314 | View Code Duplication | case 30: // Corp retracts war |
|
315 | preg_match('/(?<=againstID: )\S+/i', $notificationString, $defAllianceID); |
||
316 | $defAllianceName = allianceName($defAllianceID[0]); |
||
317 | if ($defAllianceName === '' || ' ' || null) { |
||
318 | $defAllianceName = corpName($defAllianceID[0]); |
||
319 | } |
||
320 | preg_match('/(?<=declaredByID: )\S+/i', $notificationString, $aggAllianceID); |
||
321 | $aggAllianceName = allianceName($aggAllianceID[0]); |
||
322 | if ($aggAllianceName === '' || ' ' || null) { |
||
323 | $aggAllianceName = corpName($aggAllianceID[0]); |
||
324 | } |
||
325 | if ($aggAllianceName === null || '' || $defAllianceName === null || '') { |
||
326 | $msg = '@everyone | War has been retracted. Fighting ends in roughly 24 hours.'; |
||
327 | } else { |
||
328 | $msg = "The war between **{$aggAllianceName}** and **{$defAllianceName}** is coming to an end. **{$aggAllianceName}** has retracted the war against **{$defAllianceName}**. The war will be declared as being over after approximately 24 hours."; |
||
329 | } |
||
330 | break; |
||
331 | case 31: // Alliance war invalidated by CONCORD |
||
332 | $aggAllianceID = trim(explode(': ', $notificationArray[2])[1]); |
||
333 | $aggAllianceName = allianceName($aggAllianceID); |
||
334 | $msg = "War with {$aggAllianceName} has been invalidated. Fighting ends in roughly 24 hours."; |
||
335 | break; |
||
336 | case 34: // Noob ship |
||
337 | $msg = 'skip'; |
||
338 | break; |
||
339 | case 35: // Insurance payment |
||
340 | $msg = 'skip'; |
||
341 | break; |
||
342 | case 36: // Insurance |
||
343 | $msg = 'skip'; |
||
344 | break; |
||
345 | View Code Duplication | case 41: // System lost |
|
346 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
347 | $systemName = getSystemName($solarSystemID[0]); |
||
348 | $allianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
349 | $allianceName = allianceName($allianceID); |
||
350 | $msg = "{$allianceName} has lost control of **{$systemName}**"; |
||
351 | break; |
||
352 | View Code Duplication | case 43: // System captured |
|
353 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
354 | $systemName = getSystemName($solarSystemID[0]); |
||
355 | $allianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
356 | $allianceName = allianceName($allianceID); |
||
357 | $msg = "{$allianceName} now controls **{$systemName}**"; |
||
358 | break; |
||
359 | case 45: // Tower anchoring |
||
360 | $msg = 'skip'; |
||
361 | break; |
||
362 | case 50: // Office Expired |
||
363 | $msg = 'skip'; |
||
364 | break; |
||
365 | case 52: // clone revoked |
||
366 | $msg = 'skip'; |
||
367 | break; |
||
368 | case 54: // insurance |
||
369 | $msg = 'skip'; |
||
370 | break; |
||
371 | case 55: // insurance |
||
372 | $msg = 'skip'; |
||
373 | break; |
||
374 | case 57: // jump clone destruction |
||
375 | $msg = 'skip'; |
||
376 | break; |
||
377 | case 69: // agent info |
||
378 | $msg = 'skip'; |
||
379 | break; |
||
380 | case 71: // Mission Expiration |
||
381 | $msg = 'skip'; |
||
382 | break; |
||
383 | case 73: // special mission |
||
384 | $msg = 'skip'; |
||
385 | break; |
||
386 | case 75: // POS / POS Module under attack |
||
387 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
388 | $aggAllianceName = allianceName($aggAllianceID); |
||
389 | $aggCorpID = trim(explode(': ', $notificationArray[1])[1]); |
||
390 | $aggCorpName = corpName($aggCorpID); |
||
391 | $aggID = trim(explode(': ', $notificationArray[2])[1]); |
||
392 | $aggCharacterName = characterName($aggID); |
||
393 | $moonID = trim(explode(': ', $notificationArray[5])[1]); |
||
394 | $moonName = apiMoonName($moonID); |
||
395 | $typeID = trim(explode(': ', $notificationArray[8])[1]); |
||
396 | $typeName = getTypeName($typeID); |
||
397 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
398 | $systemName = getSystemName($solarSystemID[0]); |
||
399 | $msg = "**{$typeName}** under attack in **{$systemName} - {$moonName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName})."; |
||
400 | if ($this->allianceOnly === 'true') { |
||
401 | $msg = 'skip'; |
||
402 | } |
||
403 | break; |
||
404 | case 76: // Tower resource alert |
||
405 | $moonID = trim(explode(': ', $notificationArray[2])[1]); |
||
406 | $moonName = apiMoonName($moonID); |
||
407 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
408 | $systemName = getSystemName($solarSystemID[0]); |
||
409 | $blocksRemaining = trim(explode(': ', $notificationArray[6])[1]); |
||
410 | $typeID = trim(explode(': ', $notificationArray[7])[1]); |
||
411 | $channelID = $this->fuelChannel; |
||
412 | $typeName = getTypeName($typeID); |
||
413 | $msg = "POS in {$systemName} - {$moonName} needs fuel. Only {$blocksRemaining} {$typeName}'s remaining."; |
||
414 | if ($this->fuelSkip === 'true' || $this->allianceOnly === 'true') { |
||
415 | $msg = 'skip'; |
||
416 | } |
||
417 | |||
418 | break; |
||
419 | case 88: // IHUB is being attacked |
||
420 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
421 | $aggAllianceName = allianceName($aggAllianceID); |
||
422 | $aggCorpID = trim(explode(': ', $notificationArray[0])[1]); |
||
423 | $aggCorpName = corpName($aggCorpID); |
||
424 | $aggID = trim(explode(': ', $notificationArray[1])[1]); |
||
425 | $aggCharacterName = characterName($aggID); |
||
426 | $armorValue = trim(explode(': ', $notificationArray[3])[1]); |
||
427 | $hullValue = trim(explode(': ', $notificationArray[4])[1]); |
||
428 | $shieldValue = trim(explode(': ', $notificationArray[5])[1]); |
||
429 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
430 | $systemName = getSystemName($solarSystemID[0]); |
||
431 | $msg = "IHUB under attack in **{$systemName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName}). Status: Hull: {$hullValue}, Armor: {$armorValue}, Shield: {$shieldValue}"; |
||
432 | break; |
||
433 | case 89: // Sov level? |
||
434 | $msg = 'skip'; |
||
435 | break; |
||
436 | case 90: // Sov level? |
||
437 | $msg = 'skip'; |
||
438 | break; |
||
439 | case 93: // Customs office is being attacked |
||
440 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
441 | $aggAllianceName = allianceName($aggAllianceID); |
||
442 | $aggCorpID = trim(explode(': ', $notificationArray[0])[1]); |
||
443 | $aggCorpName = corpName($aggCorpID); |
||
444 | $aggID = trim(explode(': ', $notificationArray[2])[1]); |
||
445 | $aggCharacterName = characterName($aggID); |
||
446 | $shieldValue = trim(explode(': ', $notificationArray[5])[1]); |
||
447 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
448 | $systemName = getSystemName($solarSystemID[0]); |
||
449 | $msg = "Customs Office under attack in **{$systemName}** by {$aggCharacterName} ({$aggCorpName} / {$aggAllianceName}). Shield Status: {$shieldValue}"; |
||
450 | if ($this->allianceOnly === 'true') { |
||
451 | $msg = 'skip'; |
||
452 | } |
||
453 | break; |
||
454 | case 94: // POCO Reinforced |
||
455 | $msg = 'Customs Office reinforced.'; |
||
456 | break; |
||
457 | case 95: // IHub Transfer |
||
458 | $msg = 'skip'; |
||
459 | break; |
||
460 | case 100: // Aggressor corp joins war |
||
461 | preg_match('/(?<=defenderID: )\S+/i', $notificationString, $defCorpID); |
||
462 | $defCorpName = allianceName($defCorpID[0]); |
||
463 | if ($defCorpName === 'Unknown' || '' || ' ' || null) { |
||
464 | $defCorpName = corpName($defCorpID[0]); |
||
465 | } |
||
466 | preg_match('/(?<=aggressorID: )\S+/i', $notificationString, $aggCorpID); |
||
467 | $aggCorpName = allianceName($aggCorpID[0]); |
||
468 | if ($aggCorpName === 'Unknown' || '' || ' ' || null) { |
||
469 | $aggCorpName = corpName($aggCorpID[0]); |
||
470 | } |
||
471 | $msg = "{$aggCorpName} has joined the war against {$defCorpName}."; |
||
472 | break; |
||
473 | case 101: // corp joins war |
||
474 | preg_match('/(?<=defenderID: )\S+/i', $notificationString, $defCorpID); |
||
475 | $defCorpName = allianceName($defCorpID[0]); |
||
476 | if ($defCorpName === 'Unknown' || '' || ' ' || null) { |
||
477 | $defCorpName = corpName($defCorpID[0]); |
||
478 | } |
||
479 | preg_match('/(?<=aggressorID: )\S+/i', $notificationString, $aggCorpID); |
||
480 | $aggCorpName = allianceName($aggCorpID[0]); |
||
481 | if ($aggCorpName === 'Unknown' || '' || ' ' || null) { |
||
482 | $aggCorpName = corpName($aggCorpID[0]); |
||
483 | } |
||
484 | preg_match('/(?<=allyID: )\S+/i', $notificationString, $thirdCorpID); |
||
485 | $thirdCorpName = allianceName($thirdCorpID[0]); |
||
486 | if ($thirdCorpName === 'Unknown' || '' || ' ' || null) { |
||
487 | $thirdCorpName = corpName($thirdCorpID[0]); |
||
488 | } |
||
489 | $msg = "{$thirdCorpName} has joined the war involving {$defCorpName} and {$aggCorpName}."; |
||
490 | break; |
||
491 | case 102: // War support offer? I think? |
||
492 | $msg = 'skip'; |
||
493 | break; |
||
494 | case 103: // War support offer? I think? |
||
495 | $msg = 'skip'; |
||
496 | break; |
||
497 | case 111: // Bounty |
||
498 | $msg = 'skip'; |
||
499 | break; |
||
500 | case 112: // Bounty |
||
501 | $msg = 'skip'; |
||
502 | break; |
||
503 | case 113: // Bounty |
||
504 | $msg = 'skip'; |
||
505 | break; |
||
506 | case 114: // Bounty |
||
507 | $msg = 'skip'; |
||
508 | break; |
||
509 | case 115: // Kill right |
||
510 | $msg = 'skip'; |
||
511 | break; |
||
512 | case 116: // Kill right |
||
513 | $msg = 'skip'; |
||
514 | break; |
||
515 | case 117: // Kill right |
||
516 | $msg = 'skip'; |
||
517 | break; |
||
518 | case 118: // Kill right |
||
519 | $msg = 'skip'; |
||
520 | break; |
||
521 | case 119: // Kill right |
||
522 | $msg = 'skip'; |
||
523 | break; |
||
524 | case 120: // Kill right |
||
525 | $msg = 'skip'; |
||
526 | break; |
||
527 | case 123: // Surrender (Need XML) |
||
528 | $msg = 'skip'; |
||
529 | break; |
||
530 | case 128: // Corp App |
||
531 | $msg = 'skip'; |
||
532 | break; |
||
533 | case 129: // App denied |
||
534 | $msg = 'skip'; |
||
535 | break; |
||
536 | case 130: // Corp app withdrawn? |
||
537 | $msg = 'skip'; |
||
538 | break; |
||
539 | case 135: // ESS stolen |
||
540 | $msg = 'skip'; |
||
541 | break; |
||
542 | case 138: // Clone activation |
||
543 | $msg = 'skip'; |
||
544 | break; |
||
545 | case 139: // Clone activation |
||
546 | $msg = 'skip'; |
||
547 | break; |
||
548 | case 140: // Kill report |
||
549 | $msg = 'skip'; |
||
550 | break; |
||
551 | case 141: // Kill report |
||
552 | $msg = 'skip'; |
||
553 | break; |
||
554 | case 146: // ff legality changed |
||
555 | preg_match('/(?<=corpID: )\S+/i', $notificationString, $corpID); |
||
556 | $corpName = allianceName($corpID[0]); |
||
557 | if ($corpName === 'Unknown' || '' || ' ' || null) { |
||
558 | $corpName = corpName($corpID[0]); |
||
559 | } |
||
560 | $msg = "{$corpName} has changed the legality for friendly fire."; |
||
561 | break; |
||
562 | View Code Duplication | case 147: // Entosis has started |
|
563 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
564 | $systemName = getSystemName($solarSystemID[0]); |
||
565 | $typeID = trim(explode(': ', $notificationArray[1])[1]); |
||
566 | $typeName = getTypeName($typeID); |
||
567 | $msg = "Entosis has started in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
||
568 | break; |
||
569 | View Code Duplication | case 148: // Entosis enabled a module ?????? |
|
570 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
571 | $systemName = getSystemName($solarSystemID[0]); |
||
572 | $typeID = trim(explode(': ', $notificationArray[1])[1]); |
||
573 | $typeName = getTypeName($typeID); |
||
574 | $msg = "Entosis has enabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
||
575 | break; |
||
576 | View Code Duplication | case 149: // Entosis disabled a module |
|
577 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
578 | $systemName = getSystemName($solarSystemID[0]); |
||
579 | $typeID = trim(explode(': ', $notificationArray[1])[1]); |
||
580 | $typeName = getTypeName($typeID); |
||
581 | $msg = "Entosis has disabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)"; |
||
582 | break; |
||
583 | case 152: // Sov bill |
||
584 | $msg = 'skip'; |
||
585 | break; |
||
586 | View Code Duplication | case 160: // Entosis successful |
|
587 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
588 | $systemName = getSystemName($solarSystemID[0]); |
||
589 | $msg = "Hostile entosis successful. A structure in **{$systemName}** has entered reinforced mode."; |
||
590 | break; |
||
591 | View Code Duplication | case 161: // Command Nodes Decloaking |
|
592 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
593 | $systemName = getSystemName($solarSystemID[0]); |
||
594 | $msg = "Command nodes decloaking for **{$systemName}**"; |
||
595 | break; |
||
596 | View Code Duplication | case 162: // TCU Destroyed |
|
597 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
598 | $systemName = getSystemName($solarSystemID[0]); |
||
599 | $msg = "Entosis successful, TCU in **{$systemName}** has been destroyed."; |
||
600 | break; |
||
601 | View Code Duplication | case 163: // Outpost freeport |
|
602 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
603 | $systemName = getSystemName($solarSystemID[0]); |
||
604 | $msg = "Station in **{$systemName}** has now entered freeport mode."; |
||
605 | break; |
||
606 | View Code Duplication | case 165: // System became Capital |
|
607 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
608 | $systemName = getSystemName($solarSystemID[0]); |
||
609 | $allianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
610 | $allianceName = allianceName($allianceID); |
||
611 | $msg = "**{$systemName}** is now the capital for {$allianceName}."; |
||
612 | break; |
||
613 | View Code Duplication | case 167: // Initiate Self-destruct on TCU |
|
614 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
615 | $systemName = getSystemName($solarSystemID[0]); |
||
616 | $msg = "TCU in **{$systemName}** has initiated a self destruct sequence."; |
||
617 | break; |
||
618 | View Code Duplication | case 169: // TCU Self-Destructed |
|
619 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
620 | $systemName = getSystemName($solarSystemID[0]); |
||
621 | $msg = "TCU in **{$systemName}** has self destructed."; |
||
622 | break; |
||
623 | View Code Duplication | case 181: // citadel low on fuel |
|
624 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
625 | $systemName = getSystemName($solarSystemID[0]); |
||
626 | $msg = "Citadel in **{$systemName}** is low on fuel."; |
||
627 | if ($this->fuelSkip === 'true' || $this->allianceOnly === 'true') { |
||
628 | $msg = 'skip'; |
||
629 | } |
||
630 | break; |
||
631 | case 182: // Citadel being anchored |
||
632 | preg_match('/(?<=ownerCorpName: )[^\r\n]+/i', $notificationString, $corpName); |
||
633 | $corpName = $corpName[0]; |
||
634 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
635 | $systemName = getSystemName($solarSystemID[0]); |
||
636 | $msg = "Citadel owned by **{$corpName}** is being anchored in **{$systemName}**."; |
||
637 | break; |
||
638 | case 184: // Citadel under attack |
||
639 | $aggID = trim(explode(': ', $notificationArray[7])[1]); |
||
640 | $aggCharacterName = characterName($aggID); |
||
641 | $aggAllianceID = trim(explode(': ', $notificationArray[0])[1]); |
||
642 | $aggAllianceName = allianceName($aggAllianceID); |
||
643 | $aggCorpID = trim(explode('- ', $notificationArray[11])[1]); |
||
644 | $aggCorpName = corpName($aggCorpID); |
||
645 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
646 | $systemName = getSystemName($solarSystemID[0]); |
||
647 | $msg = "@everyone | Citadel under attack in **{$systemName}** by **{$aggCharacterName}** ({$aggCorpName} / {$aggAllianceName})."; |
||
648 | break; |
||
649 | View Code Duplication | case 185: // Citadel online |
|
650 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
651 | $systemName = getSystemName($solarSystemID[0]); |
||
652 | $msg = "Citadel now online in **{$systemName}**."; |
||
653 | break; |
||
654 | View Code Duplication | case 188: // Citadel destroyed |
|
655 | $corpID = trim(explode('- ', $notificationArray[3])[1]); |
||
656 | $corpName = corpName($corpID); |
||
657 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
658 | $systemName = getSystemName($solarSystemID[0]); |
||
659 | $msg = "Citadel owned by **{$corpName}** in **{$systemName}** has been destroyed."; |
||
660 | break; |
||
661 | View Code Duplication | case 198: // citadel out of fuel |
|
662 | preg_match('/(?<=solarsystemID: )\S+/i', $notificationString, $solarSystemID); |
||
663 | $systemName = getSystemName($solarSystemID[0]); |
||
664 | $msg = "Citadel in **{$systemName}** has run out of fuel."; |
||
665 | if ($this->fuelSkip === 'true' || $this->allianceOnly === 'true') { |
||
666 | $msg = 'skip'; |
||
667 | } |
||
668 | break; |
||
669 | case 199: // citadel delivery |
||
670 | $msg = 'skip'; |
||
671 | break; |
||
672 | case 1030: // ?? |
||
673 | $msg = 'skip'; |
||
674 | break; |
||
675 | case 1031: // plex delivery |
||
676 | $msg = 'skip'; |
||
677 | break; |
||
678 | default: // Unknown typeID |
||
679 | $string = implode(' ', $notificationArray); |
||
680 | $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}"; |
||
681 | break; |
||
682 | } |
||
683 | |||
684 | if ($msg === 'skip') { |
||
685 | return null; |
||
686 | } |
||
687 | $this->logger->addInfo('Notifications: Notification queued'); |
||
688 | priorityQueueMessage($msg, $channelID, $this->guild); |
||
689 | // Find the maxID so we don't output this message again in the future |
||
690 | $this->maxID = max($notificationID, $this->maxID); |
||
691 | $this->newestNotificationID = $this->maxID; |
||
692 | setPermCache('newestNotificationID', $this->maxID); |
||
693 | } |
||
694 | } |
||
695 | $this->logger->addInfo("Notifications: Next Notification Check At: {$nextKeyTime} EVE Time"); |
||
696 | } catch (Exception $e) { |
||
697 | $this->logger->addInfo('Notifications: Notification Error: ' . $e->getMessage()); |
||
698 | } |
||
699 | return null; |
||
700 | } |
||
701 | |||
718 |
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.