本文整理汇总了Java中org.pircbotx.hooks.types.GenericMessageEvent.getUser方法的典型用法代码示例。如果您正苦于以下问题:Java GenericMessageEvent.getUser方法的具体用法?Java GenericMessageEvent.getUser怎么用?Java GenericMessageEvent.getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.hooks.types.GenericMessageEvent
的用法示例。
在下文中一共展示了GenericMessageEvent.getUser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSpam
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@SneakyThrows(ExecutionException.class)
private boolean checkSpam(Event<AgarBot> event) {
if (!(event instanceof GenericMessageEvent)) {
return false;
}
@SuppressWarnings("rawtypes") GenericMessageEvent message =
(GenericMessageEvent) event;
User user = message.getUser();
if (user.getNick().equalsIgnoreCase("nickserv")) {
return false;
}
String host = user.getHostmask();
int strikes = spam.get(host, () -> 0) + 1;
spam.put(host, strikes);
return strikes > STRIKES;
}
示例2: executeCommand
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的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!");
}
示例3: executeCommand
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
StringBuilder sb = new StringBuilder("Testing ");
sb.append(StringUtils.getArgs(cmd)).append(": ");
int random = MathUtils.getRandom(0, CHECK_MATH_MAX);
String result;
if (random < CHECK_MATH_PANIC) {
result = Colors.WHITE + "[" + Colors.YELLOW + "PANIC" + Colors.WHITE + "]";
} else if (random < CHECK_MATH_FAIL) {
result = Colors.WHITE + "[" + Colors.RED + "FAIL" + Colors.WHITE + "]";
} else {
result = Colors.WHITE + "[" + Colors.GREEN + "PASS" + Colors.WHITE + "]";
}
sb.append(result);
return new BotResponse(BotIntention.CHAT, event.getUser(), sb.toString());
}
示例4: onGenericMessage
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public void onGenericMessage(GenericMessageEvent<AgarBot> event) {
AgarBot bot = event.getBot();
String message = event.getMessage();
User user = event.getUser();
if (Utils.isTrigger(message, "raw ")
&& bot.getAuth().checkLevel(user, AuthLevel.ADMIN)) {
String raw = message.substring(5);
event.getBot().sendRaw().rawLineNow(raw);
log.warn("Raw: " + user.getNick() + "@" + user.getHostmask() + ": "
+ raw);
}
}
示例5: listAuth
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
private void listAuth(GenericMessageEvent<AgarBot> event) {
Map<String, AuthLevel> auths = event.getBot().getAuth().listNicks();
User user = event.getUser();
user.send().message(LIST);
auths.forEach((auth, level) -> user.send().message(level + " " + auth));
user.send().message(LIST_END);
}
示例6: executeCommand
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
if (event instanceof MessageEvent) {
MessageEvent messageEvent = (MessageEvent) event;
if (cmd.length > 2 && IRCUtils.userIsInChannel(messageEvent, cmd[1])) {
String actualNickname = IRCUtils.getActualNickname(cmd[1], event);
return new BotResponse(BotIntention.CHAT, null, actualNickname + ": "
+ StringUtils.getArgsOverOne(cmd));
}
}
return new BotResponse(BotIntention.HIGHLIGHT, event.getUser(), "!give <user> <text|command>");
}
示例7: executeCommand
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
if (event instanceof MessageEvent) {
Channel channel = ((MessageEvent) event).getChannel();
ImmutableSortedSet<User> users = channel.getUsers();
String victimName = "";
int totalUsers = users.size();
Random random = new Random();
int victimIndex = random.nextInt(totalUsers);
int i = 0;
for (User u : users) {
if (i < victimIndex) {
i++;
} else if (i == victimIndex) {
victimName = u.getNick();
break;
}
}
String message;
if (MathUtils.getRandom(0, DICE_MATH_MAX) < DICE_MATH_MID) {
message = Colors.WHITE + "rolls a huge " + totalUsers + " sided die and it flattens "
+ Colors.YELLOW + victimName + Colors.WHITE + " before coming to a halt on "
+ Colors.RED + "YOU LOSE" + Colors.NORMAL;
} else {
message = Colors.WHITE + "rolls a huge " + totalUsers + " sided die and it lands near "
+ Colors.YELLOW + victimName + Colors.WHITE + " before coming to a halt on "
+ Colors.GREEN + "YOU WIN" + Colors.NORMAL;
}
return new BotResponse(BotIntention.ME, null, message);
} else {
return new BotResponse(BotIntention.PRIVATE_MESSAGE, event.getUser(),
butt.getYamlConfigurationFile().getBotName() + " can't roll no dice here");
}
}
示例8: executeCommand
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
String message = StringUtils.getArgs(cmd);
Integer karma = butt.getKarmaTable().getKarmaLevel(message);
if (karma != null) {
return new BotResponse(BotIntention.HIGHLIGHT, event.getUser(), message + " has a karma level of " + karma);
} else {
return new BotResponse(BotIntention.HIGHLIGHT, event.getUser(), message + " has no karma level yet");
}
}
示例9: executeCommand
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
/**
* This is akin to the executeCommand function in the Command interface, although that
* won't work with this because there is no actual command - it's all one string.
* @param butt The IRCbutt instance.
* @param event The MessageEvent from PircBotX.
* @param command The command from the user.
* @return The bot's response, which in this case is a string that has been searched and replaced.
*/
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String command) {
if (butt.getChatStorage().hasQuoteFrom(event.getUser().getNick())) {
String replaced = searchAndReplace(command,
butt.getChatStorage().getLastQuoteFrom(event.getUser().getNick()));
return new BotResponse(BotIntention.CHAT, null, replaced);
} else {
return new BotResponse(BotIntention.HIGHLIGHT, event.getUser(), "butt dont see any message from you");
}
}