Ejemplo n.º 1
0
 /**
  * @param $discord
  * @param SluggardApp $app
  */
 public function __construct(\Discord\Discord &$discord, SluggardApp &$app)
 {
     $this->app = $app;
     $this->config = $app->config;
     $this->discord = $discord;
     $this->log = $app->log;
     $this->sluggardDB = $app->sluggarddata;
     $this->ccpDB = $app->ccpdata;
     $this->curl = $app->curl;
     $this->storage = $app->storage;
     $this->trigger = $app->triggercommand;
     $this->toDiscordChannel = $this->config->get("channelID", "siphons");
     $this->keyCount = count($this->config->get("apiKeys", "eve"));
     $this->keys = $this->config->get("apiKeys", "eve");
     $this->nextCheck = 0;
     // Schedule all the apiKeys for the future
     $keyCounter = 0;
     foreach ($this->keys as $keyOwner => $apiData) {
         $keyID = $apiData["keyID"];
         if ($apiData["corpKey"] == false) {
             continue;
         }
         $this->run = true;
         if ($keyCounter == 0) {
             // Schedule it for right now
             $this->storage->set("siphonCheck{$keyID}{$keyOwner}", time() - 5);
         } else {
             $rescheduleTime = time() + 21602 / $this->keyCount * $keyCounter;
             // We can only check keys every 6 hours..
             $this->storage->set("siphonCheck{$keyID}{$keyOwner}", $rescheduleTime);
         }
         $keyCounter++;
     }
 }
Ejemplo n.º 2
0
 /**
  * wolframAlpha constructor.
  * @param $discord
  * @param SluggardApp $app
  */
 public function __construct(\Discord\Discord &$discord, SluggardApp &$app)
 {
     $this->app = $app;
     $this->config = $app->config;
     $this->discord = $discord;
     $this->log = $app->log;
     $this->sluggardDB = $app->sluggarddata;
     $this->ccpDB = $app->ccpdata;
     $this->curl = $app->curl;
     $this->storage = $app->storage;
     $this->trigger = $app->triggercommand;
     require_once BASEDIR . "/src/wolframAlpha/WolframAlphaEngine.php";
     $appID = $this->config->get("appID", "wolframalpha");
     $this->wolframAlpha = $appID != null ? new WolframAlphaEngine($appID) : null;
 }
Ejemplo n.º 3
0
 /**
  * fileReader constructor.
  * @param $discord
  * @param SluggardApp $app
  */
 public function __construct(&$discord, SluggardApp &$app)
 {
     $this->app = $app;
     $this->config = $app->config;
     $this->discord = $discord;
     $this->log = $app->log;
     $this->sluggardDB = $app->sluggarddata;
     $this->ccpDB = $app->ccpdata;
     $this->curl = $app->curl;
     $this->storage = $app->storage;
     $this->trigger = $app->triggercommand;
     $this->channelConfig = $this->config->getAll("filereader")["channelconfig"];
     $this->db = $this->config->getAll("filereader")["db"];
     if (!is_file($this->db)) {
         touch($this->db);
     }
 }
