· 9 years ago · Aug 23, 2016, 02:22 PM
1package main;
2
3import java.nio.charset.Charset;
4
5import org.pircbotx.Configuration;
6import org.pircbotx.PircBotX;
7
8/**
9 * Basic example class for various features of PircBotX. Heavily documented
10 * to explain what's going on
11 * <p/>
12 * @author Leon Blakey <lord.quackstar at gmail.com>
13 */
14public class PircBotXExample {
15 @SuppressWarnings("deprecation")
16 public static void main(String[] args) {
17 //Setup this bot
18 Configuration configuration = new Configuration.Builder()
19 .setEncoding(Charset.forName("UTF_8"))
20 .setName("loockystwtchbot") //Set the nick of the bot. CHANGE IN YOUR CODE
21 .setLogin("loockystwtch") //login part of hostmask, eg name:login@host
22 .setAutoNickChange(true) //Automatically change nick when the current one is in use
23 .setServer("irc.twitch.tv", 6667)
24 .setServerPassword("oauth:")
25 .addAutoJoinChannel("#Loockystwtch") //Join the official #pircbotx channel
26 .buildConfiguration();
27
28 //bot.connect throws various exceptions for failures
29 try {
30 PircBotX bot = new PircBotX(configuration);
31 //Connect to the freenode IRC network
32 bot.startBot();
33 } //In your code you should catch and handle each exception seperately,
34 //but here we just lump them all togeather for simpliciy
35 catch (Exception ex) {
36 ex.printStackTrace();
37 }
38 }
39}