@@ -13,14 +13,14 @@ |
||
| 13 | 13 | try { |
| 14 | 14 | |
| 15 | 15 | // Create a Subscription using webhooks method |
| 16 | - $rcsdk = new SDK($_ENV['GLIP_APPKEY'], $_ENV['GLIP_APPSECRET'] , $_ENV['GLIP_SERVER'], 'Demo', '1.0.0'); |
|
| 16 | + $rcsdk = new SDK($_ENV['GLIP_APPKEY'], $_ENV['GLIP_APPSECRET'], $_ENV['GLIP_SERVER'], 'Demo', '1.0.0'); |
|
| 17 | 17 | |
| 18 | 18 | $platform = $rcsdk->platform(); |
| 19 | 19 | |
| 20 | 20 | $auth = $platform->login($_ENV['GLIP_USERNAME'], $_ENV['GLIP_EXTENSION'], $_ENV['GLIP_PASSWORD']); |
| 21 | 21 | |
| 22 | 22 | // Setup the Webhook Subscription |
| 23 | - $apiResponse = $platform->post('/subscription',array( |
|
| 23 | + $apiResponse = $platform->post('/subscription', array( |
|
| 24 | 24 | "eventFilters"=>array( |
| 25 | 25 | "/restapi/v1.0/glip/groups", |
| 26 | 26 | "/restapi/v1.0/glip/posts" |
@@ -36,30 +36,30 @@ |
||
| 36 | 36 | if ($request->headers->has('Validation-Token')) |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - return Response::create('',200,array('Validation-Token' => getallheaders()['Validation-Token']))->send(); |
|
| 39 | + return Response::create('', 200, array('Validation-Token' => getallheaders()['Validation-Token']))->send(); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Load the Driver into Botman |
| 44 | 44 | DriverManager::loadDriver(GlipBotman::class); |
| 45 | 45 | |
| 46 | -print "The vaialble drivers are : ". print_r(DriverManager::getAvailableDrivers()); |
|
| 46 | +print "The vaialble drivers are : " . print_r(DriverManager::getAvailableDrivers()); |
|
| 47 | 47 | |
| 48 | 48 | // Create a Botman Instance |
| 49 | 49 | $botman = BotManFactory::create($config); |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | // Give the bot something to listen for. |
| 53 | -$botman->hears('hello', function (BotMan $bot) { |
|
| 53 | +$botman->hears('hello', function(BotMan $bot) { |
|
| 54 | 54 | $bot->reply('Hello yourself.'); |
| 55 | 55 | })->driver(GlipBotman::class); |
| 56 | 56 | |
| 57 | -$botman->hears('what is your name', function (BotMan $bot) { |
|
| 57 | +$botman->hears('what is your name', function(BotMan $bot) { |
|
| 58 | 58 | $bot->reply('My name is Minion Bot.'); |
| 59 | 59 | })->driver(GlipBotman::class); |
| 60 | 60 | |
| 61 | 61 | |
| 62 | -$botman->hears('What can you do', function (BotMan $bot) { |
|
| 62 | +$botman->hears('What can you do', function(BotMan $bot) { |
|
| 63 | 63 | $bot->reply('I am still under construction'); |
| 64 | 64 | })->driver(GlipBotman::class); |
| 65 | 65 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'user_id' => $matchingMessage->getUser(), |
| 66 | 66 | ]; |
| 67 | 67 | |
| 68 | - $response = $this->$this->getPlatform()->get('/glip/persons' + $matchingMessage->getUser()); |
|
| 68 | + $response = $this->$this->getPlatform()->get('/glip/persons' +$matchingMessage->getUser()); |
|
| 69 | 69 | $responseData = json_decode($response->getContent(), true); |
| 70 | 70 | $userData = Collection::make($responseData['result']['user']); |
| 71 | 71 | |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function matchesRequest() |
| 81 | 81 | { |
| 82 | - return (! is_null($this->payload->get('body'))) && ! is_null($this->payload->get('event')); |
|
| 82 | + return (!is_null($this->payload->get('body'))) && !is_null($this->payload->get('event')); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | private function convertQuestion(Question $question) |
| 140 | 140 | { |
| 141 | - $replies = Collection::make($question->getButtons())->map(function ($button) { |
|
| 141 | + $replies = Collection::make($question->getButtons())->map(function($button) { |
|
| 142 | 142 | return [ |
| 143 | 143 | [ |
| 144 | 144 | 'text' => (string) $button['text'], |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | try { |
| 181 | 181 | |
| 182 | - if($platform->loggedIn()) { |
|
| 182 | + if ($platform->loggedIn()) { |
|
| 183 | 183 | return $platform; |
| 184 | 184 | } |
| 185 | 185 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | 'inline_keyboard' => $this->convertQuestion($message), |
| 241 | 241 | ], true); |
| 242 | 242 | } elseif ($message instanceof IncomingMessage) { |
| 243 | - if (! is_null($message->getImage())) { |
|
| 243 | + if (!is_null($message->getImage())) { |
|
| 244 | 244 | if (strtolower(pathinfo($message->getImage(), PATHINFO_EXTENSION)) === 'gif') { |
| 245 | 245 | $endpoint = 'sendDocument'; |
| 246 | 246 | $parameters['document'] = $message->getImage(); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $parameters['photo'] = $message->getImage(); |
| 250 | 250 | } |
| 251 | 251 | $parameters['caption'] = $message->getMessage(); |
| 252 | - } elseif (! is_null($message->getVideo())) { |
|
| 252 | + } elseif (!is_null($message->getVideo())) { |
|
| 253 | 253 | $endpoint = 'sendVideo'; |
| 254 | 254 | $parameters['video'] = $message->getVideo(); |
| 255 | 255 | $parameters['caption'] = $message->getMessage(); |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | 'inline_keyboard' => $this->convertQuestion($message), |
| 288 | 288 | ], true); |
| 289 | 289 | } elseif ($message instanceof IncomingMessage) { |
| 290 | - if (! is_null($message->getAttachment())) { |
|
| 290 | + if (!is_null($message->getAttachment())) { |
|
| 291 | 291 | $attachment = $message->getAttachment(); |
| 292 | 292 | $parameters['caption'] = $message->getText(); |
| 293 | 293 | if ($attachment instanceof Image) { |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public function isConfigured() |
| 339 | 339 | { |
| 340 | - return ! is_null($this->getPlatform()->loggedIn()); |
|
| 340 | + return !is_null($this->getPlatform()->loggedIn()); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -181,17 +181,13 @@ |
||
| 181 | 181 | |
| 182 | 182 | if($platform->loggedIn()) { |
| 183 | 183 | return $platform; |
| 184 | - } |
|
| 185 | - |
|
| 186 | - else { |
|
| 184 | + } else { |
|
| 187 | 185 | print 'The Username is : ' . $this->config->get('GLIP_USERNAME'); |
| 188 | 186 | $refresh = $platform->login($this->config->get('GLIP_USERNAME'), $this->config->get('GLIP_EXTENSION'), $this->config->get('GLIP_PASSWORD')); |
| 189 | 187 | file_put_contents($file, json_encode($refresh->jsonArray(), JSON_PRETTY_PRINT)); |
| 190 | 188 | return $platform; |
| 191 | 189 | } |
| 192 | - } |
|
| 193 | - |
|
| 194 | - catch (Exception $e) { |
|
| 190 | + } catch (Exception $e) { |
|
| 195 | 191 | $platform->login($this->config->get('GLIP_USERNAME'), $this->config->get('GLIP_EXTENSION'), $this->config->get('GLIP_PASSWORD')); |
| 196 | 192 | file_put_contents($file, json_encode($platform->auth()->data(), JSON_PRETTY_PRINT)); |
| 197 | 193 | return $platform; |