Example #1
0
 public function testLogsClear()
 {
     $logAmount = SlackLog::all()->count();
     $this->assertGreaterThan(0, $logAmount);
     $command = new SlackLogsClear();
     $command->handle();
     $logAmount = SlackLog::all()->count();
     // compare both array
     $this->assertEquals(0, $logAmount);
 }
Example #2
0
 public function handle()
 {
     SlackLog::truncate();
 }
Example #3
0
 public function getLogs()
 {
     $logs = SlackLog::orderBy('created_at', 'desc')->take(30)->get();
     return view('slackbot::logs', compact('logs'));
 }
Example #4
0
 protected function logEvent($eventType, $channels = null)
 {
     $message = '';
     $channelsString = '';
     if ($channels != null) {
         $channelsString = implode(',', $channels);
     }
     switch ($eventType) {
         case 'invite':
             $message = 'The user ' . $this->user->name . ' has been invited to following channels : ' . $channelsString;
             break;
         case 'kick':
             $message = 'The user ' . $this->user->name . ' has been kicked from following channels : ' . $channelsString;
             break;
         case 'mail':
             $message = 'The mail address for user ' . $this->user->name . ' has not been set (' . $this->user->email . ')';
             break;
         case 'sync':
             $message = 'The SeAT database is not synced with Slack users.';
             break;
     }
     SlackLog::create(['event' => $eventType, 'message' => $message]);
 }