当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.Builder方法代码示例

本文整理汇总了Java中org.pircbotx.Configuration.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.Builder方法的具体用法?Java Configuration.Builder怎么用?Java Configuration.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pircbotx.Configuration的用法示例。


在下文中一共展示了Configuration.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBotConfig

import org.pircbotx.Configuration; //导入方法依赖的package包/类
private static Configuration<AgarBot> getBotConfig(Config config) {
    Configuration.Builder<AgarBot> builder =
            new Configuration.Builder<AgarBot>().setAutoReconnect(true)
                    .setMaxLineLength(400).setMessageDelay(0L)
                    .setVersion("A`Gario by likcoras")
                    .setListenerManager(new AgarManager())
                    .setName(config.getNick()).setLogin(config.getUser())
                    .setRealName(config.getGecos())
                    .setServer(config.getHost(), config.getPort());
    if (!config.getPassword().isEmpty()) {
        builder.setNickservPassword(config.getPassword());
    }
    if (config.isSsl()) {
        builder.setSocketFactory(
                new UtilSSLSocketFactory().trustAllCertificates());
    }
    config.getChannels().forEach(builder::addAutoJoinChannel);
    Hooks.LIST.forEach(builder::addListener);
    return builder.buildConfiguration();
}
 
开发者ID:likcoras,项目名称:A-Gario,代码行数:21,代码来源:AgarBot.java

示例2: getConfiguration

import org.pircbotx.Configuration; //导入方法依赖的package包/类
/**
 * Loads all values from the configuration file and returns them as a PircBotX Configuration object.
 * @return the PircBotX Configuration object.
 */
public Configuration getConfiguration() {
    Configuration.Builder configBuilder = new Configuration.Builder();
    configBuilder.setName(butt.getYamlConfigurationFile().getBotName())
            .setLogin(butt.getYamlConfigurationFile().getBotLogin())
            .setRealName(butt.getYamlConfigurationFile().getBotRealName())
            .setAutoReconnect(butt.getYamlConfigurationFile().getServerAutoReconnect())
            .setMessageDelay(butt.getYamlConfigurationFile().getBotMessageDelay())
            .setNickservPassword(butt.getYamlConfigurationFile().getBotPassword())
            .setListenerManager(butt.getListenerManager())
            .addServer(butt.getYamlConfigurationFile().getServerHostname(),
                    butt.getYamlConfigurationFile().getServerPort())
            .setVersion(butt.getProgramVersion());
    if (butt.getYamlConfigurationFile().getSSLEnabled()) {
        // TODO this doesn't work at all
        configBuilder.setSocketFactory(SSLSocketFactory.getDefault());
    }
    for (String x : butt.getYamlConfigurationFile().getChannelList()) {
        configBuilder.addAutoJoinChannel(x);
    }  // TODO this doesn't authenticate before joining channels.  Anything we can do?
    return configBuilder.buildConfiguration();
}
 
开发者ID:proxa,项目名称:IRCbutt,代码行数:26,代码来源:BotConfigurationHandler.java

示例3: loadBot

