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


Java MessageEvent.getUser方法代码示例

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


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

示例1: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception {
    super.onMessage(event);

    System.out.println("Escaped: " + StringEscapeUtils.escapeJava(event.getMessage()));

    if (event.getUser() == event.getBot().getUserBot() || this.bot.isModerator(event.getUser().getNick())) {
        return;
    }

    for (Spam spam : this.bot.getSpams()) {
        if (spam.shouldTakeAction(event)) {
            spam.takeAction(event);
        }
    }
}
 
开发者ID:RyanTheAllmighty,项目名称:AllmightyBot---Java,代码行数:17,代码来源:SpamListener.java

示例2: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(final MessageEvent event) {
    User sender = event.getUser();
    try {
        PreparedStatement updateSeen = RavenBot.getInstance().getPreparedStatement("updateLastSeen");
        updateSeen.setString(1, sender.getNick());
        updateSeen.setLong(2, System.currentTimeMillis());
        updateSeen.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
    super.onMessage(event);
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:14,代码来源:WatcherHandler.java

示例3: exe

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void exe(MessageEvent event, String cmdName, String[] args) throws Exception
{
	String[] colors = {
			"Grey",
			"Black",
			"Blue",
			"Dark Green",
			"Red",
			"Red",
			"Purple",
			"Brown",
			"Yellow",
			"Light Green",
			"Dark Aqua",
			"Lighter Aqua",
			"Pink"
	};
	User user = event.getUser();

	for(int i = 0; i < 14; i++)
	{
		if(i < 4)
			Utilities.notice(user, "%C" + i + ": " + colors[i]);
		else if(i > 4 && i < 12)
			Utilities.notice(user, "%C" + i + ": " + colors[i]);
		else if(i == 13)
			Utilities.notice(user, "%C" + i + ": " + colors[i - 1]);
	}
}
 
开发者ID:bl4ckscor3,项目名称:bl4ckb0t,代码行数:31,代码来源:XColor.java

示例4: 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

示例5: 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

示例6: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception {
    super.onMessage(event);

    if (!this.bot.getSettings().shouldTimeoutLinks() || event.getUser() == event.getBot().getUserBot() || bot
            .isModerator(event.getUser().getNick()) || PermitCommand.hasPermit(event.getUser().getNick()) ||
            !LINK_PATTERN.matcher(event.getMessage()).find()) {
        return;
    }

    boolean containsDomain = false;

    // Loop through the list of domains in the domains list (read from the jar) to see if it contains it
    Pattern domainPattern;
    for (String domain : domains) {
        domainPattern = Pattern.compile(".*\\." + domain + " ?\\b", Pattern.CASE_INSENSITIVE);
        if (domainPattern.matcher(event.getMessage()).find()) {
            containsDomain = true;
            break;
        }
    }

    if (!containsDomain) {
        return;
    }

    boolean matched = false;

    for (String regex : this.bot.getAllowedLinks()) {
        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
        if (pattern.matcher(event.getMessage()).find()) {
            matched = true;
            break;
        }
    }

    if (!matched) {
        if (!warnings.containsKey(event.getUser().getNick())) {
            warnings.put(event.getUser().getNick(), 1);

            event.getChannel().send().message(App.INSTANCE.getLangValue("linkTimeoutMessageWarning1"));
            event.getChannel().send().message(".timeout " + event.getUser().getNick() + " " + 1);
        } else {
            int timeoutLength;

            if (warnings.get(event.getUser().getNick()) == 1) {
                warnings.put(event.getUser().getNick(), 2);
                timeoutLength = App.INSTANCE.getSettings().getLinkTimeoutLength1();
            } else {
                timeoutLength = App.INSTANCE.getSettings().getLinkTimeoutLength2();
            }

            event.getChannel().send().message(Utils.replaceVariablesInString(App.INSTANCE.getLangValue
                    ("linkTimeoutMessageWarning2"), Utils.timeConversion(timeoutLength)));
            event.getChannel().send().message(".timeout " + event.getUser().getNick() + " " + timeoutLength);
        }
    }
}
 
开发者ID:RyanTheAllmighty,项目名称:AllmightyBot---Java,代码行数:59,代码来源:LinkListener.java


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