package com.saki.plugin.dictionary;

import java.util.ArrayList;
import java.util.HashMap;

import com.saki.service.NewService;

import com.saki.http.Http;
import com.setqq.script.Msg;

public class TempPseudoCode extends PseudoCodeV8 {

    private Http http;

    public TempPseudoCode(NewService c, Msg m, String master,String msg, long[] at) {
        super(c, m, master, msg, at);
    }

    @Override
    protected void changeCard(long id, long qq, String card) {
        context.setMemberCard(id, qq, card);
    }

    @Override
    protected void kick(long parseLong, long parseLong2) {
        context.deleteGroupMember(parseLong, parseLong2);
    }

    @Override
    protected String netWork(String method, String url) {
        if (http == null)
            http = new Http();
        try {
            if (method.equals("GET")) {
                return new String(http.call("GET",url,null));
            } else {
                String data = url.substring(url.indexOf("?") + 1);
                url = url.substring(0, url.indexOf("?"));
                return new String(http.call("POST",url, data.getBytes()));
            }
        } catch (Exception e) {
        }
        return "";
    }

    @Override
    protected void sendBuddyMessage(String type, long id, String content) {
        HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> index = new ArrayList<String>();
        index.add(type);
        map.put(type, list);
        map.put("index", index);
        list.add(content);
        context.sendMsg(id, -1, -1, map);
    }

    @Override
    protected void sendGroupMessage(String type, long id, String content) {
        HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> index = new ArrayList<String>();
        index.add(type);
        map.put(type, list);
        map.put("index", index);
        list.add(content);
        context.sendMsg(-1,id, -1, map);
    }

    @Override
    protected void sendSessMessage(String type, long group, long sendid,
                                   String content) {
        HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
        ArrayList<String> list = new ArrayList<String>();
        ArrayList<String> index = new ArrayList<String>();
        index.add(type);
        map.put(type, list);
        map.put("index", index);
        list.add(content);
        context.sendMsg(-1, group, sendid, map);
    }

    @Override
    protected void shutup(long parseLong, long parseLong2, int parseLong3) {
        context.setShutup(parseLong, parseLong2, parseLong3);
    }
}
