當前位置: 首頁>>代碼示例>>Java>>正文


Java PircBotX類代碼示例

本文整理匯總了Java中org.pircbotx.PircBotX的典型用法代碼示例。如果您正苦於以下問題:Java PircBotX類的具體用法?Java PircBotX怎麽用?Java PircBotX使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PircBotX類屬於org.pircbotx包,在下文中一共展示了PircBotX類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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();
}
 
開發者ID:Unarmed,項目名稱:internet-on-a-stick,代碼行數:25,代碼來源:IrcBot.java

示例2: run

import org.pircbotx.PircBotX; //導入依賴的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.PircBotX; //導入依賴的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: channelCommand

import org.pircbotx.PircBotX; //導入依賴的package包/類
@Override
public void channelCommand(MessageEvent<PircBotX> event) throws Exception {
    super.channelCommand(event);

    if(Permissions.getLevel(user) >= 2) {
        if(Bot.commandList.containsKey(args[1])) {
            List<String> response = new ArrayList<>();
            response.addAll(Arrays.asList(args).subList(2, args.length));
            StringBuilder result = new StringBuilder();
            for (int i = 0; i < response.size(); i++) {
                result.append(response.get(i));
                if (i != response.size() - 1) {
                    result.append(" ");
                }
            }
            String responseComplete = result.toString();
            editCommand(args[1], responseComplete, event);
        }
    } else {
        MessageSending.sendNormalMessage("You don't have permission to edit a command", event);
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:23,代碼來源:EditCommands.java

示例5: containsLink

import org.pircbotx.PircBotX; //導入依賴的package包/類
public static boolean containsLink(String s, MessageEvent<PircBotX> event) throws InterruptedException {
    Matcher matcher = urlPattern.matcher(s);
    if (matcher.find()) {
        if (!Permissions.isPermitted(getNick(event).toLowerCase())) {
            Thread.sleep(1000);
            Timeout(event, "link");

            return true;
        } else {
            ChannelMethods.youtubeDescription(s, Defaults.songRequestBoolean);
            Bot.permitted.remove(event.getUser().getNick().toLowerCase());
            return false;
        }
    } else {
        return false;
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:18,代碼來源:CommandPermit.java

示例6: Timeout

import org.pircbotx.PircBotX; //導入依賴的package包/類
public static void Timeout(MessageEvent<PircBotX> event, String type) {
    if (Bot.strikeList.get(event.getUser().getNick().toLowerCase()) == null) {
        Bot.strikeList.put(event.getUser().getNick().toLowerCase(), (long) 1);
    } else {
        Bot.strikeList.put(event.getUser().getNick().toLowerCase(), Bot.strikeList.get(event.getUser().getNick().toLowerCase()) + 1);
    }

    if (type.equals("link")) {
        MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(), "You are not permitted to post links. (Strike : #" + Bot.strikeList.get(event.getUser().getNick().toLowerCase()) + ")");
        MessageSending.sendNormalMessage("You are not permitted to post links.");
    } else if (type.equals("caps")) {
        MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(), "Please refrain from using big amounts of caps. (Strike : #" + Bot.strikeList.get(event.getUser().getNick().toLowerCase()) + ")");
        MessageSending.sendNormalMessage("Please refrain from using big amounts of caps.");
    } else if (type.equals("wot")) {
        MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(), "Please refrain from using walls of text. (Strike : #" + Bot.strikeList.get(event.getUser().getNick().toLowerCase()) + ")");
        MessageSending.sendNormalMessage("Please refrain from using walls of text.");
    } else {
        MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(), "You were purged. (Strike : #" + Bot.strikeList.get(event.getUser().getNick().toLowerCase()) + ")");
    }

    if (Bot.strikeList.get(event.getUser().getNick().toLowerCase()) <= 3) {
        event.getBot().sendRaw().rawLine("PRIVMSG " + event.getChannel().getName() + " :.timeout " + event.getUser().getNick() + " 1");
    } else {
        event.getBot().sendRaw().rawLine("PRIVMSG " + event.getChannel().getName() + " :.timeout " + event.getUser().getNick() + " 600");
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:27,代碼來源:CommandPermit.java

示例7: containsCaps

import org.pircbotx.PircBotX; //導入依賴的package包/類
public static void containsCaps(String message, MessageEvent<PircBotX> event) throws InterruptedException {
    if (message.length() > 10) {
        double threshold = Math.floor(message.length() / 2);
        String isUp = "";
        int z = message.length();
        for (int y = 0; y < z; y++) {
            if (Character.isUpperCase(message.charAt(y))) {
                char w = message.charAt(y);
                isUp = isUp + w;
            }
        }
        if (isUp.length() > threshold) {
            Thread.sleep(1000);
            if (!Permissions.isPermitted(getNick(event).toLowerCase())) {
                Timeout(event, "caps");

            }
        }
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:21,代碼來源:CommandPermit.java

示例8: channelCommand

import org.pircbotx.PircBotX; //導入依賴的package包/類
@Override
public void channelCommand(final MessageEvent<PircBotX> event) throws Exception {
    super.channelCommand(event);
    if (Permissions.getLevel(user.toLowerCase()) >= 2) {
        if (args.length != 4) {
            MessageSending.sendNormalMessage("Wrong Syntax user : !timer &lt;command1&gt; &lt;time in minutes&gt; &lt;command2&gt;", event);
        }
        if (args.length == 4) {
            if (Bot.commandList.containsKey(args[1]) && Bot.commandList.containsKey(args[3])) {
                MessageSending.sendNormalMessage(Bot.commandList.get(args[1]), event);
                Timer timer = new Timer();
                timer.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        MessageSending.sendNormalMessage(Bot.commandList.get(args[3]), event);
                    }
                }, Integer.parseInt(args[2]) * 60 * 1000);

            }
        }
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:23,代碼來源:CommandTimer.java

示例9: buyRank

import org.pircbotx.PircBotX; //導入依賴的package包/類
private void buyRank(String user, String rank, MessageEvent<PircBotX> event) {
    try {
        Long points = Bot.userList.get(user);
        Long rankCost = Bot.rankList.get(rank);
        if (Bot.rankList.get(rank) != null) {
            if (points >= rankCost) {
                Bot.userList.put(user, Bot.userList.get(user) - rankCost);
                Bot.rankUserList.put(user, rank);
                MessageSending.sendMessageWithPrefix(user + " successfully bought " + rank, user, event);
                Bot.saveAllTheThings();
            } else {
                MessageSending.sendMessageWithPrefix(user + " you do not have enough " + Defaults.getPointName(), user, event);
            }
        } else {
            System.out.println(rank);
            System.out.println(Bot.rankList.get(rank));
            MessageSending.sendMessageWithPrefix(user + " this rank doesn't exist.", user, event);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:23,代碼來源:CommandRanks.java

示例10: sellRank

import org.pircbotx.PircBotX; //導入依賴的package包/類
private void sellRank(String user, MessageEvent<PircBotX> event) {
    try {
        Long rankCost = Bot.rankList.get(getRank(user));
        Long points = Bot.userList.get(user);
        if (Bot.rankUserList.get(user) != null) {
            Bot.rankUserList.remove(user);
            Bot.userList.put(user, (points + (rankCost / 2)));
            MessageSending.sendMessageWithPrefix(user + " you have successfully sold your rank. But you only received half of your " + Defaults.getPointName() + " back, because inflation.", user, event);
            Bot.saveAllTheThings();
        } else {
            MessageSending.sendMessageWithPrefix(user + " you either have no rank, or you have a unsellable rank.", user, event);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:17,代碼來源:CommandRanks.java

示例11: channelCommand

import org.pircbotx.PircBotX; //導入依賴的package包/類
@Override
public void channelCommand(MessageEvent<PircBotX> event) throws Exception {
    super.channelCommand(event);
    if (args.length == 1) {
        System.out.println(Bot.permList.get(user.toLowerCase()));
        if (Bot.permList.get(user.toLowerCase()) != null) {
            MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(),"You have the following level of permissions : " + getPermission(user));
        } else {
            MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(),"You have no permissions");
        }
    } else if (args.length == 4) {
        if(args[3].equalsIgnoreCase("reg") && Permissions.getLevel(user) >= 2) {
            addPermission(args[2], args[3], event);
        }else if(Permissions.getLevel(user) == 4){
            addPermission(args[2], args[3], event);
        }else{
            MessageSending.sendNormalMessage("You do not have permission to give a user a higher permission level than regular",event);
        }
    } else if (args.length == 3 && Permissions.getLevel(user) == 4) {
        removePermission(args[2], event);
    } else {
        MessageSending.sendMessageWithPrefix("Correct Args: !permission &lt;add|remove&gt; &lt;name&gt; [&lt;mod|reg|smod&gt;]", user, event);
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:25,代碼來源:CommandPermissions.java

示例12: addPermission

import org.pircbotx.PircBotX; //導入依賴的package包/類
private void addPermission(String user, String level, MessageEvent<PircBotX> event) throws IOException {
    if (level.equalsIgnoreCase("mod") || level.equalsIgnoreCase("reg") || level.equalsIgnoreCase("smod")) {
        if (Bot.permList.containsKey(user)) {
            Bot.permList.replace(user.toLowerCase(), user.toLowerCase(), level.toLowerCase());
            MessageSending.sendNormalMessage(user + " has been given " + level + " permissions.", event);
            Bot.log.info(user + " has been given " + level + " permissions.");
            Bot.saveAllTheThings();
            MainController.getInstance().permissionFiller();
        } else {
            Bot.permList.put(user.toLowerCase(), level.toLowerCase());
            MessageSending.sendNormalMessage(user + " has been given " + level + " permissions.", event);
            Bot.log.info(user + " has been given " + level + " permissions.");
            Bot.saveAllTheThings();
            MainController.getInstance().permissionFiller();
        }
    } else {
        MessageSending.sendNormalMessage("Only permission levels are MOD and REG", event);
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:20,代碼來源:CommandPermissions.java

示例13: preMessage

import org.pircbotx.PircBotX; //導入依賴的package包/類
public static void preMessage(MessageEvent<PircBotX> event) {
    arg = "";
    argList.clear();

    if (event.getMessage().split(" ").length >= 2) {
        for (int i = 1; i < event.getMessage().split(" ").length; i++) {
            if (i == event.getMessage().split(" ").length) {
                arg += (event.getMessage().split(" ")[i]);
                argList.add(event.getMessage().split(" ")[i]);
            } else {
                arg += (event.getMessage().split(" ")[i] + " ");
                argList.add(event.getMessage().split(" ")[i]);
            }
        }
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:17,代碼來源:ChannelMethods.java

示例14: Note

import org.pircbotx.PircBotX; //導入依賴的package包/類
public static void Note(MessageEvent<PircBotX> event) throws IOException {
    if (Permissions.getLevel(getNick(event)) >= 2) {
        boolean noteAdded = false;
        try {
            String completeQuote = arg;
            long note = (long) Bot.noteList.size() + 1;
            while (!noteAdded) {
                if (!Bot.noteList.containsKey(note)) {
                    Bot.noteList.put(note, completeQuote);
                    noteAdded = true;
                    MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(), " Note has been added as #" + note + ".");
                    Bot.log.info("Note " + note + " has been added");
                } else {
                    note += 1;
                    noteAdded = false;
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            Bot.saveAllTheThings();
        }
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:25,代碼來源:ChannelMethods.java

示例15: SteamGame

import org.pircbotx.PircBotX; //導入依賴的package包/類
public static void SteamGame(MessageEvent<PircBotX> event) throws Exception {
    JSONObject json = new JSONObject(JSONParser.readUrl("https://api.twitch.tv/kraken/channels/" + Bot.config.getProperty("autoJoinChannel")));
    if (json != null) {
        String game = json.get("game").toString();
        if (Bot.steamList.containsKey(game)) {
            Integer appid = Bot.steamList.get(game);
            String url = "http://store.steampowered.com/app/" + appid + "/";
            if (Defaults.whisperToggle) {
                MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(), "I'm currently playing " + game + ". You can find more info about it right here : " + url);
            } else {
                MessageSending.sendNormalMessage("I'm currently playing " + game + ". You can find more info about it right here : " + url);
            }
        } else {
            if (Defaults.whisperToggle) {
                MessageSending.sendWhisper(event.getUser().getNick().toLowerCase(), "I'm currently playing " + game + ".");
            } else {
                MessageSending.sendNormalMessage("I'm currently playing " + game + ".");
            }
        }
    }
}
 
開發者ID:lorddusk,項目名稱:DuskBot,代碼行數:22,代碼來源:ChannelMethods.java


注:本文中的org.pircbotx.PircBotX類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。