Exemplo n.º 1
0
 public function data($msgData, $botData)
 {
     $channelData = Channel::find($msgData["channel_id"]);
     if ($channelData->is_private == true) {
         $channelData->setAttribute("name", $msgData->author->username);
     }
     $msgData = (object) array("isBotOwner" => false, "user" => $msgData, "message" => (object) array("lastSeen" => $this->db->queryField("SELECT lastSeen FROM usersSeen WHERE id = :id", "lastSeen", array(":id" => $msgData->author->id)), "lastSpoke" => $this->db->queryField("SELECT lastSpoke FROM usersSeen WHERE id = :id", "lastSpoke", array(":id" => $msgData->author->id)), "timestamp" => $msgData->timestamp->toDateTimeString(), "id" => $msgData->author->id, "message" => $msgData->content, "channelID" => $msgData->channel_id, "from" => $msgData->author->username, "fromID" => $msgData->author->id, "fromDiscriminator" => $msgData->author->discriminator, "fromAvatar" => $msgData->author->avatar), "channel" => $channelData, "guild" => $channelData->is_private ? (object) array("name" => "private conversation") : Guild::find($channelData->guild_id), "botData" => $botData);
     return $msgData;
 }
Exemplo n.º 2
0
 /**
  * Writes the record down to the log of the implementing handler.
  *
  * @param array $record
  *
  * @return void
  */
 protected function write(array $record)
 {
     if (!$this->initialized) {
         if (!$this->initialize()) {
             return;
         }
     }
     $developer = new Developer($this->pastebin['api_key']);
     $account = new Account(new Credentials($this->pastebin['username'], $this->pastebin['password']));
     $draft = new Draft();
     $draft->setContent(json_encode($record, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
     $draft->setOwner($account);
     $draft->setVisibility(Visibility::VISIBILITY_UNLISTED);
     $draft->setFormat(Format::fromExtension('js'));
     $draft->setExpiry('24H');
     $draft->setTitle($record['datetime']->format('U'));
     $paste = $draft->paste($developer);
     $message = substr($record['formatted'], 0, 256);
     $this->channel->sendMessage("Error: \n\n```\n{$message}\n```\n\nPastebin: <{$paste->getUrl()}>");
 }
Exemplo n.º 3
0
 /**
  * @param $keyID
  * @param $vCode
  * @param $characterID
  */
 private function getNotifications($keyID, $vCode, $characterID)
 {
     try {
         // Seriously CCP.. *sigh*
         // Ignore notifications from these douchebags..
         $ignoreNames = array("CCP");
         $url = "https://api.eveonline.com/char/Notifications.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}";
         $data = json_decode(json_encode(simplexml_load_string($this->curl->getData($url), "SimpleXMLElement", LIBXML_NOCDATA)), true);
         $data = $data["result"]["rowset"]["row"];
         // If there is no data, just quit..
         if (empty($data)) {
             return;
         }
         $fixedData = array();
         // Sometimes there is only ONE notification, so.. yeah..
         if (count($data) > 1) {
             foreach ($data as $getFuckedCCP) {
                 $fixedData[] = $getFuckedCCP["@attributes"];
             }
         } else {
             $fixedData[] = $data["@attributes"];
         }
         foreach ($fixedData as $notification) {
             $notificationID = $notification["notificationID"];
             $typeID = $notification["typeID"];
             //$senderID = $notification["senderID"];
             $senderName = $notification["senderName"];
             $sentDate = $notification["sentDate"];
             //$read = $notification["read"];
             // If the senderName is in the list of ignores names, then continue and ignore it..
             if (in_array($senderName, $ignoreNames)) {
                 continue;
             }
             if ($notificationID > $this->newestNotificationID) {
                 $notificationString = explode("\n", $this->getNotificationText($keyID, $vCode, $characterID, $notificationID));
                 $msg = null;
                 // Seriously, get f****d CCP
                 switch ($typeID) {
                     case 5:
                         // War Declared
                         $aggressorAllianceID = trim(explode(": ", $notificationString[2])[1]);
                         $aggressorAllianceName = $this->apiData("alli", $aggressorAllianceID)["allianceName"];
                         $delayHours = trim(explode(": ", $notificationString[3])[1]);
                         $msg = "War declared by {$aggressorAllianceName}. Fighting begins in roughly {$delayHours} hours.";
                         break;
                     case 8:
                         // Alliance war invalidated by CONCORD
                         $aggressorAllianceID = trim(explode(": ", $notificationString[2])[1]);
                         $aggressorAllianceName = $this->apiData("alli", $aggressorAllianceID)["allianceName"];
                         $msg = "War declared by {$aggressorAllianceName} has been invalidated. Fighting ends in roughly 24 hours.";
                         break;
                     case 75:
                         // POS / POS Module under attack
                         $aggressorAllianceID = trim(explode(": ", $notificationString[0])[1]);
                         $aggressorAllianceName = $this->apiData("alli", $aggressorAllianceID)["allianceName"];
                         $aggressorCorpID = trim(explode(": ", $notificationString[1])[1]);
                         $aggressorCorpName = $this->apiData("corp", $aggressorCorpID)["corporationName"];
                         $aggressorID = trim(explode(": ", $notificationString[2])[1]);
                         $aggressorCharacterName = $this->apiData("char", $aggressorID)["characterName"];
                         $armorValue = trim(explode(": ", $notificationString[3])[1]);
                         $hullValue = trim(explode(": ", $notificationString[4])[1]);
                         $moonID = trim(explode(": ", $notificationString[5])[1]);
                         $moonName = $this - $this->ccpDB->queryField("SELECT itemName FROM mapAllCelestials WHERE itemID = :id", "itemName", array(":id" => $moonID));
                         $shieldValue = trim(explode(": ", $notificationString[6])[1]);
                         $solarSystemID = trim(explode(": ", $notificationString[7])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $solarSystemID));
                         $msg = "POS under attack in **{$systemName} - {$moonName}** by {$aggressorCharacterName} ({$aggressorCorpName} / {$aggressorAllianceName}). Status: Hull: {$hullValue}, Armor: {$armorValue}, Shield: {$shieldValue}";
                         break;
                     case 76:
                         // Tower resource alert
                         $moonID = trim(explode(": ", $notificationString[2])[1]);
                         $moonName = $this->ccpDB->queryField("SELECT itemName FROM mapAllCelestials WHERE itemID = :id", "itemName", array(":id" => $moonID));
                         $solarSystemID = trim(explode(": ", $notificationString[3])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $solarSystemID));
                         $blocksRemaining = trim(explode(": ", $notificationString[6])[1]);
                         $typeID = trim(explode(": ", $notificationString[7])[1]);
                         $typeName = $this->ccpDB->queryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => $typeID));
                         $msg = "POS in {$systemName} - {$moonName} needs fuel. Only {$blocksRemaining} {$typeName}'s remaining.";
                         break;
                     case 88:
                         // IHUB is being attacked
                         $aggressorAllianceID = trim(explode(": ", $notificationString[0])[1]);
                         $aggressorAllianceName = $this->apiData("alli", $aggressorAllianceID)["allianceName"];
                         $aggressorCorpID = trim(explode(": ", $notificationString[0])[1]);
                         $aggressorCorpName = $this->apiData("corp", $aggressorCorpID)["corporationName"];
                         $aggressorID = trim(explode(": ", $notificationString[1])[1]);
                         $aggressorCharacterName = $this->apiData("char", $aggressorID)["characterName"];
                         $armorValue = trim(explode(": ", $notificationString[3])[1]);
                         $hullValue = trim(explode(": ", $notificationString[4])[1]);
                         $shieldValue = trim(explode(": ", $notificationString[5])[1]);
                         $solarSystemID = trim(explode(": ", $notificationString[6])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $solarSystemID));
                         $msg = "IHUB under attack in **{$systemName}** by {$aggressorCharacterName} ({$aggressorCorpName} / {$aggressorAllianceName}). Status: Hull: {$hullValue}, Armor: {$armorValue}, Shield: {$shieldValue}";
                         break;
                     case 93:
                         // Customs office is being attacked
                         $aggressorAllianceID = trim(explode(": ", $notificationString[0])[1]);
                         $aggressorAllianceName = $this->apiData("alli", $aggressorAllianceID)["allianceName"];
                         $aggressorCorpID = trim(explode(": ", $notificationString[0])[1]);
                         $aggressorCorpName = $this->apiData("corp", $aggressorCorpID)["corporationName"];
                         $aggressorID = trim(explode(": ", $notificationString[2])[1]);
                         $aggressorCharacterName = $this->apiData("char", $aggressorID)["characterName"];
                         $planetID = trim(explode(": ", $notificationString[3])[1]);
                         $planetName = $this->ccpDB->queryField("SELECT itemName FROM mapAllCelestials WHERE itemID = :id", "itemName", array(":id" => $planetID));
                         $shieldValue = trim(explode(": ", $notificationString[5])[1]);
                         $solarSystemID = trim(explode(": ", $notificationString[6])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $solarSystemID));
                         $typeID = trim(explode(": ", $notificationString[7])[1]);
                         $typeName = $this->ccpDB->queryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => $typeID));
                         $msg = "Customs Office under attack in **{$systemName}** ({$planetName}) by {$aggressorCharacterName} ({$aggressorCorpName} / {$aggressorAllianceName}). Shield Status: {$shieldValue}";
                         break;
                     case 147:
                         // Entosis has stated
                         $systemID = trim(explode(": ", $notificationString[0])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $systemID));
                         $typeID = trim(explode(": ", $notificationString[1])[1]);
                         $typeName = $this->ccpDB->queryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => $typeID));
                         $msg = "Entosis has started in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)";
                         break;
                     case 148:
                         // Entosis enabled a module ??????
                         $systemID = trim(explode(": ", $notificationString[0])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $systemID));
                         $typeID = trim(explode(": ", $notificationString[1])[1]);
                         $typeName = $this->ccpDB->queryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => $typeID));
                         $msg = "Entosis has enabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)";
                         break;
                     case 149:
                         // Entosis disabled a module
                         $systemID = trim(explode(": ", $notificationString[0])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $systemID));
                         $typeID = trim(explode(": ", $notificationString[1])[1]);
                         $typeName = $this->ccpDB->queryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => $typeID));
                         $msg = "Entosis has disabled a module in **{$systemName}** on **{$typeName}** (Date: **{$sentDate}**)";
                         break;
                     case 160:
                         // Entosis successful
                         $systemID = trim(explode(": ", $notificationString[2])[1]);
                         $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $systemID), "ccp");
                         $msg = "Hostile entosis successful. A structure in **{$systemName}** has entered reinforced mode.";
                         break;
                     case 161:
                         // Command Nodes Decloaking
                         $systemID = trim(explode(": ", $notificationString[2])[1]);
                         $systemName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $systemID));
                         $msg = "Command nodes decloaking for **{$systemName}**";
                         break;
                     case 163:
                         //  Freeport
                         $systemID = trim(explode(": ", $notificationString[1])[1]);
                         $systemName = dbQueryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $systemID), "ccp");
                         $msg = "Station in **{$systemName}** has entered freeport mode.";
                         break;
                 }
                 if ($msg) {
                     $channel = \Discord\Parts\Channel\Channel::find($this->toDiscordChannel);
                     $channel->sendMessage($msg);
                 }
                 // Find the maxID so we don't output this message again in the future
                 $this->maxID = max($notificationID, $this->maxID);
                 $this->newestNotificationID = $this->maxID;
                 $this->storage->set("newestNotificationID", $this->maxID);
             }
         }
     } catch (Exception $e) {
         $this->log->debug("Error: " . $e->getMessage());
     }
 }
