Example #1
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage($msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         global $plugins;
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $messageString = $data["messageString"];
         if (!$messageString) {
             // Show all modules available
             $commands = array();
             foreach ($plugins["onMessage"] as $plugin) {
                 $info = $plugin->information();
                 if (!empty($info["name"])) {
                     $commands[] = $info["name"];
                 }
             }
             $msgData->user->reply("**Help:** No specific plugin requested, here is a list of plugins available: **" . implode("** | **", $commands) . "**");
         } else {
             foreach ($plugins["onMessage"] as $plugin) {
                 if ($messageString == $plugin->information()["name"]) {
                     $msgData->user->reply($plugin->information()["information"]);
                 }
             }
         }
         //$this->log->info("Sending time info to {$channelName} on {$guildName}");
         //$msgData->user->reply($msg);
     }
 }
Example #2
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $messageString = $data["messageString"];
         $response = $this->wolframAlpha->getResults($messageString);
         // There was an error
         if ($response->isError()) {
             var_dump($response->error);
         }
         $guess = $response->getPods();
         if (isset($guess[1])) {
             $guess = $guess[1]->getSubpods();
             $text = $guess[0]->plaintext;
             $image = $guess[0]->image->attributes["src"];
             if (stristr($text, "\n")) {
                 $text = str_replace("\n", " | ", $text);
             }
             $msg = "{$text}\n{$image}";
             $msgData->user->reply($msg);
         }
         //$this->log->info("Sending time info to {$channelName} on {$guildName}");
         //$msgData->user->reply($msg);
     }
 }
Example #3
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage($msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $date = date("d-m-Y");
         $fullDate = date("Y-m-d H:i:s");
         $dateTime = new DateTime($fullDate);
         $et = $dateTime->setTimezone(new DateTimeZone("America/New_York"));
         $et = $et->format("H:i:s");
         $pt = $dateTime->setTimezone(new DateTimeZone("America/Los_Angeles"));
         $pt = $pt->format("H:i:s");
         $utc = $dateTime->setTimezone(new DateTimeZone("UTC"));
         $utc = $utc->format("H:i:s");
         $cet = $dateTime->setTimezone(new DateTimeZone("Europe/Copenhagen"));
         $cet = $cet->format("H:i:s");
         $msk = $dateTime->setTimezone(new DateTimeZone("Europe/Moscow"));
         $msk = $msk->format("H:i:s");
         $aest = $dateTime->setTimezone(new DateTimeZone("Australia/Sydney"));
         $aest = $aest->format("H:i:s");
         $msg = "**Current EVE Time:** {$utc} / **EVE Date:** {$date} / **PT:** {$pt} / **ET:** {$et} / **CET:** {$cet} / **MSK:** {$msk} / **AEST:** {$aest}";
         $this->log->info("Sending time info to {$channelName} on {$guildName}");
         $msgData->user->reply($msg);
     }
 }
