public function run() { $explode = explode(" ", $this->message->content); $prefix = $this->channelConfig->prefix; $system = isset($explode[0]) ? $explode[0] == "{$prefix}pc" ? "global" : str_replace($prefix, "", $explode[0]) : "global"; unset($explode[0]); $item = implode(" ", $explode); // Stuff that doesn't need a db lookup $quickLookUps = ["plex" => array("typeName" => "30 Day Pilot's License Extension (PLEX)", "typeID" => 29668), "injector" => array("typeName" => "Skill Injector", "typeID" => 40520), "extractor" => array("typeName" => "Skill Extractor", "typeID" => 40519)]; if ($system && $item) { if (isset($quickLookUps[$item])) { $single = $quickLookUps[$item]; $multiple = null; } else { $single = $this->db->queryRow("SELECT typeID, typeName FROM invTypes WHERE typeName = :item", array(":item" => $item)); $multiple = $this->db->query("SELECT typeID, typeName FROM invTypes WHERE typeName LIKE :item LIMIT 5", array(":item" => $item)); } if (count($multiple) == 1) { $single = $multiple[0]; } if (empty($single) && !empty($multiple)) { $items = array(); foreach ($multiple as $item) { $items[] = $item["typeName"]; } $items = implode(", ", $items); return $this->message->reply("**Multiple results found:** {$items}"); } // If there is a single result, we'll get data now! if ($single) { $typeID = $single["typeID"]; $typeName = $single["typeName"]; if ($system == "global") { $system = "global"; $data = new SimpleXMLElement($this->curl->get("https://api.eve-central.com/api/marketstat?typeid={$typeID}")); } else { $solarSystemID = $this->db->queryField("SELECT solarSystemID FROM mapSolarSystems WHERE solarSystemName = :system", "solarSystemID", array(":system" => $system)); $data = new SimpleXMLElement($this->curl->get("https://api.eve-central.com/api/marketstat?usesystem={$solarSystemID}&typeid={$typeID}")); } $lowBuy = number_format((double) $data->marketstat->type->buy->min, 2); $avgBuy = number_format((double) $data->marketstat->type->buy->avg, 2); $highBuy = number_format((double) $data->marketstat->type->buy->max, 2); $lowSell = number_format((double) $data->marketstat->type->sell->min, 2); $avgSell = number_format((double) $data->marketstat->type->sell->avg, 2); $highSell = number_format((double) $data->marketstat->type->sell->max, 2); $solarSystemName = $system == "pc" ? "Global" : ucfirst($system); $messageData = "```\ntypeName: {$typeName}\nsolarSystemName: {$solarSystemName}\nBuy:\n Low: {$lowBuy}\n Avg: {$avgBuy}\n High: {$highBuy}\nSell:\n Low: {$lowSell}\n Avg: {$avgSell}\n High: {$highSell}```"; $this->message->reply($messageData); } else { $this->message->reply("**Error:** ***{$item}*** not found"); } } else { $this->message->reply("**Error:** No itemName set.."); } // Mark this as garbage $this->isGarbage(); }
public function run() { $explode = explode(" ", $this->message->content); unset($explode[0]); $item = implode(" ", $explode); if (is_numeric($item)) { $data = $this->db->queryRow("SELECT * FROM invTypes WHERE typeID = :typeID", array(":typeID" => $item)); } else { $data = $this->db->queryRow("SELECT * FROM invTypes WHERE typeName = :typeName", array(":typeName" => $item)); } if ($data) { $msg = "```"; foreach ($data as $key => $value) { $msg .= $key . ": " . $value . "\n"; } $msg .= "```"; $this->message->reply($msg); } // Mark this as garbage $this->isGarbage(); }
public function run() { $explode = explode(" ", $this->message->content); $authString = isset($explode[1]) ? $explode[1] : ""; if ($this->message->getChannelAttribute()->is_private) { return $this->message->reply("**Error** You are trying to send your auth token in private. This won't work because i need the guild information, which i can only get if you post it in a public channel on the server you want to get authed on."); } $authData = $this->db->queryRow("SELECT * FROM authRegs WHERE authString = :authString AND active = 1", array(":authString" => $authString)); if ($authData) { $groups = json_decode($authData["groups"], true); $characterID = $authData["characterID"]; /** @var Role $roles */ $roles = $this->message->getFullChannelAttribute()->getGuildAttribute()->getRolesAttribute(); /** @var Member $member */ $member = $this->message->getFullChannelAttribute()->getGuildAttribute()->getMembersAttribute()->get("id", $this->message->author->id); $username = $this->message->author->username; $discordID = $this->message->author->id; // @todo Force ingame name $characterName = json_decode($this->curl->get("https://evedata.xyz/api/character/shortinformation/{$characterID}/"))->characterName; // Doesn't work yet, but it should be something like $member->nick($characterName); //$member->user->setAttribute("username", $characterName); /** @var Role $role */ foreach ($roles as $role) { $roleName = $role->name; if (in_array($roleName, $groups)) { $member->addRole($role); } } // Save the member object, so all the roles are set $member->save(); $this->db->execute("UPDATE authRegs SET discordID = :discordID, active = 0 WHERE authString = :authString", array(":discordID" => $discordID, ":authString" => $authString)); $this->log->addInfo("{$username} authenticated in {$this->message->getChannelAttribute()->name} on {$this->message->getChannelAttribute()->getGuildAttribute()->name}"); $this->message->reply("You have now been added to the following groups: " . implode(", ", $groups)); } else { $this->message->reply("**Error** You are trying to authenticate with an already used (or not existing) auth token.."); } // Mark this as garbage $this->isGarbage(); }
public function run() { $explode = explode(" ", $this->message->content); unset($explode[0]); $name = implode(" ", $explode); $name = stristr($name, "@") ? str_replace("<@", "", str_replace(">", "", $name)) : $name; if ($name) { $data = $this->db->queryRow("SELECT * FROM users WHERE (nickName = :name OR discordID = :name)", array(":name" => $name)); if ($data) { // Is the person admin? $isAdmin = "no"; foreach ($this->config->get("admins", "permissions") as $admins) { $isAdmin = $admins == $data["discordID"] ? "yes" : "no"; } $msg = "```ID: {$data["discordID"]}\nName: {$data["nickName"]}\nAdmin: {$isAdmin}\nLast Seen: {$data["lastSeen"]}\nLast Spoken: {$data["lastSpoke"]}\nLast Status: {$data["lastStatus"]}\nPlayed Last: {$data["game"]}```"; $this->message->reply($msg); } else { $this->message->reply("Error, no such user has been seen.."); } } // Mark this as garbage $this->isGarbage(); }