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


Java IrcException类代码示例

本文整理汇总了Java中org.pircbotx.exception.IrcException的典型用法代码示例。如果您正苦于以下问题:Java IrcException类的具体用法?Java IrcException怎么用?Java IrcException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

import org.pircbotx.exception.IrcException; //导入依赖的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: PokeTwitchChatBot

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
public PokeTwitchChatBot(BotConfiguration botConfig) throws IOException, IrcException {
	super(botConfig);

	this.botConfig = botConfig;

	connectToDB();

	// TODO find a more efficient way to check if it's connected
	while (!bot.isConnected())
		;

	// requests for whispers, mod checks etc
	bot.sendRaw().rawLine(("CAP REQ :twitch.tv/membership"));
	bot.sendRaw().rawLine(("CAP REQ :twitch.tv/tags"));
	bot.sendRaw().rawLine(("CAP REQ :twitch.tv/commands"));

}
 
开发者ID:themetalfleece,项目名称:ircpokemonbot,代码行数:18,代码来源:PokeTwitchChatBot.java

示例3: main

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
public static void main(String[] args) throws IrcException, IOException {

		Toolkit.getDefaultToolkit().setDynamicLayout(true);
		System.setProperty("sun.awt.noerasebackground", "true");
		JFrame.setDefaultLookAndFeelDecorated(true);
		JDialog.setDefaultLookAndFeelDecorated(true);

		try {
			UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel");

		} catch (Exception e) {
			e.printStackTrace();
		}

		initUI();
	}
 
开发者ID:bmoyer,项目名称:osrsclient,代码行数:17,代码来源:RSClient.java

示例4: start

import org.pircbotx.exception.IrcException; //导入依赖的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

示例5: startIRCClient

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
public void startIRCClient()
{
    try {
        this.bot.startBot();
    } catch (IOException | IrcException e) {
        LogManager.getLogger(IRCMediator.class).error(e.getMessage());
    }
}
 
开发者ID:MadCoderZ,项目名称:NewsBotIRC,代码行数:9,代码来源:IRCMediator.java

示例6: startBot

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
@Override
public void startBot() throws BotInitException {
    try {
        ircBot.startBot();
    } catch (IOException | IrcException e) {
        throw new BotInitException("Failed to start bot", e);
    }
}
 
开发者ID:OTBProject,项目名称:OTBProject,代码行数:9,代码来源:TwitchBot.java

示例7: main

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
public static void main(String[] args) {
    instance = new RavenBot();
    try {
        instance.bot.startBot();
    } catch (IOException | IrcException e) {
        e.printStackTrace();
    }

}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:10,代码来源:RavenBot.java

示例8: start

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
private void start() {
    Config config;
    try {
        config = getConfig();
        new AgarBot(config).startBot();
    } catch (IOException | IrcException e) {
        log.error("Error while starting bot", e);
        return;
    }
}
 
开发者ID:likcoras,项目名称:A-Gario,代码行数:11,代码来源:AGario.java

示例9: setupListeners

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
private void setupListeners() {
	fireConnect = new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent ae) {
			ArrayList<String> joinChannels = Parse.parseIrcChannels(chanField.getText());
			mainIrcPanel.addMainPanel();
			for (String s : joinChannels) {
				mainIrcPanel.chatMainPanel.addChanPanel(s);

			}
			mainIrcPanel.chatMainPanel.switchChanPanels(joinChannels.get(joinChannels.size() - 1));

			Runnable r1 = new Runnable() {
				public void run() {

					try {
						mainIrcPanel.startChat(nickField.getText(), Parse.parseIrcChannels(chanField.getText()));

					} catch (IOException ex) {
						Logger.getLogger(ChatConfigPanel.class.getName()).log(Level.SEVERE, null, ex);
					} catch (IrcException ex) {
						Logger.getLogger(ChatConfigPanel.class.getName()).log(Level.SEVERE, null, ex);
					}
				}
			};

			new Thread(r1).start();

		}
	};
}
 
