當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。