Completed
Branch master (6bae32)
by Matthew
03:24
created
src/Sovereign.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
     public function run()
155 155
     {
156 156
         // Reap the threads!
157
-        $this->websocket->loop->addPeriodicTimer(600, function () {
157
+        $this->websocket->loop->addPeriodicTimer(600, function() {
158 158
             // Only restart the audioStream pool if it's actually empty..
159 159
             if (empty($this->voice)) {
160 160
                 $this->voice->shutdown();
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         });
174 174
 
175 175
         // Handle the onReady event, and setup some timers and so forth
176
-        $this->websocket->on('ready', function (Discord $discord) {
176
+        $this->websocket->on('ready', function(Discord $discord) {
177 177
             $this->log->addInfo('Websocket connected..');
178 178
 
179 179
             // Update our presence status
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
             // Setup the timers for the timer plugins
196 196
             foreach ($this->onTimer as $command => $data) {
197
-                $this->websocket->loop->addPeriodicTimer($data['timer'], function () use ($data, $discord) {
197
+                $this->websocket->loop->addPeriodicTimer($data['timer'], function() use ($data, $discord) {
198 198
                     try {
199 199
                         $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);
200 200
                         $this->timers->submit($plugin);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             }
206 206
 
207 207
             // Issue periodically recounting and other things (Needed because of pthreads not putting the entire context into children - leading to some weirdness in some plugins)
208
-            $this->websocket->loop->addPeriodicTimer(600, function () {
208
+            $this->websocket->loop->addPeriodicTimer(600, function() {
209 209
                 $this->extras['memberCount'] = 0;
210 210
                 $this->extras['guildCount'] = 0;
211 211
                 /** @var Guild $guild */
@@ -226,26 +226,26 @@  discard block
 block discarded – undo
226 226
             // If not, stop the session and leave the channel (To save some bandwidth)
227 227
         });
228 228
 
229
-        $this->websocket->on('error', function ($error, $websocket) {
229
+        $this->websocket->on('error', function($error, $websocket) {
230 230
             $this->log->addError('An error occurred on the websocket', [$error->getMessage()]);
231 231
             die(1);
232 232
         });
233 233
 
234
-        $this->websocket->on('close', function ($opCode, $reason) {
234
+        $this->websocket->on('close', function($opCode, $reason) {
235 235
             $this->log->addWarning('Websocket got closed', ['code' => $opCode, 'reason' => $reason]);
236 236
             die(1);
237 237
         });
238 238
 
239
-        $this->websocket->on('reconnecting', function () {
239
+        $this->websocket->on('reconnecting', function() {
240 240
             $this->log->addInfo('Websocket is reconnecting..');
241 241
         });
242 242
 
243
-        $this->websocket->on('reconnected', function () {
243
+        $this->websocket->on('reconnected', function() {
244 244
             $this->log->addInfo('Websocket was reconnected..');
245 245
         });
246 246
 
247 247
         // Handle incoming message logging
248
-        $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
248
+        $this->websocket->on(Event::MESSAGE_CREATE, function(Message $message, Discord $discord) {
249 249
             $this->log->addInfo("Message from {$message->author->username}", [$message->content]);
250 250
 
251 251
             // Don't update data for ourselves..
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
         });
258 258
 
259 259
         // Handle plugin running
260
-        $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
260
+        $this->websocket->on(Event::MESSAGE_CREATE, function(Message $message, Discord $discord) {
261 261
             $guildID = $message->getChannelAttribute()->guild_id;
262 262
 
263 263
             // Get server config
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         });
317 317
 
318 318
         // Handle joining a voice channel, and playing.. stuff....
319
-        $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
319
+        $this->websocket->on(Event::MESSAGE_CREATE, function(Message $message, Discord $discord) {
320 320
             // Get the guildID
321 321
             $guildID = $message->getChannelAttribute()->guild_id;
322 322
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         });
355 355
 
356 356
         // Handle if it's a message for the bot (CleverBot invocation)
357
-        $this->websocket->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
357
+        $this->websocket->on(Event::MESSAGE_CREATE, function(Message $message, Discord $discord) {
358 358
             // If we got highlighted we should probably answer back
359 359
             if (stristr($message->content, $discord->getClient()->id)) {
360 360
                 try {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         });
367 367
 
368 368
         // Handle presence updates
369
-        $this->websocket->on(Event::PRESENCE_UPDATE, function (PresenceUpdate $presenceUpdate) {
369
+        $this->websocket->on(Event::PRESENCE_UPDATE, function(PresenceUpdate $presenceUpdate) {
370 370
             if ($presenceUpdate->user->id && $presenceUpdate->user->username) {
371 371
                 try {
372 372
                     $this->log->addInfo("Updating presence info for {$presenceUpdate->user->username}");
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
         });
380 380
 
381 381
         // Create a new cleverbot \nick\ for this new guild
382
-        $this->websocket->on(Event::GUILD_CREATE, function (Guild $guild) {
382
+        $this->websocket->on(Event::GUILD_CREATE, function(Guild $guild) {
383 383
             $cleverBotExists = $this->db->queryField("SELECT serverID FROM cleverbot WHERE serverID = :serverID", "serverID", array(":serverID" => $guild->id));
384 384
             $guildExists = $this->db->queryField("SELECT guildID FROM guilds WHERE guildID = :serverID", "guildID", array(":serverID" => $guild->id));
385 385
 
386 386
             // Only create a new server nick if the cleverbot instance doesn't exist.. (Hopefully cleverbot.io is done deleting them at random)
387
-            if(!isset($cleverBotExists)) {
387
+            if (!isset($cleverBotExists)) {
388 388
                 $this->log->addInfo("Setting up Cleverbot for {$guild->name}");
389 389
                 $serverID = $guild->id;
390 390
                 $result = $this->curl->post('https://cleverbot.io/1.0/create', ['user' => $this->globalConfig->get('user', 'cleverbot'), 'key' => $this->globalConfig->get('key', 'cleverbot')]);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
                 }
400 400
             }
401 401
 
402
-            if(!isset($guildExists)) {
402
+            if (!isset($guildExists)) {
403 403
                 $this->db->execute("INSERT IGNORE INTO guilds (guildID) VALUES (:guildID)", array(":guildID" => $guild->id));
404 404
 
405 405
                 // Send a hello message to the channel (Only if it's new!)
Please login to merge, or discard this patch.
src/Command/StartCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         error_reporting(E_ALL);
35 35
         define('DISCORDPHP_STARTTIME', microtime(true));
36 36
         define('BASEDIR', __DIR__);
37
-        define('SOVEREIGN_CONFIG_FILE',  realpath('./' . ltrim($input->getOption('configFile'), '/')));
37
+        define('SOVEREIGN_CONFIG_FILE', realpath('./' . ltrim($input->getOption('configFile'), '/')));
38 38
 
39 39
         // Init the container object
40 40
         $container = getContainer();
Please login to merge, or discard this patch.
src/Lib/Config.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
     /**
32 32
      * @param $configFile
33 33
      */
34
-    public function loadFile ($configFile) {
34
+    public function loadFile($configFile) {
35 35
 
36 36
         if (!file_exists(realpath($configFile))) {
37
-            $this->logger->addError('Config file '.realpath($configFile).' not found.');
37
+            $this->logger->addError('Config file ' . realpath($configFile) . ' not found.');
38 38
             return;
39 39
         }
40 40
 
41 41
         try {
42 42
             $this->config = array_change_key_case(include($configFile), \CASE_LOWER);
43
-            $this->logger->addDebug('Config file loaded: '.realpath($configFile));
43
+            $this->logger->addDebug('Config file loaded: ' . realpath($configFile));
44 44
         } catch (\Exception $e) {
45
-            $this->logger->addError('Failed loading config file ('.realpath($configFile).'): '.$e->getMessage());
45
+            $this->logger->addError('Failed loading config file (' . realpath($configFile) . '): ' . $e->getMessage());
46 46
         }
47 47
     }
48 48
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             return $this->config[$type][$key];
60 60
         }
61 61
 
62
-        $this->logger->addWarning('Config setting not found: ['.$type.']['.$key.']');
62
+        $this->logger->addWarning('Config setting not found: [' . $type . '][' . $key . ']');
63 63
 
64 64
         return $default;
65 65
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             return $this->config[$type];
76 76
         }
77 77
 
78
-        $this->logger->addWarning('Config group not found: ['.$type.']');
78
+        $this->logger->addWarning('Config group not found: [' . $type . ']');
79 79
 
80 80
         return array();
81 81
     }
Please login to merge, or discard this patch.
src/Plugins/onMessage/porn.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -122,10 +122,10 @@
 block discarded – undo
122 122
                 "innie" => "https://api.imgur.com/3/gallery/r/innie/time/all/",
123 123
             );
124 124
 
125
-            foreach($categories as $catName => $catURL) {
125
+            foreach ($categories as $catName => $catURL) {
126 126
                 $categoryNames[] = ucfirst($catName);
127
-                if(strtolower($type) == strtolower($catName)) {
128
-                    if(is_array($catURL))
127
+                if (strtolower($type) == strtolower($catName)) {
128
+                    if (is_array($catURL))
129 129
                         $url = $catURL[array_rand($catURL)];
130 130
                     else
131 131
                         $url = $catURL;
Please login to merge, or discard this patch.
src/Plugins/onVoice/horn.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
 {
15 15
     public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
16 16
     {
17
-        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
17
+        $webSocket->joinVoiceChannel($channel)->then(function(VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
18 18
             $guildID = $message->getChannelAttribute()->guild_id;
19 19
             // Add this audio stream to the array of audio streams
20 20
             $audioStreams[$guildID] = $vc;
21
-            $vc->setFrameSize(40)->then(function () use ($vc, &$audioStreams, $guildID) {
21
+            $vc->setFrameSize(40)->then(function() use ($vc, &$audioStreams, $guildID) {
22 22
                 $vc->setBitrate(128000);
23 23
                 $number = mt_rand(1, 6);
24 24
                 $file = __DIR__ . "/../../../sounds/horns/{$number}.mp3";
25
-                $vc->playFile($file, 2)->done(function () use ($vc, &$audioStreams, $guildID) {
25
+                $vc->playFile($file, 2)->done(function() use ($vc, &$audioStreams, $guildID) {
26 26
                     unset($audioStreams[$guildID]);
27 27
                     $vc->close();
28 28
                 });
Please login to merge, or discard this patch.
src/Plugins/onVoice/warnings.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
 {
15 15
     public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
16 16
     {
17
-        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
17
+        $webSocket->joinVoiceChannel($channel)->then(function(VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
18 18
             $guildID = $message->getChannelAttribute()->guild_id;
19 19
             // Add this audio stream to the array of audio streams
20 20
             $audioStreams[$guildID] = $vc;
21
-            $vc->setFrameSize(40)->then(function () use ($vc, &$audioStreams, $guildID) {
21
+            $vc->setFrameSize(40)->then(function() use ($vc, &$audioStreams, $guildID) {
22 22
                 $vc->setBitrate(128000);
23 23
                 $number = mt_rand(1, 6);
24 24
                 $file = __DIR__ . "/../../../sounds/eve/{$number}.mp3";
25
-                $vc->playFile($file, 2)->done(function () use ($vc, &$audioStreams, $guildID) {
25
+                $vc->playFile($file, 2)->done(function() use ($vc, &$audioStreams, $guildID) {
26 26
                     unset($audioStreams[$guildID]);
27 27
                     $vc->close();
28 28
                 });
Please login to merge, or discard this patch.
src/Plugins/onVoice/radio.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
         $url = "";
86 86
 
87 87
         // Populate the radioNames, and also get the URL if the person actually defined one
88
-        foreach($radios as $radioName => $radioURL) {
88
+        foreach ($radios as $radioName => $radioURL) {
89 89
             $radioNames[] = ucfirst($radioName);
90 90
             if (strtolower($radioName) == strtolower($radioStation)) {
91 91
                 $url = $radioURL;
92 92
             }
93 93
         }
94 94
 
95
-        if(!$url)
95
+        if (!$url)
96 96
             $message->reply("You can listen to the following radios: " . implode(", ", $radioNames));
97 97
 
98 98
         if (!empty($url)) {
99
-            $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, &$webSocket, $log, &$audioStreams, $channel, $curl, $url) {
99
+            $webSocket->joinVoiceChannel($channel)->then(function(VoiceClient $vc) use ($message, $discord, &$webSocket, $log, &$audioStreams, $channel, $curl, $url) {
100 100
                 $guildID = $message->getChannelAttribute()->guild_id;
101 101
 
102 102
                 // Add this audio stream to the array of audio streams
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 $audioStreams["eveRadio"][$guildID] = new Process(implode(" ", $params));
122 122
                 $audioStreams["eveRadio"][$guildID]->start($webSocket->loop);
123 123
 
124
-                $vc->playRawStream($audioStreams["eveRadio"][$guildID]->stdout)->done(function () use (&$audioStreams, $vc, $guildID) {
124
+                $vc->playRawStream($audioStreams["eveRadio"][$guildID]->stdout)->done(function() use (&$audioStreams, $vc, $guildID) {
125 125
                     $audioStreams["eveRadio"][$guildID]->close();
126 126
                     unset($audioStreams[$guildID]);
127 127
                     $vc->close();
Please login to merge, or discard this patch.
src/Plugins/onVoice/radio90s.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 {
19 19
     public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
20 20
     {
21
-        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel, $curl) {
21
+        $webSocket->joinVoiceChannel($channel)->then(function(VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel, $curl) {
22 22
             $guildID = $message->getChannelAttribute()->guild_id;
23 23
 
24 24
             // Add this audio stream to the array of audio streams
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
             $vc->setBitrate(128000);
29 29
             $vc->setFrameSize(40);
30 30
 
31
-            $tickQueue = function () use (&$tickQueue, &$vc, &$message, &$channel, &$curl, &$log, &$audioStreams, $guildID) {
31
+            $tickQueue = function() use (&$tickQueue, &$vc, &$message, &$channel, &$curl, &$log, &$audioStreams, $guildID) {
32 32
                 // Get the song we'll be playing this round
33 33
                 $data = $this->getSong($curl, $log);
34 34
                 $song = $data["songData"];
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
                 // Do we really want it to spam the origin channel with what song we're playing all the time?
38 38
                 //$message->getChannelAttribute()->sendMessage("Now playing **{$song->title}** by **{$song->artist}** in {$channel->name}");
39 39
                 $log->addInfo("Now playing **{$song->title}** by **{$song->artist}** in {$channel->name}");
40
-                $vc->playFile($songFile)->done(function () use (&$tickQueue, $vc, &$log, &$audioStreams, $guildID) {
40
+                $vc->playFile($songFile)->done(function() use (&$tickQueue, $vc, &$log, &$audioStreams, $guildID) {
41 41
                     if (isset($audioStreams[$guildID])) {
42 42
                         $log->addInfo("Going to next song..");
43 43
                         $vc->stop();
Please login to merge, or discard this patch.
src/Plugins/onVoice/reapers.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@
 block discarded – undo
14 14
 {
15 15
     public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
16 16
     {
17
-        $webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
17
+        $webSocket->joinVoiceChannel($channel)->then(function(VoiceClient $vc) use ($message, $discord, $webSocket, $log, &$audioStreams, $channel) {
18 18
             $guildID = $message->getChannelAttribute()->guild_id;
19 19
             // Add this audio stream to the array of audio streams
20 20
             $audioStreams[$guildID] = $vc;
21
-            $vc->setFrameSize(40)->then(function () use ($vc, &$audioStreams, $guildID) {
21
+            $vc->setFrameSize(40)->then(function() use ($vc, &$audioStreams, $guildID) {
22 22
                 $vc->setBitrate(128000);
23 23
                 $number = mt_rand(1, 23);
24 24
                 $file = __DIR__ . "/../../../sounds/reapers/{$number}.mp3";
25
-                $vc->playFile($file, 2)->done(function () use ($vc, &$audioStreams, $guildID) {
25
+                $vc->playFile($file, 2)->done(function() use ($vc, &$audioStreams, $guildID) {
26 26
                     unset($audioStreams[$guildID]);
27 27
                     $vc->close();
28 28
                 });
Please login to merge, or discard this patch.