Example #1
0
 public function view()
 {
     $date = $this->request->date;
     $channel = '#' . $this->request->channel;
     $year = date('Y', strtotime($date));
     if (!in_array($channel, LogMessages::channels())) {
         throw new Exception('Unknown channel.');
     }
     $baseUrl = array('library' => 'li3_bot', 'controller' => 'logs');
     $breadcrumbs[] = array('title' => 'Channel Logs', 'url' => $baseUrl + array('action' => 'channels'));
     $breadcrumbs[] = array('title' => $channel, 'url' => null);
     $breadcrumbs[] = array('title' => $year, 'url' => array('library' => 'li3_bot', 'controller' => 'logs', 'action' => 'index', 'channel' => ltrim($channel, '#')) + compact('year'));
     $breadcrumbs[] = array('title' => date('m/d', strtotime($date)), 'url' => null);
     $messages = LogMessages::day($channel, $date);
     $previous = date('Y-m-d', strtotime($date) - 60 * 60 * 24);
     $next = date('Y-m-d', strtotime($date) + 60 * 60 * 24);
     if (!LogMessages::hasDay($channel, $previous)) {
         $previous = null;
     }
     if (!LogMessages::hasDay($channel, $next)) {
         $next = null;
     }
     $rewriters = Libraries::get('li3_bot', 'rewriters');
     return compact('channel', 'messages', 'date', 'breadcrumbs', 'previous', 'next', 'rewriters');
 }
Example #2
0
 public function home()
 {
     $channels = LogMessages::channels();
     $tells = Tells::recent();
     $karmas = Karma::highscore();
     return compact('channels', 'tells', 'karmas');
 }
Example #3
0
 public function migrate_logs()
 {
     $old = Logs::find('all', ['channel' => 'li3']);
     foreach (Logs::find('all') as $channel) {
         foreach (Logs::find('all', compact('channel')) as $date) {
             $lines = Logs::read($channel, $date);
             foreach ($lines as $line) {
                 $item = LogMessages::create(['created' => $date . ' ' . $line['time'], 'user' => $line['user'], 'channel' => $channel, 'message' => $line['message']]);
                 $item->save();
             }
         }
     }
 }