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


Java Channel类代码示例

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


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

示例1: handleNick

import org.pircbotx.Channel; //导入依赖的package包/类
private void handleNick(AgarBot bot, User user, Channel channel) {
    if (user.equals(user.getBot().getUserBot()) || bot.getAuth().checkLevel(user, AuthLevel.BYPASS) || !Utils.checkBot(bot, channel)) {
        return;
    }
    Matcher matcher = getMatch(user.getNick());
    if (matcher == null) {
        return;
    }
    boolean ban = true;
    Data data = badnicks.get(matcher.pattern());
    if (data.severity < 3 && strikes.getIfPresent(user.getHostmask()) == null) {
        strikes.put(user.getHostmask(), true);
        ban = false;
    }
    if (ban) {
        channel.send().ban(user.getHostmask());
    }
    channel.send().kick(user, badnicks.get(matcher.pattern()).reason);
    log.info("BADNICK TRIGGERED: " + user.getNick() + " " + user.getHostmask());
}
 
开发者ID:likcoras,项目名称:A-Gario,代码行数:21,代码来源:BadnickHook.java

示例2: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    if(command.equalsIgnoreCase("showerthought")){
        args = new String[1];
        args[0] = "showerthoughts";
    }
    try {
        JsonArray results = GeneralUtils.getJsonObject("https://api.reddit.com/r/" + args[0] + "/?limit=25").get("data").getAsJsonObject().get("children").getAsJsonArray();
        if (results.size() < 1) {
            IRCUtils.sendError(user, network, channel, "Search returned no results", prefix);
        } else {
            JsonObject result = results.get(new Random().nextInt(results.size() - 1)).getAsJsonObject().get("data").getAsJsonObject();
            IRCUtils.sendMessage(user, network, channel, result.get("title").getAsString() + " - by " + IRCUtils.noPing(result.get("author").getAsString()) + " - " + GeneralUtils.shortenURL(result.get("url").getAsString()), prefix);
        }
    }catch(HttpStatusException e){
        if(e.getStatusCode() == 403){
            IRCUtils.sendError(user,network,channel, "Private Subreddit!", prefix);
        }
    }

}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:22,代码来源:Reddit.java

示例3: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    Set<String> networks = new HashSet<>();
    for (PircBotX net : Registry.networks.inverse().keySet()) {
        if (args.length < 1) {
            networks.add(IRCUtils.getNetworkNameByNetwork(net));
        } else if (args[0].equalsIgnoreCase("connected")) {
            if (net.getState().equals(PircBotX.State.CONNECTED))
                networks.add(IRCUtils.getNetworkNameByNetwork(net));
        } else if (args[0].equalsIgnoreCase("disconnected")) {
            if (net.getState().equals(PircBotX.State.DISCONNECTED))
                networks.add(IRCUtils.getNetworkNameByNetwork(net));
        } else {
            networks.add(IRCUtils.getNetworkNameByNetwork(net));
        }
    }
    if (networks.isEmpty())
        IRCUtils.sendError(user, network, channel, "No networks found" + networks, prefix);
    else
        IRCUtils.sendMessage(user, network, channel, Registry.networks.size() + " network(s) found: " + StringUtils.join(networks, ", "), prefix);
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:22,代码来源:ListNetworks.java

示例4: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    if (IRCUtils.checkIfCanKick(channel, network, user)) {
        IRCUtils.sendKick(network.getUserBot(), user, network, channel, "┻━┻ ︵ ¯\\_(ツ)_/¯ ︵ ┻━┻");
    } else {
        IRCUtils.sendAction(user, network, channel, "kicks " + IRCUtils.noPing(user.getNick()) + " (┻━┻ ︵ ¯\\_(ツ)_/¯ ︵ ┻━┻)", prefix);
    }
    Record rec = DatabaseUtils.getChannelProperty(IRCUtils.getNetworkNameByNetwork(network), channel.getName(), "funmsg");
    if (rec != null && rec.getValue(Channelproperty.CHANNELPROPERTY.VALUE).equalsIgnoreCase("true")) {
        IRCUtils.sendMessage(user, network, channel, GeneralUtils.prism("    __   ______ ______  ___     ___  ____  ________"), prefix);
        IRCUtils.sendMessage(user, network, channel, GeneralUtils.prism("   / /  /  _/ //_/ __/ / _ |   / _ )/ __ \\/ __/ __/"), prefix);
        IRCUtils.sendMessage(user, network, channel, GeneralUtils.prism("  / /___/ // ,< / _/  / __ |  / _  / /_/ /\\ \\_\\ \\  "), prefix);
        IRCUtils.sendMessage(user, network, channel, GeneralUtils.prism(" /____/___/_/|_/___/ /_/ |_| /____/\\____/___/___/"), prefix);
        IRCUtils.sendMessage(user, network, channel, GeneralUtils.prism("                                                  "), prefix);
    }
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:17,代码来源:SomethingAwesome.java

