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


Java Configuration类代码示例

本文整理汇总了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();
}
 
开发者ID:Unarmed,项目名称:internet-on-a-stick,代码行数:25,代码来源:IrcBot.java

示例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();
    }
}
 
开发者ID:MITBorg,项目名称:TitanBot,代码行数:19,代码来源:TitanBot.java

示例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());
        }

    }
 
开发者ID:lorddusk,项目名称:DuskBot,代码行数:26,代码来源:Bot.java

示例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();

}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:26,代码来源:IRCConnectionManager.java

示例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);
}
 
开发者ID:OTBProject,项目名称:OTBProject,代码行数:17,代码来源:IRCBot.java

示例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();
}
 
开发者ID:likcoras,项目名称:A-Gario,代码行数:21,代码来源:AgarBot.java

示例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();
}
 
开发者ID:proxa,项目名称:IRCbutt,代码行数:26,代码来源:BotConfigurationHandler.java

示例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);
    }
}
 
开发者ID:proxa,项目名称:IRCbutt,代码行数:26,代码来源:IRCbutt.java

示例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());
}
 
开发者ID:RyanTheAllmighty,项目名称:AllmightyBot---Java,代码行数:25,代码来源:AllmightyBot.java

示例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()));
}
 
开发者ID:FoxDev,项目名称:FoxBot,代码行数:24,代码来源:FoxBot.java

示例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();
}
 
开发者ID:Gamealition,项目名称:JDiscordIRC,代码行数:32,代码来源:IRCManager.java

示例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()
                                         ));
    }
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:33,代码来源:TetradIRC.java

示例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();
}
 
开发者ID:MITBorg,项目名称:TitanBot,代码行数:36,代码来源:TitanBot.java

示例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)
    );
}
 
开发者ID:automenta,项目名称:spimedb,代码行数:13,代码来源:IRC.java

示例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);
}
 
开发者ID:Shockah,项目名称:Skylark,代码行数:9,代码来源:Bot.java


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