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 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}"); } }
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}"); } }