Exemplo n.º 4
0
 /**
  * When the bot's tick hits a specified time, this is started
  *
  * Runtime is defined in $this->information(), timerFrequency
  */
 public function onTimer()
 {
     $continue = false;
     $data = array();
     // Fetch the last 5 twitter replies and/or searches
     try {
         $data = $this->twitter->load(Twitter::ME_AND_FRIENDS, 5);
         foreach ($data as $message) {
             $text = (array) $message->text;
             $createdAt = (array) $message->created_at;
             $postedBy = (array) $message->user->name;
             $screenName = (array) $message->user->screen_name;
             $id = (int) $message->id;
             $this->lastID = $this->storage->get("twitterLatestID");
             // get the last posted ID
             if ($id <= $this->lastID) {
                 continue;
             }
             $this->maxID = max($id, $this->maxID);
             $url = "https://twitter.com/" . $screenName[0] . "/status/" . $id;
             $message = array("message" => $text[0], "postedAt" => $createdAt[0], "postedBy" => $postedBy[0], "screenName" => $screenName[0], "url" => $url . $id[0]);
             $msg = "**@" . $screenName[0] . "** (" . $message["postedBy"] . ") / " . htmlspecialchars_decode($message["message"]);
             $messages[$id] = $msg;
             $continue = true;
             if (sizeof($data)) {
                 $this->storage->set("twitterLatestID", $this->maxID);
             }
         }
     } catch (Exception $e) {
         $this->log->err("Twitter Error: " . $e->getMessage());
         // Don't show there was an error, it's most likely just a rate limit
     }
     if ($continue == true) {
         ksort($messages);
         $channel = \Discord\Parts\Channel\Channel::find($this->channelID);
         foreach ($messages as $id => $msg) {
             $channel->sendMessage($msg);
             sleep(1);
             // Lets sleep for a second, so we don't rage spam
         }
     }
 }