import org.pircbotx.Configuration; //导入方法依赖的package包/类
private void loadBot() {
    Configuration.Builder<PircBotX> config = this.settings.getBuilder();

    String chatServerIP = null;
    try {
        chatServerIP = TwitchAPI.getChatServerIP(this.settings.getTwitchChannel());
        config.setServerHostname(chatServerIP);
    } catch (IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    // Register the different listeners
    config.addListener(this.startupListener);
    config.addListener(this.userListener);
    config.addListener(this.commandListener);
    config.addListener(this.spamListener);
    config.addListener(this.linkListener);
    config.addListener(this.trollChatListener);

    addShutdownHook();

    this.pirc = new PircBotX(config.buildConfiguration());
}
 
开发者ID:RyanTheAllmighty,项目名称:AllmightyBot---Java,代码行数:25,代码来源:AllmightyBot.java

示例4: setBotInfo

import org.pircbotx.Configuration; //导入方法依赖的package包/类
private void setBotInfo()
{
    configBuilder = new Configuration.Builder();
    configBuilder.setEncoding(Charsets.UTF_8);
    logger.info("Setting bot info");
    configBuilder.setAutoNickChange(config.getAutoNickChange());
    logger.info(String.format("Set auto nick change to %s", config.getAutoNickChange()));
    configBuilder.setAutoReconnect(config.getAutoReconnect());
    logger.info(String.format("Set auto-reconnect to %s", config.getAutoReconnect()));
    configBuilder.setMessageDelay(config.getMessageDelay());
    logger.info(String.format("Set message delay to %s", config.getMessageDelay()));
    configBuilder.setCapEnabled(true);
    configBuilder.setRealName(config.getBotRealName());
    configBuilder.setVersion(String.format("FoxBot - A Java IRC bot written by FoxDev and owned by %s - http://foxbot.foxdev.co - Use %shelp for more info", config.getBotOwner(),
                                           config.getCommandPrefix()));
    logger.info(String.format("Set version to 'FoxBot - A Java IRC bot written by FoxDev and owned by %s - https://github.com/FoxDev/FoxBot - Use %shelp for more info'", config.getBotOwner(),
                              config.getCommandPrefix()));
    configBuilder.setAutoSplitMessage(true);
    configBuilder.setName(config.getBotNick());
    logger.info(String.format("Set nick to '%s'", config.getBotNick()));
    configBuilder.setLogin(config.getBotIdent());
    logger.info(String.format("Set ident to '%s'", config.getBotIdent()));
}
 
开发者ID:FoxDev,项目名称:FoxBot,代码行数:24,代码来源:FoxBot.java

示例5: generateConfiguration

import org.pircbotx.Configuration; //导入方法依赖的package包/类
/**
 * Generates bot {@link Configuration}.
 * @return This bots configuration based on its {@link Properties}.
 */
private static Configuration generateConfiguration() {
    // Building configuration
    Configuration.Builder configBuilder = new Configuration.Builder()
            .setName(Properties.getValue("bot.nick"))
            .setLogin(Properties.getValue("bot.username"))
            .setVersion(TitanBot.VERSION)
            .setRealName(Properties.getValue("bot.real_name"))
            .setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates())
            .setAutoNickChange(true)
            .setAutoReconnect(true)
            .setAutoSplitMessage(false)
            .addListener(new IRCListener())
            .addCapHandler(new TLSCapHandler((SSLSocketFactory) SSLSocketFactory.getDefault(), true))
            .addServer(Properties.getValue("irc.server"), Properties.getValueAsInt("irc.port"));

    // Conditional parameters
    String pass = Properties.getValue("bot.password");

    if (!pass.equalsIgnoreCase("NONE")) {
        configBuilder.setNickservPassword(pass);
    }

    String autojoinChannel = Properties.getValue("irc.autojoin_channel");

    if (!autojoinChannel.equalsIgnoreCase("NONE")) {
        configBuilder.addAutoJoinChannel(autojoinChannel);
    }

    // Now build and return the configuration
    return configBuilder.buildConfiguration();
}
 
开发者ID:MITBorg,项目名称:TitanBot,代码行数:36,代码来源:TitanBot.java

示例6: buildNewBot