Example #4
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         // Most EVE players on Discord use their ingame name, so lets support @highlights
         $messageString = stristr($data["messageString"], "@") ? str_replace("<@", "", str_replace(">", "", $data["messageString"])) : $data["messageString"];
         if (is_numeric($messageString)) {
             // The person used @highlighting, so now we got a discord id, lets map that to a name
             $messageString = $this->sluggardDB->queryField("SELECT name FROM usersSeen WHERE id = :id", "name", array(":id" => $messageString));
         }
         $url = "http://rena.karbowiak.dk/api/search/character/{$messageString}/";
         $data = @json_decode($this->curl->getData($url), true)["character"];
         if (empty($msgData)) {
             return $msgData->user->reply("**Error:** no results was returned.");
         }
         if (count($msgData) > 1) {
             $results = array();
             foreach ($msgData as $char) {
                 $results[] = $char["characterName"];
             }
             return $msgData->user->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->getData($statsURL), true);
         if (empty($stats)) {
             return $msgData->user->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}\r\ncorporationName: {$corporationName}\r\nallianceName: {$allianceName}\r\nfactionName: {$factionName}\r\nsecurityStatus: {$securityStatus}\r\nlastSeenSystem: {$lastSeenSystem}\r\nlastSeenRegion: {$lastSeenRegion}\r\nlastSeenShip: {$lastSeenShip}\r\nlastSeenDate: {$lastSeenDate}\r\ncorporationActiveArea: {$corporationActiveArea}\r\nallianceActiveArea: {$allianceActiveArea}\r\nsoloKills: {$soloKills}\r\nblobKills: {$blobKills}\r\nlifeTimeKills: {$lifeTimeKills}\r\nlifeTimeLosses: {$lifeTimeLosses}\r\npercentageSoloPVPer: {$amountOfSoloPVPer}\r\nePeenSize: {$ePeenSize}\r\nfacepalms: {$facepalms}\r\nlastUpdated: {$lastUpdated}```\r\nFor more info, visit: {$url}";
         $this->log->info("Sending char info to {$channelName} on {$guildName}");
         $msgData->user->reply($msg);
     }
 }
Example #5
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $sides = array("Heads", "Tails");
         $msgData->user->reply("The result of the coinflip is: " . $sides[array_rand($sides)]);
     }
 }
Example #6
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $memes = array('dank meme', '>mfw no gf', "m'lady *tip*", 'le toucan has arrived', "jet juel can't melt dank memes", '༼ つ ◕_◕ ༽つ gibe', 'ヽ༼ຈل͜ຈ༽ノ raise your dongers ヽ༼ຈل͜ຈ༽ノ', 'ヽʕ •ᴥ•ʔノ raise your koalas ヽʕ •ᴥ•ʔノ', 'ಠ_ಠ', '(-‸ლ)', '( ͡° ͜ʖ ͡°)', '( ° ͜ʖ͡°)╭∩╮', '(╯°□°)╯︵ ┻━┻', '┬──┬ ノ( ゜-゜ノ)', '•_•) ( •_•)>⌐■-■ (⌐■_■)', "i dunno lol ¯\\(°_o)/¯", "how do i shot web ¯\\(°_o)/¯", '(◕‿◕✿)', 'ヾ(〃^∇^)ノ', '\( ̄▽ ̄)/', '(ノ◕ヮ◕)ノ*:・゚✧', 'ᕕ( ͡° ͜ʖ ͡°)ᕗ', 'ᕕ( ᐛ )ᕗ ᕕ( ᐛ )ᕗ ᕕ( ᐛ )ᕗ', "(ノ◕ヮ◕)ノ *:・゚✧ SO KAWAII ✧・:* \\(◕ヮ◕\\)", 'ᕙ༼ຈل͜ຈ༽ᕗ. ʜᴀʀᴅᴇʀ, ʙᴇᴛᴛᴇʀ, ғᴀsᴛᴇʀ, ᴅᴏɴɢᴇʀ .ᕙ༼ຈل͜ຈ༽ᕗ', "(∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。゚you've been touched by the donger fairy", '(ง ͠° ͟ل͜ ͡°)ง ᴍᴀsᴛᴇʀ ʏᴏᴜʀ ᴅᴏɴɢᴇʀ, ᴍᴀsᴛᴇʀ ᴛʜᴇ ᴇɴᴇᴍʏ (ง ͠° ͟ل͜ ͡°)ง', "(⌐■_■)=/̵͇̿̿/'̿'̿̿̿ ̿ ̿̿ ヽ༼ຈل͜ຈ༽ノ keep your dongers where i can see them", '[̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅] do you have change for a donger bill [̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅]', '╰( ͡° ͜ʖ ͡° )つ──☆*:・゚ clickty clack clickty clack with this chant I summon spam to the chat', 'work it ᕙ༼ຈل͜ຈ༽ᕗ harder make it (ง •̀_•́)ง better do it ᕦ༼ຈل͜ຈ༽ᕤ faster raise ur ヽ༼ຈل͜ຈ༽ノ donger');
         $msgData->user->reply($memes[array_rand($memes)]);
     }
 }
Example #7
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $choices = array('It is certain', 'It is decidedly so', 'Without a doubt', 'Yes, definitely', 'You may rely on it', 'As I see it, yes', 'Most likely', 'More than likely', 'Outlook good', 'Yes', 'No', 'Lol no', 'Signs point to, yes', 'Reply hazy, try again', 'Ask again later', 'I Better not tell you now', 'I Cannot predict now', 'Concentrate and ask again', 'Don\'t count on it', 'My reply is no', 'My sources say no', 'Outlook not so good', 'Very doubtful');
         $msgData->user->reply($choices[array_rand($choices)]);
     }
 }
Example #8
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $guilds = "";
         foreach ($this->discord->guilds as $guild) {
             $guilds .= "{$guild->name}, ";
         }
         $msgData->user->reply("I am on the following servers: " . rtrim($guilds, ","));
     }
 }
Example #9
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $guildID = $msgData->guild->id;
         $switch = $data["messageArray"][0];
         switch ($switch) {
             case "save":
                 $fittingURL = $data["messageArray"][1];
                 unset($data["messageArray"][0]);
                 unset($data["messageArray"][1]);
                 $fittingName = implode(" ", $data["messageArray"]);
                 $this->sluggardDB->execute("REPLACE INTO fittings (guildID, fittingName, fittingURL) VALUES (:guildID, :fittingName, :fittingURL)", array(":guildID" => $guildID, ":fittingName" => $fittingName, ":fittingURL" => $fittingURL));
                 $this->log->info("Saved fitting ({$fittingName}) on {$guildName}");
                 $msg = "Fitting saved, you can now call upon it by using !fit {$fittingName}";
                 $msgData->user->reply($msg);
                 break;
             case "delete":
                 unset($data["messageArray"][0]);
                 $fittingName = implode(" ", $data["messageArray"]);
                 if (strlen($fittingName) > 1) {
                     $fittingData = $this->sluggardDB->queryField("SELECT fittingURL FROM fittings WHERE fittingName = :fittingName AND guildID = :guildID", "fittingURL", array(":fittingName" => $fittingName, ":guildID" => $guildID));
                     if ($fittingData) {
                         $this->sluggardDB->execute("DELETE FROM fittings WHERE fittingName = :fittingName AND guildID = :guildID", array(":fittingName" => $fittingName, ":guildID" => $guildID));
                         $msg = "Fitting {$fittingName} was deleted";
                     } else {
                         $msg = "Fitting {$fittingName} not found for this server";
                     }
                 } else {
                     $msg = "Error with your search";
                 }
                 $msgData->user->reply($msg);
                 break;
             default:
                 $search = $data["messageString"];
                 if (strlen($search) > 1) {
                     $fittingData = $this->sluggardDB->queryField("SELECT fittingURL FROM fittings WHERE fittingName = :fittingName AND guildID = :guildID", "fittingURL", array(":fittingName" => $search, ":guildID" => $guildID));
                     if ($fittingData) {
                         $msg = "Fitting {$search} can be seen here: {$fittingData}";
                     } else {
                         $msg = "Fitting {$search} not found for this server";
                     }
                 } else {
                     $msg = "Error with your search";
                 }
                 $msgData->user->reply($msg);
                 break;
         }
     }
 }
Example #10
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     $username = $msgData->message->from;
     $channelName = $msgData->channel->name;
     $guildName = $msgData->guild->name;
     if (isset($data["trigger"])) {
         $this->log->info("Sending log stats info to {$username} in {$channelName} on {$guildName}");
         $msg = "To view the log stats for this channel, look at: http://pisg.karbowiak.dk/" . urlencode(urlencode($guildName) . "." . urlencode($channelName)) . ".html";
         $msgData->user->reply($msg);
     }
 }
Example #11
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage($msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $crestData = json_decode($this->curl->getData("https://public-crest.eveonline.com/"), true);
         $tqStatus = isset($crestData["serviceStatus"]["eve"]) ? $crestData["serviceStatus"]["eve"] : "offline";
         $tqOnline = (int) $crestData["userCounts"]["eve"];
         $msg = "**TQ Status:** {$tqStatus} with {$tqOnline} users online.";
         $this->log->info("Sending eveStatus info to {$channelName} on {$guildName}");
         $msgData->user->reply($msg);
     }
 }
Example #12
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $systemName = $data["trigger"];
         $itemName = $data["messageString"];
         if ($itemName) {
             // Quick lookups
             if (isset($this->quickLookUps[$itemName])) {
                 $single = $this->quickLookUps[$itemName];
                 $multiple = null;
             } else {
                 $single = $this->ccpDB->queryRow("SELECT typeID, typeName FROM invTypes WHERE typeName = :item COLLATE NOCASE", array(":item" => ucfirst($itemName)));
                 $multiple = $this->ccpDB->query("SELECT typeID, typeName FROM invTypes WHERE typeName LIKE :item COLLATE NOCASE LIMIT 5", array(":item" => "%" . ucfirst($itemName) . "%"));
             }
             // Sometimes the multiple lookup is returning just one
             if (count($multiple) == 1) {
                 $single = $multiple[0];
             }
             // If there are multiple results, and not a single result, it's an error
             if (empty($single) && !empty($multiple)) {
                 $items = array();
                 foreach ($multiple as $item) {
                     $items[] = $item["typeName"];
                 }
                 $items = implode(", ", $items);
                 return $msgData->user->reply("**Multiple results found:** {$items}");
             }
             // If there is a single result, we'll get data now!
             if ($single) {
                 $typeID = $single["typeID"];
                 $typeName = $single["typeName"];
                 $solarSystemID = $systemName == "pc" ? "global" : $this->solarSystems[$systemName];
                 // Get pricing data
                 if ($solarSystemID == "global") {
                     $data = new SimpleXMLElement($this->curl->getData("https://api.eve-central.com/api/marketstat?typeid={$typeID}"));
                 } else {
                     $data = new SimpleXMLElement($this->curl->getData("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);
                 $this->log->info("Sending pricing info to {$channelName} on {$guildName}");
                 $solarSystemName = $systemName == "pc" ? "Global" : ucfirst($systemName);
                 $messageData = "```\r\ntypeName: {$typeName}\r\nsolarSystemName: {$solarSystemName}\r\nBuy:\r\n  Low: {$lowBuy}\r\n  Avg: {$avgBuy}\r\n  High: {$highBuy}\r\nSell:\r\n  Low: {$lowSell}\r\n  Avg: {$avgSell}\r\n  High: {$highSell}```";
                 $msgData->user->reply($messageData);
             } else {
                 $msgData->user->reply("**Error:** ***{$itemName}*** not found");
             }
         } else {
             $msgData->user->reply("**Error:** No itemName set..");
         }
     }
 }
Example #13
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $messageString = $data["messageString"];
         $url = "http://rena.karbowiak.dk/api/search/corporation/{$messageString}/";
         $data = @json_decode($this->curl->getData($url), true)["corporation"];
         if (empty($data)) {
             return $msgData->user->reply("**Error:** no results was returned.");
         }
         if (count($data) > 1) {
             $results = array();
             foreach ($data as $corp) {
                 $results[] = $corp["corporationName"];
             }
             return $msgData->user->reply("**Error:** more than one result was returned: " . implode(", ", $results));
         }
         // Get stats
         $corporationID = $data[0]["corporationID"];
         $statsURL = "https://beta.eve-kill.net/api/corpInfo/corporationID/" . urlencode($corporationID) . "/";
         $stats = json_decode($this->curl->getData($statsURL), true);
         if (empty($stats)) {
             return $msgData->user->reply("**Error:** no data available");
         }
         $corporationName = @$stats["corporationName"];
         $allianceName = isset($stats["allianceName"]) ? $stats["allianceName"] : "None";
         $factionName = isset($stats["factionName"]) ? $stats["factionName"] : "None";
         $ceoName = @$stats["ceoName"];
         $homeStation = @$stats["stationName"];
         $taxRate = @$stats["taxRate"];
         $corporationActiveArea = @$stats["corporationActiveArea"];
         $allianceActiveArea = @$stats["allianceActiveArea"];
         $lifeTimeKills = @$stats["lifeTimeKills"];
         $lifeTimeLosses = @$stats["lifeTimeLosses"];
         $memberCount = @$stats["memberArrayCount"];
         $superCaps = @count($stats["superCaps"]);
         $ePeenSize = @$stats["ePeenSize"];
         $url = "https://beta.eve-kill.net/corporation/" . @$stats["corporationID"] . "/";
         $msg = "```corporationName: {$corporationName}\r\nallianceName: {$allianceName}\r\nfactionName: {$factionName}\r\nceoName: {$ceoName}\r\nhomeStation: {$homeStation}\r\ntaxRate: {$taxRate}\r\ncorporationActiveArea: {$corporationActiveArea}\r\nallianceActiveArea: {$allianceActiveArea}\r\nlifeTimeKills: {$lifeTimeKills}\r\nlifeTimeLosses: {$lifeTimeLosses}\r\nmemberCount: {$memberCount}\r\nsuperCaps: {$superCaps}\r\nePeenSize: {$ePeenSize}\r\n```\r\nFor more info, visit: {$url}";
         $this->log->info("Sending corp info to {$channelName} on {$guildName}");
         $msgData->user->reply($msg);
     }
 }
Example #14
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $startTime = $this->app->startTime;
         $time1 = new DateTime(date("Y-m-d H:i:s", $startTime));
         $time2 = new DateTime(date("Y-m-d H:i:s"));
         $interval = $time1->diff($time2);
         $gitRevision = $this->app->gitrevision->getRevision();
         $msg = "```Hello, i am Sluggard - i am a bot created for EVE Online related Discord servers.\r\nAlso, i am the half-brother of Sovereign, atleast in the Blasto 7 movie..\r\n\r\nAbout Me:\r\nAuthor: Karbowiak (Discord ID: 118440839776174081)\r\nLibrary: DiscordPHP (https://github.com/teamreflex/DiscordPHP\\)\r\nCurrent version: " . $gitRevision["short"] . " (Last Update: " . $gitRevision["lastChangeDate"] . ")\r\nGithub Repo: https://github.com/karbowiak/Sluggard\\\r\n\r\nStatistics:\r\nUptime: " . $interval->y . " Year(s), " . $interval->m . " Month(s), " . $interval->d . " Days, " . $interval->h . " Hours, " . $interval->i . " Minutes, " . $interval->s . " seconds.\r\nMemory Usage: ~" . round(memory_get_usage() / 1024 / 1024, 3) . "MB```";
         $this->log->info("Sending about info to {$channelName} on {$guildName}");
         $msgData->user->reply($msg);
     }
 }