开发者ID:bmoyer,项目名称:osrsclient,代码行数:33,代码来源:ChatConfigPanel.java

示例10: start

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
@Override
public void start(IrcBotConfiguration config, PircBotXMessageListener handleChannelMessages) {
  Configuration<PircBotX> pircBotConfig = new Configuration.Builder<>()
          .setName(config.getBotName())
          .setServerHostname(config.getServerAddress())
          .addAutoJoinChannel(config.getChannelName()).addListener(handleChannelMessages)
          .setLogin(config.getIdent())
          .setNickservPassword(config.getPassword()).buildConfiguration();
  PircBotX pircbot = new PircBotX(pircBotConfig);
  try {
    pircbot.startBot();
  } catch (IOException | IrcException e) {
    e.printStackTrace();
  }
}
 
开发者ID:axelhodler,项目名称:takt1,代码行数:16,代码来源:PircBot.java

示例11: startBot

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
private static boolean startBot(PircBotX bot) {
    try {
        do {
            bot.startBot();
        } while (SafeStop);
    } catch (IOException | IrcException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
开发者ID:harry2258,项目名称:AlfredV2-FTB-IRC-,代码行数:12,代码来源:Main.java

示例12: connectToServer

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
private void connectToServer()
{
    configBuilder.setServer(config.getServerAddress(), config.getServerPort(), config.getServerPassword());

    if (config.getServerSsl())
    {
        configBuilder.setSocketFactory(config.getAcceptInvalidSsl() ? new UtilSSLSocketFactory().trustAllCertificates().disableDiffieHellman() : SSLSocketFactory.getDefault());
    }

    if (config.useNickserv())
    {
        configBuilder.setNickservPassword(config.getNickservPassword());
    }

    logger.info(String.format("Connecting to %s on port %s%s...", config.getServerAddress(), config.getServerPort(), config.getServerSsl() ? " with SSL" : " without SSL"));
    logger.info("Adding channels...");

    for (String channel : config.getChannels())
    {
        if (channel.contains(":"))
        {
            String[] parts = channel.split(":");
            configBuilder.addAutoJoinChannel(parts[0], parts[1]);
            continue;
        }

        configBuilder.addAutoJoinChannel(channel);
    }

    try
    {
        bot = new PircBotX(configBuilder.buildConfiguration());
        bot.startBot();
    }
    catch (IOException | IrcException ex)
    {
        logger.error("Error occurred while connecting", ex);
        shutdown();
    }
}
 
开发者ID:FoxDev,项目名称:FoxBot,代码行数:41,代码来源:FoxBot.java

示例13: SnepsBotX

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
SnepsBotX() {

        PropertyReader property = new PropertyReader(CONFIG_FILE); //create a SnepsUtils instance, I'll need it to get the configurations from the CONFIG_FILE

        //my configuration builder
        Configuration myConfig = new Configuration.Builder()
                .setName(property.readProperty("botName")) //Set nick
                .setLogin(property.readProperty("botName"))
                .addServer(property.readProperty("serverHostname"), stringToInt(property.readProperty("serverPort"))) //set server hostname and port
                .setNickservPassword(property.readProperty("NickServPassword")) //NickServ password
                .addAutoJoinChannel(property.readProperty("defaultChannel")) //set autoJoin channel(s)
                .setMessageDelay(stringToInt(property.readProperty("messageDelay")))

                //ALL MY LOVELY LISTENERS
                // Commands listeners
                .addListener(new BotInfos())
                .addListener(new Prefix())
                .addListener(new Bash())
                .addListener(new SendMessage())
                .addListener(new TestCommands())
                .addListener(new IRCCommands())
                .addListener(new IRCMovements())
                .addListener(new Spam())
                .addListener(new Stalk())
                .addListener(new ChatToggle())
                .addListener(new LastfmCommands())

                // fake.java listeners
                //.addListener(new PJListener())

                // IRCEventsReactions listeners
                .addListener(new OnInvite())
                .addListener(new OnKick())
                .addListener(new OnJoin())
                .addListener(new OnPart())
                .addListener(new OnSetSecret())
                .addListener(new OnUnknown())

                // chatter listeners
                .addListener(new BasicChatsENG())

                // working.cycles listeners
                .addListener(new StalkCycle())

                .buildConfiguration(); //build it!


        bot = new PircBotX(myConfig); //give him the configs

        try {
            bot.startBot(); //start the bot
        } catch (IOException | IrcException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:Walkersneps,项目名称:SnepsBotX,代码行数:56,代码来源:SnepsBotX.java

示例14: start

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
public final IRC start() throws IOException, IrcException {
    irc.startBot();
    return this;
}
 
开发者ID:automenta,项目名称:spimedb,代码行数:5,代码来源:IRC.java

示例15: handleLine

import org.pircbotx.exception.IrcException; //导入依赖的package包/类
@Override
public void handleLine(String rawLine) throws IOException, IrcException {
    if (rawLine == null) {
        throw new NullPointerException("rawLine");
    } else {
        String line = CharMatcher.WHITESPACE.trimFrom(rawLine);
        com.google.common.collect.ImmutableMap.Builder<String, String> tags = ImmutableMap.builder();
        String command;
        if (line.startsWith("@")) {
            String parsedLine = line.substring(1, line.indexOf(" "));
            line = line.substring(line.indexOf(" ") + 1);
            StringTokenizer sourceRaw = new StringTokenizer(parsedLine);

            while (sourceRaw.hasMoreTokens()) {
                command = sourceRaw.nextToken(";");
                if (command.contains("=")) {
                    String[] target = command.split("=");
                    tags.put(target[0], target.length == 2 ? target[1] : "");
                } else {
                    tags.put(command, "");
                }
            }
        }

        List<String> parsedLine1 = Utils.tokenizeLine(line);
        String sourceRaw1 = "";
        if (parsedLine1.get(0).charAt(0) == 58) {
            sourceRaw1 = parsedLine1.remove(0);
        }

        command = parsedLine1.remove(0).toUpperCase(this.configuration.getLocale());
        if (!command.equals("PING")) {
            App.logger.info(rawLine);
        }
        if (command.equals("PING")) {
            this.configuration.getListenerManager().onEvent(new ServerPingEvent(this.bot, parsedLine1.get(0)));
        } else if (command.startsWith("ERROR")) {
            this.bot.close();
        } else {
            String target1 = parsedLine1.isEmpty() ? "" : parsedLine1.get(0);
            if (target1.startsWith(":")) {
                target1 = target1.substring(1);
            }

            if (sourceRaw1.startsWith(":")) {
                if (((IRCBot) this.bot).notLoggedIn()) {
                    this.processConnect(line, command, target1, parsedLine1);
                }

                int code1 = Utils.tryParseInt(command, -1);
                if (code1 != -1) {
                    this.processServerResponse(code1, line, parsedLine1);
                } else {
                    UserHostmask source1 = this.bot.getConfiguration().getBotFactory().createUserHostmask(this.bot, sourceRaw1.substring(1));
                    this.processCommand(target1, source1, command, line, parsedLine1, tags.build());
                }
            } else {
                this.configuration.getListenerManager().onEvent(new UnknownEvent(this.bot, line));
                if (((IRCBot) this.bot).notLoggedIn()) {
                    for (CapHandler source : this.configuration.getCapHandlers()) {
                        if (source.handleUnknown(this.bot, line)) {
                            this.addCapHandlerFinished(source);
                        }
                    }
                }

            }
        }
    }
}
 
开发者ID:OTBProject,项目名称:OTBProject,代码行数:71,代码来源:InputParserImproved.java


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