import org.pircbotx.Configuration; //导入方法依赖的package包/类
protected Bot buildNewBot(CountDownLatch latch) {
	Configuration.Builder cfgb = new Configuration.Builder()
		.setBotFactory(new BotFactory(){
			@Override
			public InputParser createInputParser(PircBotX bot) {
				return new SkylarkInputParser(bot);
			}
		})
		.setEncoding(CHARSET)
		.setName(botName)
		.setAutoNickChange(true)
		.setMessageDelay(messageDelay)
		.setCapEnabled(true)
		.addCapHandler(new EnableCapHandler("extended-join", true))
		.addCapHandler(new EnableCapHandler("account-notify", true))
		.setAutoReconnect(true)
		.addListener(new ListenerAdapter(){
			@Override
			public void onConnect(ConnectEvent event) throws Exception {
				latch.countDown();
			}
		});
	
	if (port == null)
		cfgb.addServer(host);
	else
		cfgb.addServer(host, port);
	
	PluginManager pluginManager = serverManager.app.pluginManager;
	pluginManager.plugins.iterate(plugin -> {
		if (plugin instanceof ListenerPlugin)
			cfgb.addListener(((ListenerPlugin)plugin).listener);
	});
	
	return new Bot(cfgb.buildConfiguration(), this);
}
 
开发者ID:Shockah,项目名称:Skylark,代码行数:37,代码来源:BotManager.java

示例7: getBuilder

import org.pircbotx.Configuration; //导入方法依赖的package包/类
public Configuration.Builder<PircBotX> getBuilder() {
    Configuration.Builder<PircBotX> builder = new Configuration.Builder<>();

    builder.setName(this.twitchUsername);
    builder.setLogin(this.twitchUsername);
    builder.setServerPassword(this.twitchToken);
    builder.setAutoNickChange(true);
    builder.setServerHostname("irc.twitch.tv");
    builder.setServerPort(6667);
    builder.addAutoJoinChannel("#" + this.twitchChannel);

    return builder;
}
 
开发者ID:RyanTheAllmighty,项目名称:AllmightyBot---Java,代码行数:14,代码来源:Settings.java

示例8: BotWrapperThread

import org.pircbotx.Configuration; //导入方法依赖的package包/类
public BotWrapperThread(Configuration.Builder configuration, String nick, String serverHostName, int serverPort, String threadName) {
    this.configuration = configuration;

    this.configuration.setName(nick);
    this.configuration.setServers(Arrays.asList(new Configuration.ServerEntry(serverHostName, serverPort)));

    this.threadName = threadName;
}
 
开发者ID:meew0,项目名称:Mewtwo,代码行数:9,代码来源:BotWrapperThread.java

示例9: createNetwork

import org.pircbotx.Configuration; //导入方法依赖的package包/类
public static PircBotX createNetwork(String serverpass, String nick, String server, int port, String bindhost, String networkname, boolean SSL) {
    if (nick.isEmpty() || server.isEmpty()) {
        DatabaseUtils.removeNetwork(networkname);
        System.out.println("Removing Server " + networkname);
        return null;
    } else if (IRCUtils.getNetworkByNetworkName(networkname) != null) {
        DatabaseUtils.removeNetwork(networkname);
        System.out.println("Removing Server " + networkname);
        return null;
    }

    Configuration.Builder Net = new Configuration.Builder();
    Net.setName(nick);
    Net.setLogin(nick);
    Net.setEncoding(Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset());
    if (bindhost != null) {
        try {
            Net.setLocalAddress(InetAddress.getByName(bindhost));
        } catch (UnknownHostException e) {
            System.out.println("Failed to resolve bindhost on " + networkname);
            System.exit(0);
        }
    }
    Net.addServer(server, port);
    Net.setRealName(nick);
    Net.getListenerManager().addListener(new ConnectListener());
    Net.setAutoReconnect(true);
    if (serverpass != null) {
        Net.setServerPassword(serverpass);
    }
    Net.setAutoReconnectAttempts(5);
    Net.setAutoReconnectDelay(20000);
    Net.setChannelPrefixes("#");
    Net.setUserLevelPrefixes("+%@&~!");
    Net.setVersion(Registry.VERSION);
    if(SSL)
    Net.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates());
    Net.setAutoReconnect(true);
    return new PircBotX(Net.buildConfiguration());
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:41,代码来源:ConfigUtils.java

示例10: NetworkSession

