package com.oldterns.vilebot.handlers.admin;

import ca.szc.keratin.bot.annotation.HandlerContainer;
import ca.szc.keratin.core.event.message.recieve.ReceivePrivmsg;
import com.oldterns.vilebot.db.LogDB;
import net.engio.mbassy.listener.Handler;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by eunderhi on 18/08/15.
 */
@HandlerContainer
public class GetLog {

    private static final Pattern showLog = Pattern.compile("^!showLog$");
    private static final Pattern deleteLog = Pattern.compile("^!deleteLog$");

    @Handler
    private void getLog(ReceivePrivmsg event) {
        String text = event.getText();
        boolean showLogMatches = showLog.matcher(text).matches();
        boolean deleteLogMatches = deleteLog.matcher(text).matches();

        if (showLogMatches) {
            event.reply(LogDB.getLog());
        }
        else if(deleteLogMatches) {
            LogDB.deleteLog();
        }
    }
}

@@ -190,21 +190,104 @@
 ebot.db.
-LogDB
+GroupDB;%0Aimport com.oldterns.vilebot.db.LogDB;%0Aimport com.oldterns.vilebot.util.Sessions
 ;%0Aimport
@@ -327,40 +327,8 @@
 r;%0A%0A
-import java.util.regex.Matcher;%0A
 impo
@@ -501,18 +501,23 @@
 ompile(%22
-%5E
 !
+admin 
 showLog$
@@ -586,10 +586,15 @@
 le(%22
-%5E
 !
+admin 
 dele
@@ -700,24 +700,123 @@
 .getText();%0A
+        String sender = event.getSender();%0A        String username = Sessions.getSession(sender);%0A%0A
         bool
@@ -936,24 +936,68 @@
 matches();%0A%0A
+        if(GroupDB.isAdmin(username)) %7B%0A    
         if (
@@ -1006,32 +1006,36 @@
 owLogMatches) %7B%0A
+    
             even
@@ -1070,26 +1070,22 @@
     
- %7D%0A
      
-  
+%7D
  else if
 (del
@@ -1080,16 +1080,17 @@
  else if
+ 
 (deleteL
@@ -1114,16 +1114,20 @@
         
+    
 LogDB.de
@@ -1133,24 +1133,38 @@
 eleteLog();%0A
+            %7D%0A
         %7D%0A  

Make showLog and deleteLog admin commands