本文整理汇总了Java中org.pircbotx.hooks.types.GenericMessageEvent.getBot方法的典型用法代码示例。如果您正苦于以下问题:Java GenericMessageEvent.getBot方法的具体用法?Java GenericMessageEvent.getBot怎么用?Java GenericMessageEvent.getBot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.hooks.types.GenericMessageEvent
的用法示例。
在下文中一共展示了GenericMessageEvent.getBot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGenericMessage
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public void onGenericMessage(GenericMessageEvent<AgarBot> event)
throws IOException {
AgarBot bot = event.getBot();
String message = event.getMessage();
if (!Utils.isTrigger(message, "con ")
|| !bot.getSpam().check(event.getUser())) {
return;
}
String username = message.substring(5).toLowerCase();
ConnectInfo info = getInfo(username);
if (info.username == null) {
Utils.reply(event, NO_USER + username);
} else if (!info.hasImg) {
Utils.reply(event, NO_IMG + username);
} else {
Utils.reply(event, String.format(INFO, username, URLEncoder.encode(username, "UTF-8")));
}
}
示例2: addNick
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
private void addNick(GenericMessageEvent<AgarBot> event, List<String> args) {
if (args.size() < 4) {
return;
}
int level = getLevel(args);
if (level == -1) {
return;
}
String regex = args.get(3);
Pattern pattern = getPattern(regex);
if (pattern == null) {
return;
}
String reason = args.size() > 4 ? args.get(4) : DEFAULT_MSG;
badnicks.put(pattern, new Data(reason, level));
event.getUser().send().message(ADDED + regex);
writeBadnicks();
AgarBot bot = event.getBot();
bot.getUserChannelDao().getAllChannels().forEach(channel -> {
channel.getUsers().forEach(user -> handleNick(bot, user, channel));
});
}
示例3: onCommand
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public void onCommand(GenericMessageEvent event, CallInfo callInfo, String[] args) {
if (args.length < 1) {
event.respond("Not enough arguments.");
return;
}
final String channel = args[0];
if (!channel.startsWith("#")) {
event.respond("Channel did not start with \"#\".");
return;
}
final PircBotX bot = event.getBot();
final Channel c = bot.getUserChannelDao().getChannel(args[0]);
if (!bot.getUserBot().getChannels().contains(c)) {
event.respond("Not in that channel!");
return;
}
if (args.length > 1) c.send().part(StringUtils.join(args, ' ', 1, args.length));
else c.send().part();
event.respond("Parted from " + channel + ".");
}
示例4: onGenericMessage
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public void onGenericMessage(GenericMessageEvent<AgarBot> event) {
AgarBot bot = event.getBot();
if (Utils.isTrigger(event.getMessage(), "quit")
&& bot.getAuth().checkLevel(event.getUser(), AuthLevel.ADMIN)) {
bot.stopBotReconnect();
bot.sendIRC().quitServer();
}
}
示例5: 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);
}
}
示例6: onGenericMessage
import org.pircbotx.hooks.types.GenericMessageEvent; //导入方法依赖的package包/类
@Override
public void onGenericMessage(GenericMessageEvent<AgarBot> event)
throws IOException {
Matcher match = LINK_PATTERN.matcher(event.getMessage());
AgarBot bot = event.getBot();
if (!match.find() || !bot.getSpam().check(event.getUser())) {
return;
}
YoutubeInfo info =
getInfo(match.group(1), bot.getConfig().getGoogleApi());
if (info != null && !info.getItems().isEmpty()) {
Utils.reply(event, formatInfo(info));
}
}