/**
 * 这个类用于生成初始化的配置文件
 */
package config;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import com.google.gson.*;
import config.ConfigData;

/**
 * @author XiLing
 *
 */
public class CreateConfigs
{

	public static void createConfigs(File configFile)
	{
		
		ConfigData configData = new ConfigData();
		configData.coolqDir = "./coolq";
		configData.qqBotPort = 11235;
		configData.qqBotNumber = "10000";
		configData.telegramBotToken = "";
		GroupsPairs sample = new GroupsPairs();
		sample.qqGroup = 10000;
		sample.telegramGroup = -1;
		configData.groupsPairs = new ArrayList<GroupsPairs>();
		configData.groupsPairs.add(sample);
		configData.proxyConfig = new ProxyConfig();
		configData.proxyConfig.enableProxy = false;
		configData.proxyConfig.proxyType = "SOCKS";
		configData.proxyConfig.proxyHost = "127.0.0.1";
		configData.proxyConfig.proxyPort = 1080;
		configData.enabledPlugins = new ArrayList<String>();
		configData.enabledPlugins.add("plugins.Transport");
		
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
		String JSONString = gson.toJson(configData);
		
		try
		{
			FileWriter out = new FileWriter(configFile.toString());
			out.write(JSONString);
			out.close();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
}