本文整理汇总了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();
}
示例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();
}
示例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());
}
示例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()));
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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();
}
示例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)
);
}
示例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;
}
示例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);
}
}
示例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();
}
}