public function execute($parameters, $db)
 {
     $db->execute("delete from zz_social where insertTime < date_sub(now(), interval 23 hour)");
     $minPilots = 100;
     $minWrecks = 100;
     $result = $db->query("select * from (select solarSystemID, count(distinct characterID) count, count(distinct killID) kills from zz_participants where characterID != 0 and killID > 0 and dttm > date_sub(now(), interval 1 hour) group by 1 order by 2 desc) f where count >= {$minPilots} and kills > {$minWrecks}");
     foreach ($result as $row) {
         $systemID = $row["solarSystemID"];
         $key = $row["solarSystemID"] * 100 + date("H");
         $key2 = $row["solarSystemID"] * 100 + date("H", time() + 3600);
         // Have we already reported this battle to the masses?
         $socialCount = $db->queryField("select count(*) count from zz_social where killID = :killID", "count", array(":killID" => $key), 0);
         $db->execute("insert ignore into zz_social (killID) values (:k1), (:k2)", array(":k1" => $key, ":k2" => $key2));
         Info::addInfo($row);
         $wrecks = number_format($row['kills'], 0);
         $involved = number_format($row['count'], 0);
         $system = $row["solarSystemName"];
         $date = date("YmdH00");
         $link = "https://zkillboard.com/related/{$systemID}/{$date}/";
         // Insert into (or update) zz_battles
         $db->execute("REPLACE INTO zz_battles (solarSystemID, solarSystemName, timestamp, involved, kills) VALUES (:solarSystemID, :solarSystemName, :timestamp, :involved, :kills)", array(":solarSystemID" => $systemID, ":solarSystemName" => $system, ":timestamp" => $date, ":involved" => $involved, ":kills" => $wrecks));
         if ($socialCount != 0) {
             $message = "Battle detected in |g|{$system}|n| with |g|{$involved}|n| involved and |g|{$wrecks}|n| wrecks.";
             Log::irc($message . " |g|{$link}");
             $isgd = Twit::shortenURL($link);
             $message = Log::stripIRCColors($message . " {$isgd} #tweetfleet #eveonline");
             $tweet = Twit::sendMessage($message);
             $twitID = $tweet->id;
             Log::irc("Message was also tweeted: https://twitter.com/eve_kill/status/{$twitID}");
         }
     }
 }
 public function execute($parameters, $db)
 {
     $url = "https://twitter.com/eve_kill/status/";
     $storageName = "twitterLatestRepliesID";
     $latest = $db->queryField("SELECT contents FROM zz_storage WHERE locker = '{$storageName}'", "contents", array(), 0);
     if ($latest == null) {
         $latest = 0;
     }
     $maxID = $latest;
     $twitter = Twit::getMessages(25);
     $messages = array();
     foreach ($twitter as $status) {
         $text = (array) $status->text;
         $createdAt = (array) $status->created_at;
         $postedBy = (array) $status->user->name;
         $screenName = (array) $status->user->screen_name;
         $id = (int) $status->id;
         if ($id <= $latest) {
             continue;
         }
         $maxID = max($id, $maxID);
         $message = array("message" => $text[0], "postedAt" => $createdAt[0], "postedBy" => $postedBy[0], "screenName" => $screenName[0], "url" => $url . $id[0]);
         $url = "https://twitter.com/" . $screenName[0] . "/status/" . $id;
         $msg = "|g|@|n|" . $screenName[0] . " (|g|" . $message["postedBy"] . "|n|) |g|/|n| " . date("H:i:s", strtotime($message["postedAt"])) . " |g|/|n| " . Twit::shortenUrl($url) . " |g|/|n| |g|" . $message["message"];
         //$msg = "Twitter: ($id) |g|" . $message["postedBy"] . "|n| (|g|@". $screenName[0] ."|n|) / |g|" . date("Y-m-d H:i:s", strtotime($message["postedAt"])) . " Message:|n| " . $message["message"];
         $messages[$id] = $msg;
     }
     ksort($messages);
     foreach ($messages as $id => $msg) {
         Log::irc($msg, "");
     }
     if (sizeof($twitter)) {
         $db->execute("INSERT INTO zz_storage (contents, locker) VALUES (:contents, :locker) ON DUPLICATE KEY UPDATE contents = :contents", array(":locker" => $storageName, ":contents" => $maxID));
     }
 }