Ejemplo n.º 4
0
 /**
  *
  */
 public function createSluggardDB()
 {
     $tables = array("users", "usersSeen", "storage", "authentications");
     $tableCreateCode = array("users" => "\r\n            BEGIN;\r\n            CREATE TABLE IF NOT EXISTS `users` (\r\n                `id` INTEGER PRIMARY KEY AUTOINCREMENT,\r\n                `serverID` BIGINT(20) NOT NULL,\r\n                `userID` BIGINT(20) NOT NULL,\r\n                `discordID` BIGINT(20) NOT NULL,\r\n                `characterID` INT(16) NOT NULL,\r\n                `corporationID` VARCHAR(255) NOT NULL,\r\n                `allianceID` VARCHAR(255) NOT NULL,\r\n                `authString` VARCHAR(255) NOT NULL,\r\n                `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP\r\n            );\r\n            CREATE UNIQUE INDEX userID ON users (userID);\r\n            CREATE INDEX serverID ON users (serverID);\r\n            CREATE INDEX corporationID ON users (corporationID);\r\n            CREATE INDEX allianceID ON users (allianceID);\r\n            COMMIT;", "usersSeen" => "\r\n            BEGIN;\r\n            CREATE TABLE IF NOT EXISTS `usersSeen` (\r\n                `id` INTEGER PRIMARY KEY,\r\n                `name` VARCHAR(255) NOT NULL,\r\n                `isAdmin` TINYINT(1) NOT NULL DEFAULT '0',\r\n                `lastSeen` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n                `lastSpoke` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\r\n                `lastStatus` VARCHAR(50) NULL DEFAULT NULL,\r\n                `lastWritten` TEXT NULL\r\n            );\r\n            CREATE INDEX name ON usersSeen (name);\r\n            COMMIT;", "storage" => "\r\n            BEGIN;\r\n            CREATE TABLE IF NOT EXISTS `storage` (\r\n                `id` INTEGER PRIMARY KEY AUTOINCREMENT,\r\n                `key` VARCHAR(255) NOT NULL,\r\n                `value` VARCHAR(255) NOT NULL\r\n            );\r\n            CREATE UNIQUE INDEX key ON storage (key);\r\n            COMMIT;", "authentications" => "\r\n            BEGIN;\r\n            CREATE TABLE IF NOT EXISTS `authentications` (\r\n                `discordID` INTEGER PRIMARY KEY,\r\n                `characterID` BIGINT(40) NOT NULL,\r\n                `corporationID` BIGINT(40) NOT NULL,\r\n                `allianceID` BIGINT(40) NOT NULL,\r\n                `guildID` BIGINT(128) DEFAULT 0 NOT NULL\r\n            );\r\n            CREATE UNIQUE INDEX discordID ON authentications (discordID);\r\n            COMMIT;\r\n            ", "fittings" => "\r\n            BEGIN;\r\n            CREATE TABLE `fittings` (\r\n                `guildID` INTEGER PRIMARY KEY,\r\n                `fittingName` VARCHAR(255) NOT NULL,\r\n                `fittingURL` VARCHAR(255) NOT NULL\r\n            );\r\n            CREATE UNIQUE INDEX fittingName ON fittings (guildID, fittingName);\r\n            COMMIT;");
     $dbName = $this->config->get("botName", "bot");
     // Does the file exist?
     if (!file_exists(BASEDIR . "/config/database/{$dbName}.sqlite")) {
         touch(BASEDIR . "/config/database/{$dbName}.sqlite");
     }
     // Check if the tables exist, if not, create them
     foreach ($tables as $table) {
         $exists = $this->sluggardDB->queryField("SELECT name FROM sqlite_master WHERE type = 'table' AND name = :name", "name", array(":name" => $table));
         if (!$exists) {
             $this->log->warn("Creating {$table} in {$dbName}.sqlite, since it does not exist");
             $this->sluggardDB->execute(trim($tableCreateCode[$table]));
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * twitterNotifications constructor.
  * @param $discord
  * @param SluggardApp $app
  */
 public function __construct(&$discord, SluggardApp &$app)
 {
     $this->app = $app;
     $this->config = $app->config;
     $this->discord = $discord;
     $this->log = $app->log;
     $this->sluggardDB = $app->sluggarddata;
     $this->ccpDB = $app->ccpdata;
     $this->curl = $app->curl;
     $this->storage = $app->storage;
     $this->trigger = $app->triggercommand;
     $this->twitter = new Twitter($this->config->get("consumerKey", "twitter"), $this->config->get("consumerSecret", "twitter"), $this->config->get("accessToken", "twitter"), $this->config->get("accessTokenSecret", "twitter"));
     $this->maxID = 0;
     $this->channelID = $this->config->get("channelID", "twitteroutput");
 }
Ejemplo n.º 6
0
 /**
  * eveNotifications constructor.
  * @param $discord
  * @param SluggardApp $app
  */
 public function __construct(&$discord, SluggardApp &$app)
 {
     $this->app = $app;
     $this->config = $app->config;
     $this->discord = $discord;
     $this->log = $app->log;
     $this->sluggardDB = $app->sluggarddata;
     $this->ccpDB = $app->ccpdata;
     $this->curl = $app->curl;
     $this->storage = $app->storage;
     $this->trigger = $app->triggercommand;
     // Rena APIs
     $this->charApi = "http://rena.karbowiak.dk/api/character/information/";
     $this->corpApi = "http://rena.karbowiak.dk/api/corporation/information/";
     $this->alliApi = "http://rena.karbowiak.dk/api/alliance/information/";
     $this->toDiscordChannel = $this->config->get("channelID", "evemails");
     $this->newestNotificationID = $this->storage->get("newestNotificationID");
     $this->maxID = 0;
     $this->keyCount = count($this->config->get("apiKeys", "eve"));
     $this->keys = $this->config->get("apiKeys", "eve");
     $this->nextCheck = 0;
     // Schedule all the apiKeys for the future
     $keyCounter = 0;
     foreach ($this->keys as $keyOwner => $apiData) {
         $keyID = $apiData["keyID"];
         if (@$apiData["corpKey"] == true) {
             continue;
         }
         $characterID = $apiData["characterID"];
         if ($keyCounter == 0) {
             // Schedule it for right now
             $this->storage->set("corpMailCheck{$keyID}{$keyOwner}{$characterID}", time() - 5);
         } else {
             $rescheduleTime = time() + 1805 / $this->keyCount * $keyCounter;
             $this->storage->set("corpMailCheck{$keyID}{$keyOwner}{$characterID}", $rescheduleTime);
         }
         $keyCounter++;
     }
 }
Ejemplo n.º 7
0
 /**
  * @return array
  *
  * name: is the name of the script
  * trigger: is an array of triggers that can trigger this plugin
  * information: is a short description of the plugin
  * timerFrequency: if this were an onTimer script, it would execute every x seconds, as defined by timerFrequency
  */
 public function information()
 {
     return array("name" => "auth", "trigger" => array("!auth"), "information" => "Authenticates you up against the auth site located at " . $this->config->get("authSite", "auth"), "timerFrequency" => 0);
 }
Ejemplo n.º 8
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);
             }
         }
     }
 }