本文整理汇总了Java中org.pircbotx.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于org.pircbotx包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.pircbotx.Configuration; //导入依赖的package包/类
public static void main(final String[] args) throws IOException, IrcException {
if(args.length != 1) {
System.out.println("Usage: java -jar internet-on-a-stick.jar <configfile>");
System.exit(0);
}
final ObjectMapper mapper = new ObjectMapper()
.registerModule(new AutoMatterModule());
final IrcConfig config = mapper.readValue(new File(args[0]), IrcConfig.class);
final Configuration configuration = new Configuration.Builder()
.setName(config.name())
.setRealName(config.realname())
.addServer(config.server(), config.port())
.setSocketFactory(new UtilSSLSocketFactory().trustAllCertificates())
.addAutoJoinChannels(config.autoJoinChannels())
.addListener(new IrcBot(config))
.buildConfiguration();
//Create our bot with the configuration
final PircBotX bot = new PircBotX(configuration);
//Connect to the server
bot.startBot();
}
示例2: run
import org.pircbotx.Configuration; //导入依赖的package包/类
/**
* Entry point to TitanBot.
*/
public void run() throws Exception {
TitanBot.setDatabaseConnection(DriverManager.getConnection("jdbc:sqlite:database.db"));
StringHelper.loadWordList(Properties.getValue("games.wordlist"));
EventHandler.register(new CommandHandler());
this.registerModules();
this.createTables();
Configuration configuration = TitanBot.generateConfiguration();
// Now start the bot
try (PircBotX bot = new PircBotX(configuration)) {
bot.startBot();
}
}
示例3: bots
import org.pircbotx.Configuration; //导入依赖的package包/类
public static void bots() {
Configuration server = new Configuration.Builder()
.setEncoding(Charset.forName("UTF8"))
.setName(Defaults.getBotName())
.setAutoNickChange(true)
.setServerHostname(Defaults.getServer())
.setServerPassword(Defaults.getOAuth())
.setServerPort(Defaults.getPort())
.addAutoJoinChannel("#" + Defaults.getStreamer())
.setMessageDelay(1875)
.addListener(new Hooks())
.addListener(new Commands())
.addListener(new ChannelCommands())
.buildConfiguration();
try {
mbm.addBot(new PircBotX(server));
mbm.addBot(new PircBotX(Whisper.whisper));
mbm.start();
} catch (Exception e) {
log.error(e.getMessage());
}
}
示例4: IRCConnectionManager
import org.pircbotx.Configuration; //导入依赖的package包/类
protected IRCConnectionManager() {
m_config = new Configuration.Builder()
.setName(ConfigManager.getInstance().getIrcNick())
.setLogin(ConfigManager.getInstance().getIrcNick())
.setNickservPassword(ConfigManager.getInstance().getIrcPassword())
.setAutoNickChange(true)
.setServer(ConfigManager.getInstance().getIrcServer(), ConfigManager.getInstance().getIrcPort())
.setSocketFactory(SSLSocketFactory.getDefault())
.addListener(new HelpListener())
.addListener(new TimeListener())
.addListener(new ShameListener())
.addListener(new TellListener())
.addListener(new BouncerListener())
.addListener(new VersionListener())
.addListener(new TwitterListener())
.addListener(new ActivityListener())
.addListener(new AdminCmdListener())
.addListener(new HelloWorldListener())
.addListener(new GoogleSearchListener())
.addListener(new WebsiteHeaderListener())
.addListener(new TwitterHandleListener())
.addAutoJoinChannel(ConfigManager.getInstance().getIrcChannel())
.buildConfiguration();
}
示例5: IRCBot
import org.pircbotx.Configuration; //导入依赖的package包/类
public IRCBot() throws ExecutionException, InterruptedException, TimeoutException {
super(new Configuration.Builder()
.setName(Configs.getAccount().getExactly(Account::getName))
.setAutoNickChange(false) //Twitch doesn't support multiple users
.setOnJoinWhoEnabled(false) //Twitch doesn't support WHO command
.setCapEnabled(true)
.addCapHandler(new EnableCapHandler("twitch.tv/membership"))
.addCapHandler((new EnableCapHandler("twitch.tv/tags")))
.addListener(new IrcListener())
.addServer("irc.twitch.tv", 6667)
.setServerPassword(Configs.getAccount().getExactly(Account::getPasskey))
.setEncoding(Charset.forName("UTF-8"))
.buildConfiguration());
App.logger.info("Bot configuration built");
newOutputRaw = new OutputRawImproved(this);
}
示例6: 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();
}
示例7: 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();
}
示例8: start
import org.pircbotx.Configuration; //导入依赖的package包/类
/**
* This function actually starts the bot.
*/
void start() {
/* Log initiation and current logging level */
log.info("Starting IRCButt version " + programVersion);
LoggingHandler.logCurrentLogLevel();
/* Add event listeners */
listenerManager.addListener(new ChatListener(this));
listenerManager.addListener(new PrivateMessageListener(this));
/* Set the bot's configuration variables */
Configuration configuration = new BotConfigurationHandler(this).getConfiguration();
/* Create the bot with our configuration */
this.pircBotX = new PircBotX(configuration);
/* Start the bot */
try {
pircBotX.startBot();
} catch (Exception ex) { // several exceptions can be thrown here
log.error("Unable to start bot. StackTrace: ", ex);
}
}
示例9: 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());
}
示例10: 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()));
}
示例11: init
import org.pircbotx.Configuration; //导入依赖的package包/类
public void init() throws Exception
{
LOG.info("Connecting for first time...");
server = CONFIG.get("irc.server");
channel = CONFIG.get("irc.channel");
nickname = CONFIG.get("irc.nickname");
username = CONFIG.get("irc.username");
realname = CONFIG.get("irc.realname");
Configuration config = new Configuration.Builder()
.setName(nickname)
.setLogin(username)
.setRealName(realname)
.setEncoding(StandardCharsets.UTF_8)
.setAutoNickChange(true)
.setAutoReconnect(true)
.setAutoReconnectAttempts(Integer.MAX_VALUE)
.setAutoReconnectDelay(5000)
.addServer(server)
.addListener(this)
.buildConfiguration();
bot = new PircBotX(config);
thread = new Thread(() -> {
try { bot.startBot(); }
catch (Exception e) { JDiscordIRC.exit("IRC bot crashed"); }
}, "PircBotX");
thread.start();
}
示例12: start
import org.pircbotx.Configuration; //导入依赖的package包/类
public void start(ITetradCallback callback) {
logger.debug("start");
logger.info(MessageFormat.format("Connecting to service {0} with username {1} and resource {2}",
this.serverName,
this.userName,
this.getChannel()
));
this.callback = callback;
try {
//IdentServer.startServer();
Configuration configuration =
new Configuration.Builder()
.setName("tetrad")
.setLogin("tetrad")
.setAutoNickChange(true)
.addServer(this.serverName)
.addAutoJoinChannel(this.getChannel())
//.setIdentServerEnabled(true)
.addListener(this)
.buildConfiguration();
this.bot = new PircBotX(configuration);
this.bot.startBot();
} catch (IOException | IrcException e) {
logger.error(MessageFormat.format("Error connecting to {0}{1}. Message: {2}",
this.serverName,
this.getChannel(),
e.getMessage()
));
}
}
示例13: 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();
}
示例14: IRC
import org.pircbotx.Configuration; //导入依赖的package包/类
public IRC(String nick, String server, String... channels) {
this(new Configuration.Builder()
.setName(nick)
.setRealName(nick)
.setLogin("root")
.setVersion("unknown")
.addServer(server)
.addAutoJoinChannels(Iterables.mList(channels))
.setAutoReconnect(true)
.setAutoNickChange(true)
);
}
示例15: Bot
import org.pircbotx.Configuration; //导入依赖的package包/类
public Bot(Configuration configuration, BotManager manager) {
super(configuration);
this.manager = manager;
setupServices();
whoisManager = new WhoisManager(this);
getConfiguration().getListenerManager().addListener(whoisManager);
}