本文整理匯總了Java中org.pircbotx.PircBotX.startBot方法的典型用法代碼示例。如果您正苦於以下問題:Java PircBotX.startBot方法的具體用法?Java PircBotX.startBot怎麽用?Java PircBotX.startBot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.pircbotx.PircBotX
的用法示例。
在下文中一共展示了PircBotX.startBot方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.pircbotx.PircBotX; //導入方法依賴的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: main
import org.pircbotx.PircBotX; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
PircBotX bot = new PircBotX(getConfig().getConfiguration());
handler = new ChatHandler(bot);
bot.getConfiguration().getListenerManager().addListener(handler);
@SuppressWarnings({"TooBroadCatch", "BroadCatchBlock", "UseSpecificCatch"})
Thread botThread = new Thread(() -> {
try {
bot.startBot();
} catch (Exception e) {
log.warn("Exception in IRC thread", e);
}
}, "IRC bot");
botThread.start();
// No GUI by default
List<String> argsList = new ArrayList<>(Arrays.asList(args));
if (!argsList.remove("--gui") && !argsList.contains("--nogui")) {
argsList.add("--nogui");
}
MinecraftServer.main(argsList.toArray(new String[0]));
}
示例3: init
import org.pircbotx.PircBotX; //導入方法依賴的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();
}
示例4: main
import org.pircbotx.PircBotX; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception{
System.setProperty("http.agent", "Wget/1.9.1");
initializeProperties();
initializeWatchlist();
for (Field field : Commands.class.getFields()) hardCommands.add((String)field.get(""));
Thread animeCheckingThread = new Thread(){
@Override
public void run() {
while (true){
try {
lookForAnimes();
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
helix = new PircBotX(new ConfigurationEsperNet().buildConfiguration());
// animeCheckingThread.start();
readWordlist();
JSONArray a = new JSONArray(properties.getProperty("irc.admins"));
for (int i = 0; i < a.length(); i++) {
admins.add(a.getString(i));
}
new HTTPServer();
helix.startBot();
}
示例5: startBot
import org.pircbotx.PircBotX; //導入方法依賴的package包/類
private static void startBot(PircBotX bot) {
logger.info("Starting PircBotX bot");
try {
bot.startBot();
} catch (Exception e) {
logger.error("Failed to start PircBotX bot", e);
System.exit(1);
}
}
示例6: TheHiddenBot
import org.pircbotx.PircBotX; //導入方法依賴的package包/類
public TheHiddenBot(){
try {
PircBotX myBot = new PircBotX(server);
myBot.startBot();
} catch (Exception e){
e.printStackTrace();
}
}
示例7: main
import org.pircbotx.PircBotX; //導入方法依賴的package包/類
public static void main(String args[]) throws Exception{
Integer Port = 6667;
String Password = "";
String Server = "irc.twitch.tv";
//Builds the bot, enables options for the bot.
Configuration config = new Configuration.Builder()
.setAutoNickChange(false)
.setCapEnabled(true)
.addCapHandler(new EnableCapHandler("twitch.tv/membership"))
.addCapHandler(new EnableCapHandler("twitch.tv/tags"))
.addCapHandler(new EnableCapHandler("twitch.tv/commands"))
.addServer(Server, Port)
.setName("fallbot301")
.setName("fallbot301")
.setServerPassword(Password)
.addAutoJoinChannel("#fallbot301")
.addListener(new Fallbot())
.buildConfiguration();
PircBotX bot = new PircBotX(config);
try{
bot.startBot();
}catch (Exception ex){
ex.printStackTrace();
}
}
示例8: onCommand
import org.pircbotx.PircBotX; //導入方法依賴的package包/類
@Override
public void onCommand(String command, String[] args, CommandIO commandIO) throws Exception {
boolean reconnect = false;
boolean disconnect = false;
if (command.equalsIgnoreCase("reconnect")) {
reconnect = true;
} else if (command.equalsIgnoreCase("disconnect")) {
disconnect = true;
}
PircBotX workingnetwork = IRCUtils.getNetworkByNetworkName(args[0]);
if (workingnetwork == null) {
commandIO.getPrintStream().println("Network does not exist");
return;
}
if (reconnect || disconnect) {
if (workingnetwork.getState().equals(PircBotX.State.DISCONNECTED)) {
commandIO.getPrintStream().println("Bot currently disconnected");
return;
} else {
commandIO.getPrintStream().println("Disconnecting...");
workingnetwork.sendIRC().quitServer(GeneralUtils.buildMessage(1, args.length, args));
workingnetwork.stopBotReconnect();
}
}
if (disconnect) {
return;
} else if (reconnect) {
do {
TimeUnit.SECONDS.sleep(5);
} while (workingnetwork.getState().equals(PircBotX.State.CONNECTED));
}
if (workingnetwork.getState().equals(PircBotX.State.CONNECTED)) {
commandIO.getPrintStream().println("Bot currently connected");
} else {
commandIO.getPrintStream().println("Reconnecting...");
workingnetwork.startBot();
return;
}
}
示例9: SnepsBotX
import org.pircbotx.PircBotX; //導入方法依賴的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();
}
}