@@ -28,7 +28,6 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | // Setup logger |
| 30 | 30 | use Discord\Discord; |
| 31 | -use Discord\Parts\Channel\Channel; |
|
| 32 | 31 | |
| 33 | 32 | // More memory allowance |
| 34 | 33 | ini_set('memory_limit', '1024M'); |
@@ -67,7 +66,6 @@ discard block |
||
| 67 | 66 | updateCCPData($logger); |
| 68 | 67 | |
| 69 | 68 | // Init Discord |
| 70 | -use Discord\Parts\Channel\Message; |
|
| 71 | 69 | use Discord\Parts\User\Game; |
| 72 | 70 | use Discord\WebSockets\Event; |
| 73 | 71 | use Discord\WebSockets\WebSocket; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | // Require the vendor stuff |
| 27 | -require_once __DIR__.'/vendor/autoload.php'; |
|
| 27 | +require_once __DIR__ . '/vendor/autoload.php'; |
|
| 28 | 28 | |
| 29 | 29 | // Setup logger |
| 30 | 30 | use Discord\Discord; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | // create a log channel |
| 46 | 46 | $logger = new Logger('Dramiel'); |
| 47 | -$logger->pushHandler(new StreamHandler(__DIR__.'/log/dramielLog.log', Logger::DEBUG)); |
|
| 47 | +$logger->pushHandler(new StreamHandler(__DIR__ . '/log/dramielLog.log', Logger::DEBUG)); |
|
| 48 | 48 | $logger->addInfo('Logger Initiated'); |
| 49 | 49 | |
| 50 | 50 | global $logger; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Load the library files (Probably a prettier way to do this that i haven't thought up yet) |
| 61 | -foreach (glob(__DIR__.'/src/lib/*.php') as $lib) { |
|
| 61 | +foreach (glob(__DIR__ . '/src/lib/*.php') as $lib) { |
|
| 62 | 62 | require_once $lib; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | // Number of plugins loaded |
| 98 | -$logger->info('Loaded: '.count($pluginsT).' background plugins'); |
|
| 98 | +$logger->info('Loaded: ' . count($pluginsT) . ' background plugins'); |
|
| 99 | 99 | |
| 100 | 100 | // Load chat plugins |
| 101 | 101 | $pluginDirs = ['src/plugins/onMessage/*.php']; |
@@ -117,47 +117,47 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Number of chat plugins loaded |
| 120 | -$logger->addInfo('Loaded: '.count($plugins).' chat plugins'); |
|
| 120 | +$logger->addInfo('Loaded: ' . count($plugins) . ' chat plugins'); |
|
| 121 | 121 | |
| 122 | 122 | $ws = new WebSocket($discord); |
| 123 | 123 | |
| 124 | 124 | $ws->on( |
| 125 | 125 | 'ready', |
| 126 | - function ($discord) use ($ws, $logger, $config, $plugins, $pluginsT) { |
|
| 126 | + function($discord) use ($ws, $logger, $config, $plugins, $pluginsT) { |
|
| 127 | 127 | // In here we can access any of the WebSocket events. |
| 128 | 128 | // |
| 129 | 129 | // There is a list of event constants that you can |
| 130 | 130 | // find here: https://teamreflex.github.io/DiscordPHP/classes/Discord.WebSockets.Event.html |
| 131 | 131 | // |
| 132 | 132 | // We will echo to the console that the WebSocket is ready. |
| 133 | - $logger->addInfo('Discord WebSocket is ready!'.PHP_EOL); |
|
| 133 | + $logger->addInfo('Discord WebSocket is ready!' . PHP_EOL); |
|
| 134 | 134 | $game = new Game(['name' => $config['bot']['game'], 'url' => null, 'type' => null], true); |
| 135 | 135 | $ws->updatePresence($game, false); |
| 136 | 136 | // $ws->setNickname($config["bot"]["name"]); //not in yet |
| 137 | 137 | |
| 138 | 138 | // Database check |
| 139 | - $ws->loop->addPeriodicTimer(86400, function () use ($logger) { |
|
| 139 | + $ws->loop->addPeriodicTimer(86400, function() use ($logger) { |
|
| 140 | 140 | updateDramielDB($logger); |
| 141 | 141 | updateCCPData($logger); |
| 142 | 142 | }); |
| 143 | 143 | |
| 144 | 144 | // Run the Tick plugins |
| 145 | - $ws->loop->addPeriodicTimer(1, function () use ($pluginsT) { |
|
| 145 | + $ws->loop->addPeriodicTimer(1, function() use ($pluginsT) { |
|
| 146 | 146 | foreach ($pluginsT as $plugin) { |
| 147 | 147 | $plugin->tick(); |
| 148 | 148 | } |
| 149 | 149 | }); |
| 150 | 150 | |
| 151 | 151 | // Mem cleanup every 30 minutes |
| 152 | - $ws->loop->addPeriodicTimer(1800, function () use ($logger) { |
|
| 153 | - $logger->addInfo('Memory in use: '.memory_get_usage() / 1024 / 1024 .'MB'); |
|
| 152 | + $ws->loop->addPeriodicTimer(1800, function() use ($logger) { |
|
| 153 | + $logger->addInfo('Memory in use: ' . memory_get_usage() / 1024 / 1024 . 'MB'); |
|
| 154 | 154 | gc_collect_cycles(); // Collect garbage |
| 155 | - $logger->addInfo('Memory in use after garbage collection: '.memory_get_usage() / 1024 / 1024 .'MB'); |
|
| 155 | + $logger->addInfo('Memory in use after garbage collection: ' . memory_get_usage() / 1024 / 1024 . 'MB'); |
|
| 156 | 156 | }); |
| 157 | 157 | |
| 158 | 158 | $ws->on( |
| 159 | 159 | Event::MESSAGE_CREATE, |
| 160 | - function ($message, $discord, $newdiscord) use ($logger, $config, $plugins) { |
|
| 160 | + function($message, $discord, $newdiscord) use ($logger, $config, $plugins) { |
|
| 161 | 161 | $msgData = [ |
| 162 | 162 | 'message' => [ |
| 163 | 163 | 'timestamp' => $message->timestamp, |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | try { |
| 187 | 187 | $plugin->onMessage($msgData, $message); |
| 188 | 188 | } catch (Exception $e) { |
| 189 | - $logger->addError('Error: '.$e->getMessage()); |
|
| 189 | + $logger->addError('Error: ' . $e->getMessage()); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -197,19 +197,19 @@ discard block |
||
| 197 | 197 | ); |
| 198 | 198 | $ws->on( |
| 199 | 199 | 'error', |
| 200 | - function ($error, $ws) use ($logger) { |
|
| 200 | + function($error, $ws) use ($logger) { |
|
| 201 | 201 | $logger->addError($error); |
| 202 | 202 | exit(1); |
| 203 | 203 | } |
| 204 | 204 | ); |
| 205 | 205 | $ws->on( |
| 206 | 206 | 'reconnecting', |
| 207 | - function () use ($logger) { |
|
| 207 | + function() use ($logger) { |
|
| 208 | 208 | $logger->addInfo('Websocket is reconnecting..'); |
| 209 | 209 | }); |
| 210 | 210 | $ws->on( |
| 211 | 211 | 'reconnected', |
| 212 | - function () use ($logger) { |
|
| 212 | + function() use ($logger) { |
|
| 213 | 213 | $logger->addInfo('Websocket was reconnected..'); |
| 214 | 214 | }); |
| 215 | 215 | // Now we will run the ReactPHP Event Loop! |
@@ -22,10 +22,7 @@ |
||
| 22 | 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | 23 | * SOFTWARE. |
| 24 | 24 | */ |
| 25 | -use Discord\Discord; |
|
| 26 | 25 | use Discord\Parts\Channel\Channel; |
| 27 | -use Discord\Parts\User\User; |
|
| 28 | -use Discord\WebSockets\Event; |
|
| 29 | 26 | |
| 30 | 27 | /** |
| 31 | 28 | * Class fileAuthCheck. |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Send the info to the channel |
| 139 | - $msg = $discordName.' roles have been removed via the auth.'; |
|
| 139 | + $msg = $discordName . ' roles have been removed via the auth.'; |
|
| 140 | 140 | $channelID = $toDiscordChannel; |
| 141 | 141 | $channel = Channel::find($channelID); |
| 142 | 142 | $channel->sendMessage($msg, false); |
| 143 | - $this->logger->addInfo($discordName." roles ({$role}) have been removed via the auth."); |
|
| 143 | + $this->logger->addInfo($discordName . " roles ({$role}) have been removed via the auth."); |
|
| 144 | 144 | |
| 145 | 145 | $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'"; |
| 146 | 146 | $conn->query($sql); |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Send the info to the channel |
| 167 | - $msg = $discordName.' roles have been removed because their name no longer matches their ingame name.'; |
|
| 167 | + $msg = $discordName . ' roles have been removed because their name no longer matches their ingame name.'; |
|
| 168 | 168 | $channelID = $toDiscordChannel; |
| 169 | 169 | $channel = Channel::find($channelID); |
| 170 | 170 | $channel->sendMessage($msg, false); |
| 171 | - $this->logger->addInfo($discordName.' roles have been removed because their name no longer matches their ingame name.'); |
|
| 171 | + $this->logger->addInfo($discordName . ' roles have been removed because their name no longer matches their ingame name.'); |
|
| 172 | 172 | |
| 173 | 173 | $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'"; |
| 174 | 174 | $conn->query($sql); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | ], |
| 57 | 57 | ]; |
| 58 | 58 | |
| 59 | -$config['enabledPlugins'] = [ // remove the slashes for the plugins you want |
|
| 59 | +$config['enabledPlugins'] = [// remove the slashes for the plugins you want |
|
| 60 | 60 | 'about', //info on the bot |
| 61 | 61 | 'auth', //sso based auth system |
| 62 | 62 | 'authCheck', // checks if users have left corp or alliance |
@@ -153,7 +153,7 @@ |
||
| 153 | 153 | $sentBy = $mail['senderName']; |
| 154 | 154 | $title = $mail['title']; |
| 155 | 155 | $sentDate = $mail['sentDate']; |
| 156 | - $url = "https://api.eveonline.com/char/MailBodies.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}&ids=".$mail['messageID']; |
|
| 156 | + $url = "https://api.eveonline.com/char/MailBodies.xml.aspx?keyID={$keyID}&vCode={$vCode}&characterID={$characterID}&ids=" . $mail['messageID']; |
|
| 157 | 157 | $content = strip_tags(str_replace('<br>', "\n", json_decode(json_encode(simplexml_load_string(downloadData($url), 'SimpleXMLElement', LIBXML_NOCDATA)))->result->rowset->row)); |
| 158 | 158 | |
| 159 | 159 | // Blank Content Check |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | $this->maxID = max($id, $this->maxID); |
| 107 | 107 | |
| 108 | - $url = 'https://twitter.com/'.$screenName[0].'/status/'.$id; |
|
| 109 | - $message = ['message' => $text[0], 'postedAt' => $createdAt[0], 'postedBy' => $postedBy[0], 'screenName' => $screenName[0], 'url' => $url.$id[0]]; |
|
| 110 | - $msg = '**@'.$screenName[0].'** ('.$message['postedBy'].') / '.htmlspecialchars_decode($message['message']); |
|
| 108 | + $url = 'https://twitter.com/' . $screenName[0] . '/status/' . $id; |
|
| 109 | + $message = ['message' => $text[0], 'postedAt' => $createdAt[0], 'postedBy' => $postedBy[0], 'screenName' => $screenName[0], 'url' => $url . $id[0]]; |
|
| 110 | + $msg = '**@' . $screenName[0] . '** (' . $message['postedBy'] . ') / ' . htmlspecialchars_decode($message['message']); |
|
| 111 | 111 | $messages[$id] = $msg; |
| 112 | 112 | |
| 113 | 113 | $continue = true; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | public function shortenUrl($url) |
| 144 | 144 | { |
| 145 | - return file_get_contents('http://is.gd/api.php?longurl='.$url); |
|
| 145 | + return file_get_contents('http://is.gd/api.php?longurl=' . $url); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | continue; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $message .= $row.' | '; |
|
| 101 | + $message .= $row . ' | '; |
|
| 102 | 102 | usleep(300000); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | foreach ($this->channelConfig as $chanName => $chanConfig) { |
| 109 | 109 | if ($chanConfig['searchString'] == false) { // If no match was found, and searchString is false, just use that |
| 110 | - $message = $chanConfig['textStringPrepend'].' '.$message.' '.$chanConfig['textStringAppend']; |
|
| 110 | + $message = $chanConfig['textStringPrepend'] . ' ' . $message . ' ' . $chanConfig['textStringAppend']; |
|
| 111 | 111 | $channelID = $chanConfig['channelID']; |
| 112 | 112 | } elseif (stristr($message, $chanConfig['searchString'])) { |
| 113 | - $message = $chanConfig['textStringPrepend'].' '.$message.' '.$chanConfig['textStringAppend']; |
|
| 113 | + $message = $chanConfig['textStringPrepend'] . ' ' . $message . ' ' . $chanConfig['textStringAppend']; |
|
| 114 | 114 | $channelID = $chanConfig['channelID']; |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $this->logger->addInfo("Next Notification Check At: {$cacheTimer} EVE Time"); |
| 434 | 434 | } catch (Exception $e) { |
| 435 | - $this->logger->addInfo('Notification Error: '.$e->getMessage()); |
|
| 435 | + $this->logger->addInfo('Notification Error: ' . $e->getMessage()); |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | break; |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - return json_decode(downloadData($downloadFrom.$typeID.'/'), true); |
|
| 483 | + return json_decode(downloadData($downloadFrom . $typeID . '/'), true); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | $msg = '``` |
| 100 | 100 | Developer: Shibdib (In-game Name: Mr Twinkie) |
| 101 | 101 | |
| 102 | -Current Version: '.$gitRevision['short'].' |
|
| 103 | -Current Branch: '.$gitBranch." |
|
| 102 | +Current Version: '.$gitRevision['short'] . ' |
|
| 103 | +Current Branch: '.$gitBranch . " |
|
| 104 | 104 | Github Repo: https://github.com/shibdib/Dramiel |
| 105 | 105 | |
| 106 | 106 | Statistics: |
| 107 | 107 | Currently on {$this->info['guilds']} different discord servers. |
| 108 | -Up-time: ".$interval->y.' Year(s), '.$interval->m.' Month(s), '.$interval->d.' Days, '.$interval->h.' Hours, '.$interval->i.' Minutes, '.$interval->s.' seconds. |
|
| 109 | -Memory Usage: ~'.round(memory_get_usage() / 1024 / 1024, 3).'MB```'; |
|
| 108 | +Up-time: " . $interval->y . ' Year(s), ' . $interval->m . ' Month(s), ' . $interval->d . ' Days, ' . $interval->h . ' Hours, ' . $interval->i . ' Minutes, ' . $interval->s . ' seconds. |
|
| 109 | +Memory Usage: ~'.round(memory_get_usage() / 1024 / 1024, 3) . 'MB```'; |
|
| 110 | 110 | $this->logger->addInfo("Sending about info to {$user}"); |
| 111 | 111 | $this->message->reply($msg); |
| 112 | 112 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | return [ |
| 121 | 121 | 'name' => 'about', |
| 122 | - 'trigger' => [$this->config['bot']['trigger'].'about'], |
|
| 122 | + 'trigger' => [$this->config['bot']['trigger'] . 'about'], |
|
| 123 | 123 | 'information' => "Shows information on the bot, who created it, what library it's using, revision, and other stats. Example: !about", |
| 124 | 124 | ]; |
| 125 | 125 | } |
@@ -103,7 +103,7 @@ |
||
| 103 | 103 | { |
| 104 | 104 | return [ |
| 105 | 105 | 'name' => 'time', |
| 106 | - 'trigger' => [$this->config['bot']['trigger'].'time'], |
|
| 106 | + 'trigger' => [$this->config['bot']['trigger'] . 'time'], |
|
| 107 | 107 | 'information' => 'This shows the time for various timezones compared to EVE Time. To use simply type <!time>', |
| 108 | 108 | ]; |
| 109 | 109 | } |