示例5: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    int ArrayIndex = 0;
    if (GeneralUtils.isInteger(args[0])) {
        ArrayIndex = Integer.parseInt(args[0]) - 1;
        args = ArrayUtils.remove(args, 0);
    }
    Document doc = Jsoup.connect("http://www.dogpile.com/info.dogpl/search/web?ssm=true&q=" + StringUtils.join(args, "%20") + "&fcoid=1573&fcop=results-main&om_nextpage=True").get();
    Elements results = doc.select(".resultsMainRegion").select(".searchResult");
    if (results.size() > 0) {
        if (results.size() - 1 >= ArrayIndex) {
            String title = results.get(ArrayIndex).select(".resultTitlePane").select(".resultTitle").text();
            String url = results.get(ArrayIndex).select(".resultDisplayUrlPane").select(".resultDisplayUrl").text();
            String content = results.get(ArrayIndex).select(".resultDescription").text();
            IRCUtils.sendMessage(user, network, channel, "[" + title + "] " + content + " - " + GeneralUtils.shortenURL(url), prefix);
        } else {
            ArrayIndex = ArrayIndex + 1;
            IRCUtils.sendError(user, network, channel, "Search #" + ArrayIndex + " does not exist", prefix);
        }
    } else {
        IRCUtils.sendError(user, network, channel, "Search returned no results", prefix);
    }
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:24,代码来源:Search.java

示例6: onAllPluginsLoaded

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
protected void onAllPluginsLoaded() {
	manager.app.serverManager.botManagers.iterate(botManager -> {
		if (!botManager.bots.isEmpty()) {
			IdentService service = botManager.getService(IdentService.class);
			NickServIdentMethod method = service.getMethod(NickServIdentMethod.class);
			if (method == null || !method.isAvailable() || !method.hasWhoX())
				return;
			
			botManager.bots.iterate(bot -> {
				for (Channel channel : bot.getUserBot().getChannels()) {
					bot.sendRaw().rawLine(String.format("WHO %s %%na", channel.getName()));
				}
			});
		}
	});
}
 
开发者ID:Shockah,项目名称:Skylark,代码行数:18,代码来源:NickServIdentPlugin.java

示例7: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    String wolframalphaapikey;
    if (DatabaseUtils.getConfig("wolframalphaapikey") != null)
        wolframalphaapikey = DatabaseUtils.getConfig("wolframalphaapikey").getValue(CONFIG.VALUE);
    else {
        IRCUtils.sendError(user, network, channel, "Wolfram Alpha api key is null - contact bot controller to fix", prefix);
        return;
    }
    WAEngine engine = new WAEngine();
    engine.setAppID(wolframalphaapikey);
    engine.addFormat("plaintext");
    WAQuery query = engine.createQuery();
    query.setInput(StringUtils.join(args, " "));
    WAQueryResult queryResult = engine.performQuery(query);
    WAPod[] result = queryResult.getPods();
    List<String> results = new ArrayList<>();
    if (result.length > 0) {
            results.add(GeneralUtils.getWAResult(0, result));
            results.add(GeneralUtils.getWAResult(1, result));
            IRCUtils.sendMessage(user, network, channel,StringUtils.join(results, " - "), prefix);
    } else {
        IRCUtils.sendError(user, network, channel, "Question returned no answers", prefix);
    }
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:26,代码来源:Question.java

示例8: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(PircBotX bot, User user, Channel channel, List<String> lines, String... args) {
    if (args.length < 1) {
        lines.add("This command requires at least one arg.");
    }

    String potentialChannel = IRCUtils.fmtChan(args[args.length - 1]);
    Channel sayChan = IRCUtils.getChannelByName(bot, potentialChannel).orElse(null); // meh

    if (sayChan != null) {
        args = ArrayUtils.remove(args, args.length - 1);
    }

    String text = StringUtils.join(args, " ");

    if (sayChan == null || IRCUtils.isPermLevelAboveOrEqualTo(PermRegistry.INSTANCE.getPermLevelForUser(sayChan, user), PermLevel.TRUSTED)) {
        MessageSender.INSTANCE.enqueue(bot, sayChan == null ? channel == null ? user.getNick() : channel.getName() : sayChan.getName(), text);
    } else {
        lines.add("You must be trusted or higher in that channel.");
    }
}
 