import org.pircbotx.Configuration; //导入方法依赖的package包/类
public NetworkSession(String nick, ArrayList<String> chanNames, IrcManager mgr) {
	Configuration.Builder<PircBotX> builder = new Configuration.Builder<>().
		setName(nick).
		setAutoNickChange(true).
		setMessageDelay(50).
		setServer("irc.swiftirc.net", 6667).
		setAutoReconnect(true).
		addListener(this);
	for (String s : chanNames) {
		builder.addAutoJoinChannel(s);
	}
	manager = mgr;
	bot = new PircBotX(builder.buildConfiguration());
	
}
 
开发者ID:bmoyer,项目名称:osrsclient,代码行数:16,代码来源:NetworkSession.java

示例11: RoyalIRCBot

import org.pircbotx.Configuration; //导入方法依赖的package包/类
public RoyalIRCBot(final RoyalIRC plugin, ConfigurationSection cs, ListenerManager<PircBotX> lm) {
    final String hostname = cs.getString("hostname");
    final int port = cs.getInt("port", 6667);
    final String password = cs.getString("server_password", "");
    Configuration.Builder<PircBotX> cb = new Configuration.Builder<PircBotX>();
    cb.setServer(hostname, port)
            .setAutoNickChange(true)
            .setMessageDelay(cs.getLong("message_delay", 1000L))
            .setName(cs.getString("nick", "RoyalIRCBot"))
            .setFinger(cs.getString("finger", "RoyalDev IRC Link"))
            .setLogin(cs.getString("login", "RoyalIRC"))
            .setVersion("RoyalIRC" + RoyalIRC.version)
            .setListenerManager(lm);
    if (!password.isEmpty()) cb.setServerPassword(password);
    if (cs.getString("auth").equalsIgnoreCase("NickServ")) cb.setNickservPassword(cs.getString("auth_password"));
    for (String channel : cs.getStringList("channels")) {
        String[] parts = channel.trim().split(" ");
        if (parts.length > 1) cb.addAutoJoinChannel(parts[0], parts[1]);
        else cb.addAutoJoinChannel(parts[0]);
    }
    bot = new PircBotX(cb.buildConfiguration());
    plugin.getLogger().info("Attempting to connect to " + hostname + ":" + port + "...");
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                bot.startBot();
            } catch (Exception e) {
                plugin.getLogger().warning("Could not connect to " + hostname + ":" + port + "!");
            }
        }
    }).start();
}
 
开发者ID:RoyalDev,项目名称:RoyalIRC,代码行数:34,代码来源:RoyalIRCBot.java

示例12: IRCMediator

import org.pircbotx.Configuration; //导入方法依赖的package包/类
protected IRCMediator()
{
    Configuration.Builder confBuilder = new Configuration.Builder();

    // check if SSL is enabled, otherwise it won't use SSL connection.
    if (ConfReader.getInstance().isSSL())
    {
        confBuilder.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates());
    }

    // It tries to authenticate using SASL (it doesn't work on all networks)
    if (ConfReader.getInstance().isIdentifyEnabled())
    {
        confBuilder.addCapHandler(new SASLCapHandler(ConfReader.getInstance().getNick(),
                ConfReader.getInstance().getNickserv_passwd(), true));
    }

    confBuilder.setAutoReconnect(ConfReader.getInstance().isAutoreconnect());
    confBuilder.setAutoReconnectAttempts(ConfReader.getInstance().getReconnectattempts());
    confBuilder.setAutoReconnectDelay(ConfReader.getInstance().getDelaybetweenretries());
    confBuilder.setRealName(ConfReader.getInstance().getRealname());
    confBuilder.setName(ConfReader.getInstance().getNick());
    confBuilder.setLogin(ConfReader.getInstance().getLogin());
    confBuilder.setAutoNickChange(true);
    confBuilder.addServer(ConfReader.getInstance().getIrcserver(), ConfReader.getInstance().getPort());
    confBuilder.addAutoJoinChannel("#" + ConfReader.getInstance().getChannel());

    confBuilder.setVersion(
            ConfReader.getAppProperties().getString("application.name") +
            " v" + ConfReader.getAppProperties()
                    .getString("application.version") +
            " " + ConfReader.getAppProperties()
                    .getString("application.buildnumber")
    );
    confBuilder.addListener(new IRCListener(this) );
    confBuilder.buildConfiguration();

    this.bot = new PircBotX(confBuilder.buildConfiguration());
    this.newsReader = new NewsReader(new IRCOutputter());

    new NewsTimer(ConfReader.getInstance().getPollFrequency()).addTask(
                    new NewsTask(newsReader)
    );
}
 