Exemplo n.º 5
0
 private function checkMails($keyID, $vCode, $characterID)
 {
     $updateMaxID = false;
     $url = "https://api.eveonline.com/char/MailMessages.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}";
     $data = json_decode(json_encode(simplexml_load_string($this->curl->getData($url), "SimpleXMLElement", LIBXML_NOCDATA)), true);
     $data = $data["result"]["rowset"]["row"];
     $mails = array();
     // Sometimes there is only ONE notification, so.. yeah..
     if (count($data) > 1) {
         foreach ($data as $getFuckedCCP) {
             $mails[] = $getFuckedCCP["@attributes"];
         }
     } else {
         $mails[] = $data["@attributes"];
     }
     usort($mails, array($this, "sortByDate"));
     foreach ($mails as $mail) {
         if (in_array($mail["toCorpOrAllianceID"], $this->toIDs) && $mail["messageID"] > $this->newestMailID) {
             $sentBy = $mail["senderName"];
             $title = $mail["title"];
             $sentDate = $mail["sentDate"];
             $url = "https://api.eveonline.com/char/MailBodies.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}&ids=" . $mail["messageID"];
             $content = strip_tags(str_replace("<br>", "\n", json_decode(json_encode(simplexml_load_string($this->curl->getData($url), "SimpleXMLElement", LIBXML_NOCDATA)))->result->rowset->row));
             $messageSplit = null;
             if (strlen($content) > 1850) {
                 $messageSplit = str_split($content, 1850);
             }
             // Stitch the mail together
             $msg = "**Mail By: **{$sentBy}\n";
             $msg .= "**Sent Date: **{$sentDate}\n";
             $msg .= "**Title: ** {$title}\n";
             $msg .= "**Content: **\n";
             if (!$messageSplit) {
                 $msg .= htmlspecialchars_decode(trim($content));
             }
             // Send the mails to the channel
             $channel = \Discord\Parts\Channel\Channel::find($this->toDiscordChannel);
             if (strlen($content) > 1850 && !empty($longMessage)) {
                 foreach ($longMessage as $msg) {
                     $channel->sendMessage($msg);
                 }
             } else {
                 $channel->sendMessage($msg);
             }
             sleep(1);
             // Lets sleep for a second, so we don't rage spam
             // Find the maxID so we don't spit this message out ever again
             $this->maxID = max($mail["messageID"], $this->maxID);
             $this->newestMailID = $this->maxID;
             //$mail["messageID"];
             $updateMaxID = true;
             // set the maxID
             if ($updateMaxID) {
                 $this->storage->set("newestCorpMailID", $this->maxID);
             }
         }
     }
 }