开发者ID:TPPIDev,项目名称:TPPIBot,代码行数:22,代码来源:Say.java

示例9: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(PircBotX bot, User user, Channel channel, List<String> lines, String... args) {
    if (args.length < 2) {
        lines.add("This requires 2 args: [command] and [edit args]");
        return;
    }

    for (ICommand c : CommandRegistry.INSTANCE.getCommands()) {
        String cmdName = args[0];

        if (c.getIdent().equalsIgnoreCase(cmdName)) {
            args = ArrayUtils.remove(args, 0);

            if (!IRCUtils.userMatchesPerms(channel, user, c.getPermLevel())) {
                lines.add("You do not have high enough permissions to edit command \"" + c.getIdent() + ".\" You must be at least: " + c.getPermLevel());
                return;
            }

            lines.add("Editing command " + c.getIdent() + "...");
            c.editCommand(bot, user, channel, lines, args);
        }
    }
}
 
开发者ID:TPPIDev,项目名称:TPPIBot,代码行数:24,代码来源:EditCommand.java

示例10: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    if (!PermUtils.isAccountEnabled(network)) {
        IRCUtils.sendError(user, network, channel, "This network is set to " + DatabaseUtils.getNetwork(IRCUtils.getNetworkNameByNetwork(network)).getValue(NETWORKS.AUTHTYPE) + " authentication", prefix);
        return;
    }
    String authedUser = PermUtils.authUser(network, user.getNick());
    Record account = DatabaseUtils.getAccount(authedUser);
    if (Registry.encryptor.checkPassword(args[0] + account.getValue(ACCOUNTS.RANDOMSTRING), account.getValue(ACCOUNTS.PASSWORD))) {
        if (authedUser != null) {
            Registry.networks.inverse().keySet().stream().filter(net -> PermUtils.isAccountEnabled(net)).forEach(net -> {
                Registry.authedUsers.get(net).keySet().stream().filter(key -> Registry.authedUsers.get(net).get(key).equals(authedUser)).forEach(key ->
                                Registry.authedUsers.get(net).remove(key)
                );
                DatabaseUtils.removeNetworkUserPropertyByUser(IRCUtils.getNetworkNameByNetwork(net), authedUser);
                DatabaseUtils.removeChannelUserPropertyByUser(IRCUtils.getNetworkNameByNetwork(net), authedUser);
            });
            DatabaseUtils.removeAccount(authedUser);
        }
        IRCUtils.sendMessage(user, network, channel, "Your account is now dropped", prefix);
        IRCUtils.sendLogChanMsg(network, "[ACCOUNT DROPPED] " + IRCUtils.noPing(user.getNick()));
    } else {
        IRCUtils.sendError(user, network, channel, "Incorrect password", prefix);
    }
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:26,代码来源:Drop.java

示例11: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(PircBotX bot, User user, Channel channel, List<String> lines, String... args) {
    if (args.length < 1) {
        if (channel != null) {
            user.send().notice("Your current perm level is: " + PermRegistry.INSTANCE.getPermLevelForUser(channel, user) + ".");
        }

        lines.add(IRCUtils.getMessageWithArgs(user, "To get help on specific commands " + (channel == null ? helpText.replace(MessageListener.controlChar, "\"") + "\"" : helpText), args));
    } else {
        lines.add(IRCUtils.getMessageWithArgs(user, "%user% - Info on commands:", new String[] {}));

        for (String s : args) {
            if (CommandRegistry.INSTANCE.isCommandRegistered(s)) {
                ICommand c = CommandRegistry.INSTANCE.getCommand(s);
                lines.add(String.format("Info on %s: %s %s: %s", s, c.getDesc(), "Required perm level", c.getPermLevel().toString()));
            }
        }
    }
}
 
开发者ID:TPPIDev,项目名称:TPPIBot,代码行数:20,代码来源:Help.java