Example #15
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $authString = trim($data["messageString"]);
         $private = (bool) $msgData->channel->is_private;
         $authData = $this->authData->queryRow("SELECT * FROM registrations WHERE authString = :authString AND active = 1", array(":authString" => $authString));
         if ($private) {
             return $msgData->user->reply("**Error:** you are trying to send your auth token in private. This won't work because i need Guild information. Post it in a channel on the server where you want to be authed");
         }
         // Someone had a valid auth string, amazing
         if (!empty($authData)) {
             $groups = json_decode($authData["groups"], true);
             $roles = $msgData->guild->roles;
             $guild = $this->discord->guilds->first();
             //$guild = $this->discord->guilds->get("id", $msgData->guild->id);
             $member = $guild->members->get("id", $msgData->user->author->id);
             $username = $msgData->user->author->username;
             $discordID = $msgData->user->author->id;
             $characterID = $authData["characterID"];
             $corporationID = $authData["corporationID"];
             $allianceID = $authData["allianceID"];
             foreach ($roles as $role) {
                 $roleName = $role->name;
                 if (in_array($roleName, $groups)) {
                     // Add user to group
                     $member->addRole($role);
                     $member->save();
                 }
             }
             // Add the user data to the local database so we can recheck it
             $this->sluggardDB->execute("REPLACE INTO authentications (discordID, characterID, corporationID, allianceID) VALUES (:discordID, :characterID, :corporationID, :allianceID)", array("discordID" => $discordID, ":characterID" => $characterID, ":corporationID" => $corporationID, ":allianceID" => $allianceID));
             // Now set the auth to inactive, and we'll be golden
             $this->authData->execute("UPDATE registrations SET active = 0 WHERE authString = :authString", array(":authString" => $authString));
             $this->log->info("Authenticating {$username} in {$channelName} on {$guildName}");
             $msgData->user->reply("You have now been added to the following groups: " . implode(", ", $groups));
         } else {
             $msgData->user->reply("**Error:** you are trying to use an already used auth code, or a non-existing auth code. Either way, prepare to get #rekt");
         }
     }
 }