开发者ID:MadCoderZ,项目名称:NewsBotIRC,代码行数:45,代码来源:IRCMediator.java

示例13: getXMLConfig

import org.pircbotx.Configuration; //导入方法依赖的package包/类
/**
 * getXMLConfig will then take the settings from the XML, and then 
 * attach listeners to the new bot objects based on the XML settings.
 * @param botSettings
 * @return Configuration<? extends PircBotX> configuration file for PircBotX to create.
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private Configuration<? extends PircBotX> getXMLConfig(Settings botSettings) {
	// Create builder
	Builder myBuilder = new Configuration.Builder();
	Settings mySettings = botSettings;
	// Add generics to builder
	myBuilder
			.setName(mySettings.getNick())
			.setLogin("RCbot")
			.setAutoNickChange(true)
			.setCapEnabled(true)
			.addCapHandler(
					new TLSCapHandler(new UtilSSLSocketFactory()
							.trustAllCertificates(), true))
			.setAutoReconnect(true)
			.setServerHostname(mySettings.getServer())
			.addAutoJoinChannel(mySettings.getChannel())
			.setNickservPassword(mySettings.getPassword());
	// Add necessary listeners
	myBuilder.addListener(new AdminListener());
	if (mySettings.getRedditPreview() == true) {
		myBuilder.addListener(new RedditPreviewListener());
	}
	if (mySettings.getNewUserGreeting() == true) {
		myBuilder.addListener(new NewUserGreetingListener());
	}
	if (mySettings.getCalendar() == true) {
		myBuilder.addListener(new CalendarListener());
	}
	if (mySettings.getDice() == true) {
		myBuilder.addListener(new DiceListener());
	}
	if (mySettings.getCatfacts() == true) {
		myBuilder.addListener(new CatFactListener());
	}
	if (mySettings.getDadjokes() == true) {
		myBuilder.addListener(new DadJokeListener());
	}
	if (mySettings.getLogger() == true) {
		myBuilder.addListener(new LogListener());
		myBuilder.addListener(new QueryListener());
		myBuilder.addListener(new AutobannerListener());
	}
	if (mySettings.getRcrover() == true){
		myBuilder.addListener(new RoverListener());
	}
	// Build configuration and return
	Configuration<PircBotX> myConfiguration = myBuilder
			.buildConfiguration();
	return myConfiguration;
}
 
开发者ID:AndrewBell,项目名称:RCbot,代码行数:58,代码来源:ConfigFactory.java

示例14: main

import org.pircbotx.Configuration; //导入方法依赖的package包/类
public static void main(String[] args) {
    System.setProperty(SimpleLogger.SHOW_DATE_TIME_KEY, "true");
    System.setProperty(SimpleLogger.DATE_TIME_FORMAT_KEY, "[HH:mm:ss]");
    System.setProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, "false");
    System.setProperty(SimpleLogger.LEVEL_IN_BRACKETS_KEY, "true");
    System.setProperty(SimpleLogger.SHOW_LOG_NAME_KEY, "false");
    System.out.println("Starting");
    try {
        startup = System.currentTimeMillis();
        final Config config = new Config();
        PermissionManager manager = new PermissionManager();
        System.out.println("Loading and registering commands");
        config.load();
        manager.load();
        Reflections reflections = new Reflections("com.zack6849.alphabot.commands");
        Set<Class<? extends Command>> subTypes = reflections.getSubTypesOf(Command.class);
        for (Class c : subTypes) {
            Command cmd = CommandRegistry.getCommand(c.getSimpleName());
            cmd.setManager(manager);
            cmd.setConfig(config);
            CommandRegistry.register(cmd);
        }
        //i have no idea what this is, but IDEA wouldn't shut the fuck up about changing it.
        Configuration.Builder<PircBotX> builder = new Configuration.Builder<PircBotX>();
        builder.setName(config.getBotNickname());
        builder.setRealName(config.getBotUsername());
        builder.setLogin(config.getBotIdent());
        builder.setFinger(config.getCtcpFinger());
        builder.setEncoding(Charset.isSupported("UTF-8") ? Charset.forName("UTF-8") : Charset.defaultCharset());
        builder.setNickservPassword(config.getBotPassword());
        builder.setVersion("Alphbot v2.0 BETA");
        builder.setAutoNickChange(config.isAutoNickChange());
        builder.setAutoReconnect(config.isAutoReconnectServer());
        builder.setServer(config.getServerHostame(), Integer.parseInt(config.getServerPort()), config.getServerPassword());
        builder.getListenerManager().addListener(new com.zack6849.alphabot.listeners.MessageEvent(config, manager));
        builder.getListenerManager().addListener(new com.zack6849.alphabot.listeners.InviteEvent(config, manager));
        for (String channel : config.getChannels()) {
            builder.addAutoJoinChannel(channel);
        }
        PircBotX bot = new PircBotX(builder.buildConfiguration());
        System.out.println("Starting bot...");
        if (config.isEnableChatSocket()) {
            new Thread(new ChatSocketListener(bot, config)).start();
        }
        bot.startBot();
        System.out.println("Shutting down");
        System.exit(0);
    } catch (Exception ex) {
        ex.printStackTrace();
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:zack6849,项目名称:AlphabotV2,代码行数:53,代码来源:Main.java

示例15: main

import org.pircbotx.Configuration; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    config = new Config();
    config.load();

    registerCommands();

    //Setup Logger
    System.setProperty(SimpleLogger.SHOW_DATE_TIME_KEY, "true");
    System.setProperty(SimpleLogger.DATE_TIME_FORMAT_KEY, "[HH:mm:ss]");
    System.setProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, "false");
    System.setProperty(SimpleLogger.LEVEL_IN_BRACKETS_KEY, "true");
    System.setProperty(SimpleLogger.SHOW_LOG_NAME_KEY, "true");
    System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug");
    Logger logger = new SimpleLoggerFactory().getLogger(Main.class.getName());
    System.out.println(logger.isDebugEnabled());

    //Setup this bot
    Configuration.Builder builder = new Configuration.Builder();
    builder.setName(config.getBotNickname());
    builder.setRealName(config.getBotRealname());
    builder.setLogin(config.getBotLogin());
    //builder.setNickservPassword(config.getBotPassword());
    builder.setAutoNickChange(true);
    builder.addListener(new BotListener());
    builder.setServer(config.getServerHostname(), config.getServerPort(), config.getServerPassword());
    builder.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates());
    for(String channel : config.getChannels()){
        builder.addAutoJoinChannel(channel);
    }
    PircBotX bot = new PircBotX(builder.buildConfiguration());

    minecraftLog = new LogTailer(bot, "/home/minecraft/1.7.2/logs/latest.log");
    //Connect to server
    try {
        logger.debug("staring bot");
        bot.startBot();
    } catch (Exception ex) {
        logger.error(null, ex);
        ex.printStackTrace();
    }
}
 
开发者ID:mimiKitsune,项目名称:MimiBot,代码行数:42,代码来源:Main.java


注:本文中的org.pircbotx.Configuration.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。