示例12: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    if (args.length > 0) {
            IRCCommand irCommand = IRCUtils.getCommand(args[0], IRCUtils.getNetworkNameByNetwork(network), channel.getName());
            if (irCommand != null) {
                IRCUtils.sendMessage(user, network, channel, "Variations: " + StringUtils.join(Arrays.asList(irCommand.getCommandID()), ", "), prefix);
                String syntax = irCommand.getSyntax();
                if (!syntax.isEmpty())
                    IRCUtils.sendMessage(user, network, channel, "Syntax: " + syntax, prefix);
                IRCUtils.sendMessage(user, network, channel, irCommand.getDesc(), prefix);
            } else {
                IRCUtils.sendError(user, network, channel, "Command does not exist", prefix);
            }
    } else {
        IRCUtils.sendMessage(user, network, channel, "help (command) - Run list for available commands, generally a + before something means editing it, and a - means removing it. None means adding it. Time is in [time](s/m/h/d/w) format. [] is a required argument. () is an optional argument.", prefix);
    }
}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:18,代码来源:Help.java

示例13: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
    if (!args[0].startsWith("http://") && !args[0].startsWith("https://")) {
        args[0] = "http://" + args[0];
    }
    Document doc = Jsoup.connect("http://www.isup.me/" + args[0]).userAgent(Registry.USER_AGENT).get();
    String c = doc.select("#container").text();
    if(c.contains("not just you")){
        c = "It's not just you! " + args[0] + " looks down from here too. (Please note that isup.me - the service we use - lacks IPv6 support, so this might not be entirely accurate)";
    }else if(c.contains("just you")){
        c = "It's just you. " + args[0] + " looks fine from here.";
    }else{
        c = "isup.me can't find " + args[0] + " on the interwho. This might be because isup.me lacks IPv6 support or simply because you put in an invalid url.";
    }
    IRCUtils.sendMessage(user, network, channel, c, prefix);


}
 
开发者ID:TechCavern,项目名称:WaveTact,代码行数:19,代码来源:ISup.java

示例14: onCommand

import org.pircbotx.Channel; //导入依赖的package包/类
@Override
public void onCommand(PircBotX bot, User user, Channel channel, List<String> lines, String... args) {
    if (args.length > 0) {
        try {
            URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + args[0]);
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String uuid;

            if ((uuid = reader.readLine()) != null) {
                String[] cleaned = getInfo(uuid);
                lines.add(cleaned[1] + " ==> " + formatUUID(cleaned[0]));
            } else {
                lines.add("Unable to find any matching names.");
            }

            return;
        } catch (IOException e) {
            lines.add("The Mojang API is currently unavailable.");
            return;
        }
    }

    lines.add("This command requires at least one arg.");
}
 
开发者ID:TPPIDev,项目名称:TPPIBot,代码行数:25,代码来源:UUID.java

示例15: timeout

import org.pircbotx.Channel; //导入依赖的package包/类
public boolean timeout(PircBotX bot, User user, Channel channel, SpamReasons reason) {
    if (IRCUtils.userIsOp(channel, bot.getUserBot()) && !IRCUtils.isUserAboveOrEqualTo(channel, PermLevel.TRUSTED, user)) {
        int strikeCount = 0;
        if (strikes.containsKey(user.getHostmask())) {
            strikeCount = strikes.get(user.getHostmask()).size();
        }

        if (reason == SpamReasons.CURSE) {
            MessageSender.INSTANCE.enqueue(bot, channel.getName(), user.getNick() + ", please do not do that! This is strike " + (strikeCount + 1) + ", you will now be timed out for " + 10
                    + " minutes. Reason: " + reason.getText());
            IRCUtils.timeout(bot, user, channel, "" + 10);
            return true;
        }

        if (strikeCount < 3) {
            MessageSender.INSTANCE.enqueue(bot, channel.getName(), user.getNick() + ", please do not do that! This is strike " + (strikeCount + 1) + "! Reason: " + reason.getText());
        } else {
            MessageSender.INSTANCE.enqueue(bot, channel.getName(), user.getNick() + ", please do not do that! This is strike " + (strikeCount + 1) + ", you will now be timed out for "
                    + (5 * (strikeCount - 2)) + " minutes. Reason: " + reason.getText());
            IRCUtils.timeout(bot, user, channel, "" + 5 * (strikeCount - 2));
        }
        return true;
    }
    return false;
}
 
开发者ID:TPPIDev,项目名称:TPPIBot,代码行数:26,代码来源:CharacterSpam.java


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