Example #16
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $user = stristr($data["messageString"], "@") ? str_replace("<@", "", str_replace(">", "", $data["messageString"])) : $data["messageString"];
         // Get data for user
         $userData = $this->sluggardDB->queryRow("SELECT * FROM usersSeen WHERE (name = :name COLLATE NOCASE OR id = :name)", array(":name" => $user));
         if ($userData) {
             $msg = "```ID: {$userData["id"]}\nName: {$userData["name"]}\nisAdmin: {$userData["isAdmin"]}\nLast Seen: {$userData["lastSeen"]}\nLast Spoken: {$userData["lastSpoke"]}\nLast Status: {$userData["lastStatus"]}```";
             $this->log->info("Sending time info to {$channelName} on {$guildName}");
             $msgData->user->reply($msg);
         } else {
             $msgData->user->reply("**Error:** no such user in the users table");
         }
     }
 }
Example #17
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage($msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         $channelName = $msgData->channel->name;
         $guildName = $msgData->guild->name;
         $item = $data["messageString"];
         if (is_numeric($item)) {
             $data = $this->ccpDB->queryRow("SELECT * FROM invTypes WHERE typeID = :item", array(":item" => $item));
         } else {
             $data = $this->ccpDB->queryRow("SELECT * FROM invTypes WHERE typeName = :item COLLATE NOCASE", array(":item" => $item));
         }
         if ($data) {
             $msg = "```";
             foreach ($data as $key => $value) {
                 $msg .= $key . ": " . $value . "\n";
             }
             $msg .= "```";
             $this->log->info("Sending item info to {$channelName} on {$guildName}");
             $msgData->user->reply($msg);
         }
     }
 }