Example #3
0
 public static function beSocial($killID)
 {
     if ($killID < 0) {
         return;
     }
     $ircMin = 5000000000;
     $twitMin = 10000000000;
     // This is an array of characters we like to laugh at :)
     $laugh = array(1633218082, 924610627, 619471207, 268946627, 179004085, 428663616);
     $count = Db::queryField("select count(*) count from zz_social where killID = :killID", "count", array(":killID" => $killID), 0);
     if ($count != 0) {
         return;
     }
     // Get victim info
     $victimInfo = Db::queryRow("select * from zz_participants where killID = :killID and isVictim = 1", array(":killID" => $killID));
     if ($victimInfo == null) {
         return;
     }
     $totalPrice = $victimInfo["total_price"];
     if (!in_array($victimInfo["characterID"], $laugh)) {
         // If in laugh array, skip the checks
         // Check the minimums, min. price and happened in last 12 hours
         if ($totalPrice < $ircMin) {
             return;
         }
     }
     Info::addInfo($victimInfo);
     $url = "https://zkillboard.com/detail/{$killID}/";
     if ($totalPrice >= $twitMin) {
         $url = Twit::shortenUrl($url);
     }
     $message = "|g|" . $victimInfo["shipName"] . "|n| worth |r|" . Util::formatIsk($totalPrice) . " ISK|n| was destroyed! {$url}";
     if (!isset($victimInfo["characterName"])) {
         $victimInfo["characterName"] = $victimInfo["corporationName"];
     }
     if (strlen($victimInfo["characterName"]) < 25) {
         $name = $victimInfo["characterName"];
         if (Util::endsWith($name, "s")) {
             $name .= "'";
         } else {
             $name .= "'s";
         }
         $message = "{$name} {$message}";
     }
     Db::execute("insert into zz_social (killID) values (:killID)", array(":killID" => $killID));
     Log::irc("{$message}");
     $message = Log::stripIRCColors($message);
     if ($totalPrice >= $twitMin) {
         $message .= " #tweetfleet #eveonline";
         $return = Twit::sendMessage($message);
         $twit = "https://twitter.com/eve_kill/status/" . $return->id;
         Log::irc("Message was also tweeted: |g|{$twit}");
     }
 }
Example #4
0
function beSocial($killID)
{
    global $beSocial, $mdb;
    if (!isset($beSocial)) {
        $beSocial = false;
    }
    if ($beSocial === false) {
        return;
    }
    if ($killID < 0) {
        return;
    }
    $ircMin = 10000000000.0;
    $twitMin = 10000000000.0;
    $kill = $mdb->findDoc('killmails', ['killID' => $killID]);
    if (@$kill['social'] == true) {
        return;
    }
    $hours24 = time() - 86400;
    if ($kill['dttm']->sec < $hours24) {
        return;
    }
    // Get victim info
    $victimInfo = $kill['involved'][0];
    if ($victimInfo == null) {
        return;
    }
    $totalPrice = $kill['zkb']['totalValue'];
    Info::addInfo($victimInfo);
    // Reduce spam of freighters and jump freighters
    $shipGroupID = $victimInfo['groupID'];
    if (in_array($shipGroupID, array(513, 902))) {
        $shipPrice = Price::getItemPrice($victimInfo['shipTypeID'], date('Ymd'));
        $ircMin += $shipPrice;
        $twitMin += $shipPrice;
    }
    $worthIt = false;
    $worthIt |= $totalPrice >= $ircMin;
    if (!$worthIt) {
        return;
    }
    $tweetIt = false;
    $tweetIt |= $totalPrice >= $twitMin;
    global $fullAddr, $twitterName;
    $url = "{$fullAddr}/kill/{$killID}/";
    if ($url == '') {
        $url = "{$fullAddr}/kill/{$killID}/";
    }
    $message = '|g|' . $victimInfo['shipName'] . '|n| worth |r|' . Util::formatIsk($totalPrice) . " ISK|n| was destroyed! {$url}";
    if (!isset($victimInfo['characterName'])) {
        $victimInfo['characterName'] = $victimInfo['corporationName'];
    }
    if (strlen($victimInfo['characterName']) < 25) {
        $name = $victimInfo['characterName'];
        if (Util::endsWith($name, 's')) {
            $name .= "'";
        } else {
            $name .= "'s";
        }
        $message = "{$name} {$message}";
    }
    $mdb->getCollection('killmails')->update(['killID' => $killID], ['$unset' => ['social' => true]]);
    Log::irc("{$message}");
    $message = Log::stripIRCColors($message);
    $message .= ' #tweetfleet #eveonline';
    if (strlen($message) > 120) {
        $message = str_replace(' worth ', ': ', $message);
    }
    if (strlen($message) > 120) {
        $message = str_replace(' was destroyed!', '', $message);
    }
    if ($tweetIt && strlen($message) <= 120) {
        $return = Twit::sendMessage($message);
        $twit = "https://twitter.com/{$twitterName}/status/" . $return->id;
        Log::irc("Message was also tweeted: |g|{$twit}");
    }
}