Exemplo n.º 6
0
    $message = $msgData->content;
    // If they write directly to me, i'll send it to cleverbot (Also the message has to start with this...
    if (stristr($message, "<@" . $app->config->get("botID", "bot") . ">")) {
        $msg = str_replace("<@" . $app->config->get("botID", "bot") . ">", $app->config->get("botName", "bot"), $message);
        $response = $botSession->think($msg);
        $msgData->reply($response);
    }
    // We randomly pick things to answer to.... why? why the f**k not
    if (mt_rand(1, 100) <= 5) {
        $response = $botSession->think($message);
        $channel = \Discord\Parts\Channel\Channel::find($msgData->channel_id);
        $channel->sendMessage($response);
    }
    // Silly replies always to be done..
    if ($message == '(╯°□°)╯︵ ┻━┻') {
        $channel = \Discord\Parts\Channel\Channel::find($msgData->channel_id);
        $channel->sendMessage('┬─┬ ノ( ゜-゜ノ)');
    }
    // Run the logfile generator
    if ($msgData->author->username != $app->config->get("botName", "bot")) {
        $app->logfile->writeToLog($app->composemsgdata->data($msgData, $botData));
    }
});
/** @var \Discord\WebSockets\WebSocket $websocket */
/** @var \Sluggard\SluggardApp $app */
/** @var \Discord\Discord $discord */
// On a message, run the plugin that is triggered
$websocket->on(Event::MESSAGE_CREATE, function ($msgData, $botData) use($app, $discord, $websocket, $plugins) {
    // Map the message content to $message for easier usage
    $message = $msgData->content;
    // Show every message in the bot window (Except if it's from our self, then ignore it!
Exemplo n.º 7
0
 /**
  * @param $keyID
  * @param $vCode
  */
 private function checkForSiphons($keyID, $vCode)
 {
     try {
         // Seriously CCP.. *sigh*
         $url = "https://api.eveonline.com/corp/AssetList.xml.aspx?keyID={$keyID}&vCode={$vCode}";
         $data = json_decode(json_encode(simplexml_load_string($this->curl->getData($url), "SimpleXMLElement", LIBXML_NOCDATA)), true);
         $data = $data["result"]["rowset"]["row"];
         // If there is no data, just quit..
         if (empty($data)) {
             return;
         }
         $fixedData = array();
         foreach ($data as $key => $getFuckedCCP) {
             if ($getFuckedCCP["@attributes"]["typeID"] == 14343) {
                 $fixedData[$key] = $getFuckedCCP["@attributes"];
                 $fixedData[$key]["siloContents"] = @$getFuckedCCP["rowset"]["row"]["@attributes"];
             }
         }
         foreach ($fixedData as $silos) {
             $locationID = $silos["locationID"];
             $locationName = $this->ccpDB->queryField("SELECT solarSystemName FROM mapSolarSystems WHERE solarSystemID = :id", "solarSystemName", array(":id" => $locationID));
             $siloContents = $silos["siloContents"];
             $quantity = $siloContents["quantity"];
             $siloHarvesting = $siloContents["typeID"];
             $siloHarvestingName = $this->ccpDB->queryField("SELECT typeName FROM invTypes WHERE typeID = :id", "typeName", array(":id" => $siloHarvesting));
             // Skip this silo if it has no data
             if ($siloContents == null || empty($siloContents)) {
                 continue;
             }
             // If we're being siphoned
             if ($quantity % 100 != 0) {
                 $msg = "**Alert:** Possible Siphon detected in {$locationName}.. What is being siphoned: {$siloHarvestingName}";
                 $channel = \Discord\Parts\Channel\Channel::find($this->toDiscordChannel);
                 $channel->sendMessage($msg);
             }
         }
     } catch (Exception $e) {
         $this->log->debug("Error: " . $e->getMessage());
     }
 }
 public function run()
 {
     $handle = fopen("/tmp/discord.db", "r+");
     flock($handle, LOCK_EX);
     $message = "";
     while ($row = fgets($handle)) {
         if (!empty($row)) {
             $row = str_replace("\n", "", str_replace("\r", "", str_replace("^@", "", $row)));
             if ($row == "" || $row == " ") {
                 continue;
             }
             $message .= $row . " | ";
         }
     }
     flock($handle, LOCK_UN);
     fclose($handle);
     $handle = fopen("/tmp/discord.db", "w+");
     fclose($handle);
     chmod("/tmp/discord.db", 0777);
     $data = null;
     $handle = null;
     clearstatcache();
     if (!empty($message)) {
         // Strip out the last |
         $message = trim(substr($message, 0, -2));
         $channelID = 154221481625124864;
         /** @var Channel $channel */
         $channel = Channel::find($channelID);
         $this->log->addInfo("Sending ping to #pings on The Culture");
         $channel->sendMessage("@everyone " . $message, false);
     }
 }
Exemplo n.º 9
0
 /**
  * When the bot's tick hits a specified time, this is started
  *
  * Runtime is defined in $this->information(), timerFrequency
  */
 public function onTimer()
 {
     if (filemtime($this->db) >= $this->lastCheck) {
         $data = file($this->db);
         if ($data) {
             $message = "";
             foreach ($data as $row) {
                 $row = str_replace("\n", "", str_replace("\r", "", str_replace("^@", "", $row)));
                 if ($row == "" || $row == " ") {
                     continue;
                 }
                 $message .= $row . " | ";
                 usleep(300000);
             }
             // Remove |  from the line or whatever else is at the last two characters in the string
             $message = trim(substr($message, 0, -2));
             $defaultID = 0;
             foreach ($this->channelConfig as $chanName => $chanConfig) {
                 // If a channel is marked as default (usually the first on the list) we populate defaultID here, just to make sure..
                 if ($chanConfig["default"] == true) {
                     $defaultID = $chanConfig["channelID"];
                 }
                 // Search for a channel where the search string matches the actual message
                 if (stristr($message, $chanConfig["searchString"])) {
                     $message = $chanConfig["textStringPrepend"] . " " . $message . " " . $chanConfig["textStringAppend"];
                     $channelID = $chanConfig["channelID"];
                 } elseif ($chanConfig["searchString"] == false) {
                     // If no match was found, and searchString is false, just use that
                     $message = $chanConfig["textStringPrepend"] . " " . $message . " " . $chanConfig["textStringAppend"];
                     $channelID = $chanConfig["channelID"];
                 } else {
                     // If something f****d up, we'll just go this route..
                     $channelID = isset($defaultID) ? $defaultID : $chanConfig["channelID"];
                     // If default ID isn't set, then we just pick whatever we can..
                 }
             }
             // Get the Discord Channel Object
             // Send Message to Channel Object
             $channel = \Discord\Parts\Channel\Channel::find(isset($channelID) ? $channelID : $defaultID);
             $channel->sendMessage($message);
         }
         $h = fopen($this->db, "w+");
         fclose($h);
         chmod($this->db, 0777);
         $data = null;
         $h = null;
     }
     clearstatcache();
     $this->lastCheck = time();
 }
Exemplo n.º 10
0
 public function run()
 {
     $channels = $this->db->query("SELECT * FROM killmailPosting");
     foreach ($channels as $channel) {
         $rowID = $channel["id"];
         $type = $channel["typeName"];
         $id = $channel["typeID"];
         $latest = $channel["latestKillID"];
         $channelID = $channel["channelID"];
         // Get the killdata
         $killData = json_decode($this->curl->get("https://evedata.xyz/api/killlist/latest/"));
         if (!empty($killData)) {
             foreach ($killData as $kill) {
                 if (isset($kill->killID) && $kill->killID > $latest) {
                     switch ($type) {
                         case "character":
                             if ($kill->victim->characterID == $id) {
                                 $msg = "{$kill->victim->characterName} ({$kill->victim->corporationName} / {$kill->victim->allianceName}) lost {$kill->victim->shipTypeName} in {$kill->solarSystemName} ({$kill->regionName}) with a total value of {$kill->totalValue}isk | https://beta.eve-kill.net/kill/{$kill->killID}/";
                                 $this->db->execute("UPDATE killmailPosting SET latestKillID = :killID WHERE id = :rowID", array(":killID" => $kill->killID, ":rowID" => $rowID));
                             }
                             foreach ($kill->attackers as $attacker) {
                                 if ($attacker->characterID == $id && $attacker->finalBlow == 1) {
                                     $msg = "{$attacker->characterName} participated in killing {$kill->victim->characterName} ({$kill->victim->corporationName} / {$kill->victim->allianceName} / {$kill->victim->shipTypeName}) in a {$attacker->shipTypeName} doing a total of {$attacker->damageDone} damage, and helped destroy {$kill->totalValue}isk | https://beta.eve-kill.net/kill/{$kill->killID}/";
                                     $this->db->execute("UPDATE killmailPosting SET latestKillID = :killID WHERE id = :rowID", array(":killID" => $kill->killID, ":rowID" => $rowID));
                                 }
                             }
                             break;
                         case "corporation":
                             if ($kill->victim->corporationID == $id) {
                                 $msg = "{$kill->victim->characterName} ({$kill->victim->corporationName} / {$kill->victim->allianceName}) lost {$kill->victim->shipTypeName} in {$kill->solarSystemName} ({$kill->regionName}) with a total value of {$kill->totalValue}isk";
                                 $this->db->execute("UPDATE killmailPosting SET latestKillID = :killID WHERE id = :rowID", array(":killID" => $kill->killID, ":rowID" => $rowID));
                             }
                             foreach ($kill->attackers as $attacker) {
                                 if ($attacker->corporationID == $id && $attacker->finalBlow == 1) {
                                     $msg = "{$attacker->characterName} participated in killing {$kill->victim->characterName} ({$kill->victim->corporationName} / {$kill->victim->allianceName} / {$kill->victim->shipTypeName}) in a {$attacker->shipTypeName} doing a total of {$attacker->damageDone} damage, and helped destroy {$kill->totalValue}isk | https://beta.eve-kill.net/kill/{$kill->killID}/";
                                     $this->db->execute("UPDATE killmailPosting SET latestKillID = :killID WHERE id = :rowID", array(":killID" => $kill->killID, ":rowID" => $rowID));
                                 }
                             }
                             break;
                         case "alliance":
                             if ($kill->victim->allianceID == $id) {
                                 $msg = "{$kill->victim->characterName} ({$kill->victim->corporationName} / {$kill->victim->allianceName}) lost {$kill->victim->shipTypeName} in {$kill->solarSystemName} ({$kill->regionName}) with a total value of {$kill->totalValue}isk";
                                 $this->db->execute("UPDATE killmailPosting SET latestKillID = :killID WHERE id = :rowID", array(":killID" => $kill->killID, ":rowID" => $rowID));
                             }
                             foreach ($kill->attackers as $attacker) {
                                 if ($attacker->allianceID == $id && $attacker->finalBlow == 1) {
                                     $msg = "{$attacker->characterName} participated in killing {$kill->victim->characterName} ({$kill->victim->corporationName} / {$kill->victim->allianceName} / {$kill->victim->shipTypeName}) in a {$attacker->shipTypeName} doing a total of {$attacker->damageDone} damage, and helped destroy {$kill->totalValue}isk | https://beta.eve-kill.net/kill/{$kill->killID}/";
                                     $this->db->execute("UPDATE killmailPosting SET latestKillID = :killID WHERE id = :rowID", array(":killID" => $kill->killID, ":rowID" => $rowID));
                                 }
                             }
                             break;
                     }
                 }
             }
             if (!empty($msg)) {
                 /** @var Channel $chan */
                 $chan = Channel::find($channelID);
                 $chan->sendMessage($msg);
             }
         }
     }
 }