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


Java MessageEvent.getChannel方法代码示例

本文整理汇总了Java中org.pircbotx.hooks.events.MessageEvent.getChannel方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEvent.getChannel方法的具体用法?Java MessageEvent.getChannel怎么用?Java MessageEvent.getChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pircbotx.hooks.events.MessageEvent的用法示例。


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

示例1: executeCommand

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
    if (event instanceof MessageEvent) {
        MessageEvent channelEvent = (MessageEvent) event;
        Channel channel = channelEvent.getChannel();
        if (channel != null) {
            StringBuilder sb = new StringBuilder();
            for (User user : channel.getUsers()) {
                if (sb.length() > 0) {
                    sb.append(' ');
                }
                sb.append(user.getNick());
            }
            return new BotResponse(BotIntention.CHAT, null, sb.toString());
        }
    }
    return new BotResponse(BotIntention.PRIVATE_MESSAGE, event.getUser(),
            "there aint nobody to wake up here!");
}
 
开发者ID:proxa,项目名称:IRCbutt,代码行数:20,代码来源:WakeRoomCommand.java

示例2: channelCommand

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void channelCommand(MessageEvent<PircBotX> event) throws Exception {
    message = event.getMessage();
    command = message.split(" ")[0];
    user = event.getUser().getNick();
    args = event.getMessage().split(" ");
    channel = event.getChannel();
}
 
开发者ID:lorddusk,项目名称:DuskBot,代码行数:8,代码来源:CommandBase.java

示例3: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent<PircBotX> event) {
    final User user = event.getUser();
    final Channel channel = event.getChannel();
    final String message = event.getMessage();
    if (user != plugin.getIrcBot().getUserBot()) {
        if (!message.startsWith("!")) {
            plugin.handleChat(user, channel, message);
        }
    }
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:12,代码来源:IrcMessageListener.java

示例4: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent<PircBotX> event) throws Exception {
    String message = event.getMessage();
    User sender = event.getUser();
    Channel channel = event.getChannel();
    List<ICommand> commands = CommandRegistry.INSTANCE.getCommands();

    Long lastFire = delayMap.get(event.getChannel().getName());
    if (lastFire == null) {
        lastFire = 0L;
    }

    ReactionRegistry.INSTANCE.getReactions().forEach(r -> r.onMessage(event));
    String[] args = IRCUtils.trim(message.split(" "));

    if (args.length < 1) {
        return;
    }

    // Eira Bot
    if (args[0].startsWith("<") && args[0].endsWith(">")) {
        args = ArrayUtils.remove(args, 0);
    }

    if (args.length > 0 && args[0].startsWith(controlChar)) {
        PermLevel perm = PermRegistry.INSTANCE.getPermLevelForUser(event.getChannel(), event.getUser());

        if (perm == PermLevel.NONE && !PermRegistry.INSTANCE.isDefaultController(sender)) {
            MessageSender.INSTANCE.enqueueNotice(event.getBot(), sender.getNick(), "You may not execute commands in " + channel.getName());
            return;
        }

        if (lastFire + delayTime < System.currentTimeMillis() || IRCUtils.isPermLevelAboveOrEqualTo(perm, PermLevel.TRUSTED)) {
            args[0] = pruneCommand(args[0]);
            for (int i = 0; i < commands.size(); i++) {
                ICommand c = commands.get(i);
                if (c.getIdent().equalsIgnoreCase(args[0]) && (IRCUtils.userIsOp(event.getChannel(), event.getBot().getUserBot()) || !c.needsOp())) {
                    delayMap.put(channel.getName(), System.currentTimeMillis());
                    List<String> toSend = new ArrayList<String>();
                    if (IRCUtils.userMatchesPerms(channel, sender, c.getPermLevel())) {
                        c.onCommand(event.getBot(), event.getUser(), event.getChannel(), toSend, ArrayUtils.remove(args, 0));
                    } else {
                        MessageSender.INSTANCE.enqueueNotice(event.getBot(), event.getUser().getNick(), "You have no permission, you must be at least: " + c.getPermLevel().toString());
                    }

                    for (String s : toSend) {
                        IRCUtils.modeSensitiveEnqueue(event.getBot(), event.getUser(), event.getChannel(), s);
                    }
                }

                if (i < commands.size() && commands.get(i) != c) {
                    i--;
                }
            }
        } else {
            event.getUser().send().notice("Slow down there, partner.");
        }
    }
}
 
开发者ID:TPPIDev,项目名称:TPPIBot,代码行数:60,代码来源:MessageListener.java

示例5: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception {
    Chan = event.getChannel();
    if (event.getMessage().equalsIgnoreCase("!test")) {

        event.getChannel().send().message("Running C++ saying hello world! Just kidding, running Java baby!! Keepo");

    }
    else if (event.getMessage().equalsIgnoreCase("!join")) {

        event.getBot().sendIRC().joinChannel("#" + event.getUser().getNick().toLowerCase());

    }
    else if (event.getMessage().equalsIgnoreCase("!createtable")) {

        SQLConnection.createTable(Chan.getName());


    } else if (event.getMessage().toLowerCase().startsWith("!join #")) {

        event.respond("On My Way!");
        String[] parts = event.getMessage().split(" ");
        event.getBot().sendIRC().joinChannel(parts[1].toLowerCase());
      //TODO Make the rank command read the actual user rank, needs TTVJSONHandler first.
    } else if (event.getMessage().toLowerCase().startsWith("!rank")) {

        String Rank = "";
        //if(event.getUser().toString().toLowerCase() ==)
        if(event.getUser().toString().equalsIgnoreCase(Owner)){
            event.respond("Your rank is: " + Rank + ". You are also my creator.");
        }

    } /**else if (event.getMessage().toLowerCase().startsWith("!uptime")) {
            event.getChannel().send().message(JSON.getUptime(Chan.getName()));

    }**/

    //Leave the dang channel.
    else if (event.getMessage().toLowerCase().startsWith("!dismiss")) {
        if(event.getUser().toString().equalsIgnoreCase(event.getChannel().getOwners().toString())){
         event.getBot().sendRaw().rawLine("PART"+Chan.getName());
        }

        //If NONE of the previous hardcoded commands are right, THEN go to the MySQL database.
    } else if (event.getMessage().toLowerCase().startsWith("!")) {
        String reply = SQLConnection.returnCom(Chan.getName().toLowerCase().replace("#",""), event.getMessage().toLowerCase() );
            if(reply!=null) {
                event.getChannel().send().message(reply);
            }

    }

}
 
开发者ID:Fallout301,项目名称:Fallbot,代码行数:54,代码来源:Fallbot.java


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