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(); }
public function run() { // Most EVE players on Discord use their ingame name, so lets support @highlights $explode = explode(" ", $this->message->content); unset($explode[0]); $name = implode(" ", $explode); $name = stristr($name, "@") ? str_replace("<@", "", str_replace(">", "", $name)) : $name; if (is_numeric($name)) { // The person used @highlighting, so now we got a discord id, lets map that to a name $name = $this->db->queryField("SELECT nickName FROM users WHERE discordID = :id", "nickName", array(":id" => $name)); } $url = "https://evedata.xyz/api/search/character/" . urlencode($name) . "/"; $data = @json_decode($this->curl->get($url), true)["character"]; if (empty($data)) { return $this->message->reply("**Error:** no results was returned."); } $exists = false; if (count($data) > 1) { $results = array(); foreach ($data as $char) { if (strtolower($char["characterName"]) == strtolower($name)) { $data[0]["characterID"] = $char["characterID"]; $exists = true; } $results[] = $char["characterName"]; } if ($exists == false) { return $this->message->reply("**Error:** more than one result was returned: " . implode(", ", $results)); } } // Get stats $characterID = $data[0]["characterID"]; $statsURL = "https://beta.eve-kill.net/api/charInfo/characterID/" . urlencode($characterID) . "/"; $stats = json_decode($this->curl->get($statsURL), true); if (empty($stats)) { return $this->message->reply("**Error:** no data available"); } $characterName = @$stats["characterName"]; $corporationName = @$stats["corporationName"]; $allianceName = isset($stats["allianceName"]) ? $stats["allianceName"] : "None"; $factionName = isset($stats["factionName"]) ? $stats["factionName"] : "None"; $securityStatus = @$stats["securityStatus"]; $lastSeenSystem = @$stats["lastSeenSystem"]; $lastSeenRegion = @$stats["lastSeenRegion"]; $lastSeenShip = @$stats["lastSeenShip"]; $lastSeenDate = @$stats["lastSeenDate"]; $corporationActiveArea = @$stats["corporationActiveArea"]; $allianceActiveArea = @$stats["allianceActiveArea"]; $soloKills = @$stats["soloKills"]; $blobKills = @$stats["blobKills"]; $lifeTimeKills = @$stats["lifeTimeKills"]; $lifeTimeLosses = @$stats["lifeTimeLosses"]; $amountOfSoloPVPer = @$stats["percentageSoloPVPer"]; $ePeenSize = @$stats["ePeenSize"]; $facepalms = @$stats["facepalms"]; $lastUpdated = @$stats["lastUpdatedOnBackend"]; $url = "https://beta.eve-kill.net/character/" . $stats["characterID"] . "/"; $msg = "```characterName: {$characterName}\ncorporationName: {$corporationName}\nallianceName: {$allianceName}\nfactionName: {$factionName}\nsecurityStatus: {$securityStatus}\nlastSeenSystem: {$lastSeenSystem}\nlastSeenRegion: {$lastSeenRegion}\nlastSeenShip: {$lastSeenShip}\nlastSeenDate: {$lastSeenDate}\ncorporationActiveArea: {$corporationActiveArea}\nallianceActiveArea: {$allianceActiveArea}\nsoloKills: {$soloKills}\nblobKills: {$blobKills}\nlifeTimeKills: {$lifeTimeKills}\nlifeTimeLosses: {$lifeTimeLosses}\npercentageSoloPVPer: {$amountOfSoloPVPer}\nePeenSize: {$ePeenSize}\nfacepalms: {$facepalms}\nlastUpdated: {$lastUpdated}```\nFor more info, visit: {$url}"; $this->message->reply($msg); // Mark this as garbage $this->isGarbage(); }
/** * */ public function run() { // Reap the threads! $this->websocket->loop->addPeriodicTimer(600, function () { $this->log->addInfo('Restarting the threading pool, to clear out old threads..'); // Shutdown the pool $this->pool->shutdown(); $this->timers->shutdown(); // Startup the pool again $this->pool = new \Pool(count($this->onMessage), \Worker::class); $this->timers = new \Pool(count($this->onTimer), \Worker::class); }); // Handle the onReady event, and setup some timers and so forth $this->websocket->on('ready', function (Discord $discord) { $this->log->addInfo('Websocket connected..'); // Update our presence status $game = new Game(array('name' => $this->globalConfig->get('presence', 'bot', "table flippin'"), 'url' => null, 'type' => null), true); $this->websocket->updatePresence($game, false); // Count the amount of people we are available to.. /** @var Guild $guild */ foreach ($this->discord->getClient()->getGuildsAttribute()->all() as $guild) { $this->extras['memberCount'] += $guild->member_count; $this->extras['guildCount']++; $this->extras['guild']['memberCount']["id{$guild->id}"] = $guild->member_count; $this->extras['onMessagePlugins'] = $this->onMessage; $this->extras['onVoicePlugins'] = $this->onVoice; } $this->log->addInfo("Member count, currently available to: {$this->extras['memberCount']} people"); // Setup the timers for the timer plugins foreach ($this->onTimer as $command => $data) { $this->websocket->loop->addPeriodicTimer($data['timer'], function () use($data, $discord) { try { $plugin = new $data['class']($discord, $this->log, $this->globalConfig, $this->db, $this->curl, $this->settings, $this->permissions, $this->container->get('serverConfig'), $this->users, $this->extras); $this->timers->submit($plugin); } catch (\Exception $e) { $this->log->addError("Error running the periodic timer: {$e->getMessage()}"); } }); } // Issue periodically recounting and other things (Needed because of pthreads not putting the entire context into children - leading to some weirdness in some plugins) $this->websocket->loop->addPeriodicTimer(600, function () { $this->extras['memberCount'] = 0; $this->extras['guildCount'] = 0; /** @var Guild $guild */ foreach ($this->discord->getClient()->getGuildsAttribute()->all() as $guild) { $this->extras['memberCount'] += $guild->member_count; $this->extras['guildCount']++; $this->extras['guild']['memberCount']["id{$guild->id}"] = $guild->member_count; $this->extras['onMessagePlugins'] = $this->onMessage; $this->extras['onVoicePlugins'] = $this->onVoice; } // Output periodic information while doing the recounting stuff $this->log->addInfo('Currently running audio streams: ' . count($this->audioStreams)); $this->log->addInfo("Member recount, currently available to: {$this->extras['memberCount']} people"); }); // @todo run a timer to check if there are any active voice sessions - and if there are, if there are any people in those voice sessions // If not, stop the session and leave the channel (To save some bandwidth) }); $this->websocket->on('error', function ($error, $websocket) { $this->log->addError('An error occurred on the websocket', [$error->getMessage()]); die(1); }); $this->websocket->on('close', function ($opCode, $reason) { $this->log->addWarning('Websocket got closed', ['code' => $opCode, 'reason' => $reason]); die(1); }); $this->websocket->on('reconnecting', function () { $this->log->addInfo('Websocket is reconnecting..'); }); $this->websocket->on('reconnected', function () { $this->log->addInfo('Websocket was reconnected..'); }); // Handle incoming message logging $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) { $this->log->addInfo("Message from {$message->author->username}", [$message->content]); // Don't update data for ourselves.. if ($message->author->id !== $discord->getClient()->id) { $this->users->set($message->author->id, $message->author->username, 'online', null, date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), $message->content); } // @todo Create text logs }); // Handle plugin running $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) { $guildID = $message->getChannelAttribute()->guild_id; // Get server config $config = $this->settings->get($guildID); // Is the person admin? $userDiscordID = $message->author->id; foreach ($this->globalConfig->get('admins', 'permissions') as $admins) { $message->isAdmin = $admins === $userDiscordID; } // Define the prefix if it isn't already set.. @($config->prefix = $config->prefix ?? $this->globalConfig->get('prefix', 'bot')); // Check if the user requested an onMessage plugin if (substr($message->content, 0, strlen($config->prefix)) === $config->prefix) { $content = explode(' ', $message->content); foreach ($this->onMessage as $command => $data) { $parts = []; foreach ($content as $index => $c) { foreach (explode("\n", $c) as $p) { $parts[] = $p; } } if ($parts[0] === $config->prefix . $command) { // If they are listed under the admins array in the bot config, they're the super admins if (in_array($message->author->id, $this->globalConfig->get('admins', 'permissions'))) { $userPerms = 3; } elseif (null !== $message->getChannelAttribute()->getGuildAttribute()->owner_id && $message->author->id === $message->getChannelAttribute()->getGuildAttribute()->owner_id) { $userPerms = 2; } else { $userPerms = 1; } if ($userPerms >= $data['permissions']) { try { $message->getChannelAttribute()->broadcastTyping(); if ($data['class'] === "\\Sovereign\\Plugins\\onMessage\\auth") { /** @var \Threaded $plugin */ $plugin = new $data['class']($message, $discord, $config, $this->log, $this->globalConfig, $this->db, $this->curl, $this->settings, $this->permissions, $this->container->get('serverConfig'), $this->users, $this->extras); $plugin->run(); } else { /** @var \Threaded $plugin */ $plugin = new $data['class']($message, $discord, $config, $this->log, $this->globalConfig, $this->db, $this->curl, $this->settings, $this->permissions, $this->container->get('serverConfig'), $this->users, $this->extras); $this->pool->submit($plugin); } $this->log->addInfo("{$message->author->username}#{$message->author->discriminator} ({$message->author}) ran command {$config->prefix}{$command}", $content); } catch (\Exception $e) { $this->log->addError("Error running command {$config->prefix}{$command}. Command run by {$message->author->username} in {$message->getChannelAttribute()->name}. Error: {$e->getMessage()}"); $message->reply("**Error:** There was a problem running the command: {$e->getMessage()}"); } } } } } }); // Handle joining a voice channel, and playing.. stuff.... $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) { // Get the guildID $guildID = $message->getChannelAttribute()->guild_id; // Get this guilds settings $config = $this->settings->get($guildID); // Get the prefix for this guild @($config->prefix = $config->prefix ?? $this->globalConfig->get('prefix', 'bot')); if (substr($message->content, 0, strlen($config->prefix)) === $config->prefix) { $content = explode(' ', $message->content); foreach ($this->onVoice as $command => $data) { $parts = []; foreach ($content as $index => $c) { foreach (explode("\n", $c) as $p) { $parts[] = $p; } } if ($parts[0] === $config->prefix . $command) { try { $voiceChannels = $message->getFullChannelAttribute()->getGuildAttribute()->channels->getAll('type', 'voice'); foreach ($voiceChannels as $channel) { if (!empty($channel->members[$message->author->id])) { $voice = new $data['class'](); $voice->run($message, $discord, $this->websocket, $this->log, $this->audioStreams, $channel, $this->curl); } } } catch (\Exception $e) { $this->log->addError("Error running voice command {$config->prefix}{$command}. Command run by {$message->author->username} in {$message->getChannelAttribute()->name}. Error: {$e->getMessage()}"); $message->reply("**Error:** There was a problem running the command: {$e->getMessage()}"); } } } } }); // Handle if it's a message for the bot (CleverBot invocation) $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) { // If we got highlighted we should probably answer back if (stristr($message->content, $discord->getClient()->id)) { try { $this->pool->submit(new cleverBotMessage($message, $discord, $this->log, $this->globalConfig, $this->db, $this->curl, $this->settings, $this->permissions, $this->container->get('serverConfig'), $this->users)); } catch (\Exception $e) { $message->reply("**Error:** There was an error with CleverBot: {$e->getMessage()}"); } } }); // Handle presence updates $this->websocket->on(Event::PRESENCE_UPDATE, function (PresenceUpdate $presenceUpdate) { if ($presenceUpdate->user->id && $presenceUpdate->user->username) { try { $this->log->addInfo("Updating presence info for {$presenceUpdate->user->username}"); $game = $presenceUpdate->getGameAttribute()->name ?? null; $this->users->set($presenceUpdate->user->id, $presenceUpdate->user->username, $presenceUpdate->status, $game, date('Y-m-d H:i:s'), null, null); } catch (\Exception $e) { $this->log->addError("Error: {$e->getMessage()}"); } } }); // Create a new cleverbot \nick\ for this new guild $this->websocket->on(Event::GUILD_CREATE, function (Guild $guild) { $cleverBotExists = $this->db->queryField("SELECT serverID FROM cleverbot WHERE serverID = :serverID", "serverID", array(":serverID" => $guild->id)); $guildExists = $this->db->queryField("SELECT guildID FROM guilds WHERE guildID = :serverID", "guildID", array(":serverID" => $guild->id)); // Only create a new server nick if the cleverbot instance doesn't exist.. (Hopefully cleverbot.io is done deleting them at random) if (!isset($cleverBotExists)) { $this->log->addInfo("Setting up Cleverbot for {$guild->name}"); $serverID = $guild->id; $result = $this->curl->post('https://cleverbot.io/1.0/create', ['user' => $this->globalConfig->get('user', 'cleverbot'), 'key' => $this->globalConfig->get('key', 'cleverbot')]); if ($result) { $result = @json_decode($result); $nick = $result->nick ?? false; if ($nick) { $this->db->execute('INSERT INTO cleverbot (serverID, nick) VALUES (:serverID, :nick) ON DUPLICATE KEY UPDATE nick = :nick', [':serverID' => $serverID, ':nick' => $nick]); } } } if (!isset($guildExists)) { $this->db->execute("INSERT IGNORE INTO guilds (guildID) VALUES (:guildID)", array(":guildID" => $guild->id)); // Send a hello message to the channel (Only if it's new!) //$message = "Hello, i was invited here by someone with admin permissions, i have quite a few features that you can discover by doing %help\n"; //$message .= "I am sorry if i am triggering other bots aswell, you can change my trigger with %config setTrigger newTrigger (Example: %config setTrigger *)\n"; //$message .= "If you for some reason don't want me here after all, just kick me ;)"; // Get the first channel in the list (usually the default channel) //$channel = $guild->channels->first(); //$channel->sendMessage($message); } }); // Run the websocket, and in turn, the bot! $this->websocket->run(); }
public function run() { $guildID = $this->message->full_channel->guild->id; $input = explode(" ", $this->message->content); unset($input[0]); $type = isset($input[1]) ? $input[1] : ""; unset($input[1]); // Defaults $channelID = $this->message->channel_id; $msg = ""; // Config options switch (trim($type)) { case "setTrigger": $trigger = $input[2]; $orgTrigger = $this->serverConfig->get($guildID, "prefix") ? $this->serverConfig->get($guildID, "prefix") : $this->channelConfig->prefix; $this->serverConfig->set($guildID, "prefix", $trigger); $msg = "Trigger has been changed from {$orgTrigger} to {$trigger}"; break; case "enablePorn": $pornArray = $this->serverConfig->getAll($guildID)->p**n->allowedChannels; if (!in_array($channelID, $pornArray)) { $pornArray[] = $channelID; } $this->serverConfig->set($guildID, "p**n", array("allowedChannels" => $pornArray)); $msg = "P**n has now been enabled on this channel, enjoy, you perv ;)"; break; case "disablePorn": $pornArray = $this->serverConfig->getAll($guildID)->p**n->allowedChannels; foreach ($pornArray as $key => $value) { if ($value == $channelID) { unset($pornArray[$key]); } } $this->serverConfig->set($guildID, "p**n", array("allowedChannels" => $pornArray)); $msg = "P**n has now been disabled on this channel. :("; break; case "addKillmails": // %config addKillmails character characterID $typeName = trim($input[2]); $typeID = trim($input[3]); switch ($typeName) { case "character": // Check said char exists on the killboard.. $exists = json_decode($this->curl->get("https://evedata.xyz/api/character/information/{$typeID}/")); if (isset($exists->characterID)) { $this->db->execute("INSERT IGNORE INTO killmailPosting (channelID, typeName, typeID) VALUES (:channelID, :typeName, :typeID)", array(":channelID" => $channelID, ":typeName" => $typeName, ":typeID" => $typeID)); $msg = "**Success** killmails should start getting posted for {$exists->characterName} to this channel"; } else { $msg = "**Error** characterID is not valid"; } break; case "corporation": // Check said char exists on the killboard.. $exists = json_decode($this->curl->get("https://evedata.xyz/api/corporation/information/{$typeID}/")); if (isset($exists->corporationID)) { $this->db->execute("INSERT IGNORE INTO killmailPosting (channelID, typeName, typeID) VALUES (:channelID, :typeName, :typeID)", array(":channelID" => $channelID, ":typeName" => $typeName, ":typeID" => $typeID)); $msg = "**Success** killmails should start getting posted for {$exists->corporationName} to this channel"; } else { $msg = "**Error** corporationID is not valid"; } break; case "alliance": // Check said char exists on the killboard.. $exists = json_decode($this->curl->get("https://evedata.xyz/api/alliance/information/{$typeID}/")); if (isset($exists->allianceID)) { $this->db->execute("INSERT IGNORE INTO killmailPosting (channelID, typeName, typeID) VALUES (:channelID, :typeName, :typeID)", array(":channelID" => $channelID, ":typeName" => $typeName, ":typeID" => $typeID)); $msg = "**Success** killmails should start getting posted for {$exists->allianceName} to this channel"; } else { $msg = "**Error** allianceID is not valid"; } break; } break; case "removeKillmails": break; case "listKillmails": break; case "addTwitterOauth": // Add oauth settings for twitter, and send twitter messages to the channel it was enabled in, unless channelID was passed along break; case "removeTwitterOauth": // Disable twitter, and remove the oauth keys break; case "addSiphonKey": // Add an apikey used for checking for siphons, output to the channel it was enabled in, unless a channelID was passed along break; case "removeSiphonKey": break; case "addMailKey": // same as add siphon break; case "removeMailKey": break; case "addNotificationKey": // same as add siphon break; case "removeNotificationKey": break; case "addAuth": // Enable authentication for a characterID, corporationID or allianceID - have multiple, and let them map 1:1 to groups on Discord (if group doesn't exist, create it) break; case "removeAuth": break; case "addJabberReader": // Setup a socket to listen for messages, make them prepend a key for the channel it was enabled in (unless a channelID was specified) break; case "removeJabberReader": break; default: $msg = "Error, no configuration option picked. Available configuration options are: setTrigger, enablePorn, disablePorn, addTwitterOauth, removeTwitterOauth, addSiphonKey, removeSiphonKey, addMailKey, removeMailKey, addNotificationKey, removeNotificationKey, addJabberReader, removeJabberReader, addAuth, removeAuth"; break; } $this->message->reply($msg); // Mark this as garbage $this->isGarbage(); }
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); } } } }
/** * */ public function run() { $guildID = $this->message->getFullChannelAttribute()->guild_id; $cleverBotNick = $this->db->queryField("SELECT nick FROM cleverbot WHERE serverID = :serverID", "nick", array(":serverID" => $guildID)); // Simply remove the <id> part of the string, since it seems to make the responses from Cleverbot be less idiotic and terrible.. $msg = str_replace("<@{$this->discord->getClient()->id}>", "", $this->message->content); $response = $this->curl->post("https://cleverbot.io/1.0/ask", array("user" => $this->config->get("user", "cleverbot"), "key" => $this->config->get("key", "cleverbot"), "nick" => $cleverBotNick, "text" => $msg)); if ($response) { $resp = @json_decode($response); $reply = isset($resp->response) ? $resp->response : false; if ($reply) { $this->message->getChannelAttribute()->broadcastTyping(); $this->message->reply($reply); } } }