/*
 * Copyright 2016 LINE Corporation
 *
 * LINE Corporation licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package com.bot;

import java.io.IOException;
import java.util.HashMap;
import java.util.Random;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.linecorp.bot.model.event.Event;
import com.linecorp.bot.model.event.MessageEvent;
import com.linecorp.bot.model.event.message.TextMessageContent;
import com.linecorp.bot.model.message.TextMessage;
import com.linecorp.bot.spring.boot.annotation.EventMapping;
import com.linecorp.bot.spring.boot.annotation.LineMessageHandler;

@SpringBootApplication
@LineMessageHandler
public class Oripyon_jr {
	
	int seed;
	Random random = new Random();
	String[] noodle = {"廢物","垃圾","蘿莉控","意淫業務的變態","處男","嫩","ㄧ"};
	
	HashMap<String, String> binaryCommand;
	
	
    public static void main(String[] args) {
        SpringApplication.run(Oripyon_jr.class, args);
    }

    @EventMapping
    public TextMessage handleTextMessageEvent(MessageEvent<TextMessageContent> event) {
        System.out.println("event: " + event);
        
//        jsonParser();
        
        String message = event.getMessage().getText();
        String returnMessage = null;
        
//        if(message.startsWith("!")){
//        	String key = message.split(" ")[0].substring(1);
//        	String target = message.substring(key.length() + 1);
//        	if(binaryCommand.get(key) != null){
//        		returnMessage = binaryCommand.get(key);
//        	}
//        }
        
        if(message.contains("陳彥霖")){
        	seed = random.nextInt(noodle.length);
        	returnMessage = noodle[seed] + "test";
        }
        
        return new TextMessage(returnMessage);
    }

    @EventMapping
    public void handleDefaultMessageEvent(Event event) {
        System.out.println("event: " + event);
    }
    
//    private void jsonParser(){
//    	try {
//    		TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String,String>>(){};
//        	ObjectMapper mapper = new ObjectMapper();
//    		
//			binaryCommand = mapper.readValue(getClass().getResourceAsStream("/command/binary.json"),typeRef);
//			
//		} catch (JsonParseException e) {
//			e.printStackTrace();
//		} catch (JsonMappingException e) {
//			e.printStackTrace();
//		} catch (IOException e) {
//			e.printStackTrace();
//		}
//    }
}

@@ -1884,34 +1884,32 @@
 vent);%0A        %0A
-//
         jsonPars
@@ -2654,26 +2654,24 @@
 %0A    %7D%0A    %0A
-//
     private 
@@ -2689,18 +2689,16 @@
 rser()%7B%0A
-//
     %09try
@@ -2700,18 +2700,16 @@
  %09try %7B%0A
-//
     %09%09Ty
@@ -2802,18 +2802,16 @@
 %3E%3E()%7B%7D;%0A
-//
         
@@ -2857,19 +2857,15 @@
 ();%0A
-//
     %09%09%0A
-//
 %09%09%09b
@@ -2965,16 +2965,12 @@
 f);%0A
-//
 %09%09%09%0A
-//
 %09%09%7D 
@@ -2992,34 +2992,32 @@
 eException e) %7B%0A
-//
 %09%09%09e.printStackT
@@ -3016,34 +3016,32 @@
 ntStackTrace();%0A
-//
 %09%09%7D catch (JsonM
@@ -3053,34 +3053,32 @@
 gException e) %7B%0A
-//
 %09%09%09e.printStackT
@@ -3085,18 +3085,16 @@
 race();%0A
-//
 %09%09%7D catc
@@ -3113,18 +3113,16 @@
 on e) %7B%0A
-//
 %09%09%09e.pri
@@ -3141,16 +3141,12 @@
 ();%0A
-//
 %09%09%7D%0A
-//
     

Update Oripyon_jr.java