Example #18
0
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  * @return mixed
  */
 public function onMessage($msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     // If this channel is not in the allowed channels array for this plugin, we'll just quit
     if (!in_array($msgData->message->channelID, $this->channelLimit[get_class($this)])) {
         $channelIDs = array();
         foreach ($this->channelLimit[get_class($this)] as $c) {
             $channelIDs[] = "<#" . $c . "> ";
         }
         $channelsAllowed = implode(" ", $channelIDs);
         $msg = "**Error:** this plugin only works in {$channelsAllowed}";
         return $msgData->user->reply($msg);
     }
     if (isset($data["trigger"])) {
         $urls = array();
         // If it doesn't exist, we'll just make it an empty string..
         if (!isset($data["messageArray"][0])) {
             $data["messageArray"][0] = "";
         }
         switch ($data["messageArray"][0]) {
             case "redheads":
             case "redhead":
             case "red":
                 $urls = array("https://api.imgur.com/3/gallery/r/redheads/time/all/", "https://api.imgur.com/3/gallery/r/ginger/time/all/", "https://api.imgur.com/3/gallery/r/FireCrotch/time/all/");
                 break;
             case "blondes":
                 $urls = array("https://api.imgur.com/3/gallery/r/blondes/time/all/");
                 break;
             case "asians":
                 $urls = array("https://api.imgur.com/3/gallery/r/AsiansGoneWild/time/all/");
                 break;
             case "gonewild":
                 $urls = array("https://api.imgur.com/3/gallery/r/gonewild/time/all/");
                 break;
             case "realgirls":
                 $urls = array("https://api.imgur.com/3/gallery/r/realgirls/time/all/");
                 break;
             case "palegirls":
                 $urls = array("https://api.imgur.com/3/gallery/r/palegirls/time/all/");
                 break;
             case "gif":
                 $urls = array("https://api.imgur.com/3/gallery/r/NSFW_GIF/time/all/");
                 break;
             case "lesbians":
                 $urls = array("https://api.imgur.com/3/gallery/r/lesbians/time/all/");
                 break;
             case "tattoos":
                 $urls = array("https://api.imgur.com/3/gallery/r/Hotchickswithtattoos/time/all/");
                 break;
             case "mgw":
             case "militarygonewild":
                 $urls = array("https://api.imgur.com/3/gallery/r/MilitaryGoneWild/time/all/");
                 break;
             case "amateur":
                 $urls = array("https://api.imgur.com/3/gallery/r/AmateurArchives/time/all/");
                 break;
             case "college":
                 $urls = array("https://api.imgur.com/3/gallery/r/collegesluts/time/all/");
                 break;
             case "bondage":
                 $urls = array("https://api.imgur.com/3/gallery/r/bondage/time/all/");
                 break;
             case "milf":
                 $urls = array("https://api.imgur.com/3/gallery/r/milf/time/all/");
                 break;
             case "freckles":
                 $urls = array("https://api.imgur.com/3/gallery/r/FreckledGirls/time/all/");
                 break;
             case "cosplay":
                 $urls = array("https://api.imgur.com/3/gallery/r/cosplay/time/all/");
                 break;
             case "boobs":
                 $urls = array("https://api.imgur.com/3/gallery/r/boobs/time/all/");
                 break;
             case "ass":
                 $urls = array("https://api.imgur.com/3/gallery/r/ass/time/all/");
                 break;
             default:
                 $msg = "No endpoint selected. Currently available are: redheads, blondes, asians, gonewild, realgirls, palegirls, gif, lesbians, tattoos, mgw/militarygonewild, amateur, college, bondage, milf, freckles, boobs, ass and cosplay";
                 $msgData->user->reply($msg);
                 break;
         }
         if (!empty($urls)) {
             // Select a random url
             $url = $urls[array_rand($urls)];
             $clientID = $this->config->get("clientID", "imgur");
             $headers = array();
             $headers[] = "Content-type: application/json";
             $headers[] = "Authorization: Client-ID {$clientID}";
             $data = $this->curl->getData($url, $headers);
             if ($data) {
                 $json = json_decode($data, true)["data"];
                 $count = count($json);
                 $img = $json[array_rand($json)];
                 // Get gifv over gif, if it's infact a gif gallery
                 //$imageURL = isset($img["gifv"]) ? $img["gifv"] : $img["link"];
                 $imageURL = $img["link"];
                 // gifv doesn't embed properly in discord, yet..
                 $message = "**Title:** {$img["title"]} | **Section:** {$img["section"]} | **url:** {$imageURL}";
                 $msgData->user->reply($message);
             }
         }
     }
 }
Example #19
-3
 /**
  * When a message arrives that contains a trigger, this is started
  *
  * @param $msgData
  */
 public function onMessage(stdClass $msgData)
 {
     $message = $msgData->message->message;
     $data = $this->trigger->trigger($message, $this->information()["trigger"]);
     if (isset($data["trigger"])) {
         if (preg_match('/https:\\/\\/discord.gg\\/(.+)/', $message, $matches)) {
             $invite = $this->discord->acceptInvite($message);
             $msgData->user->reply("Joined server {$invite->guild->name}");
         }
     }
 }