本文整理汇总了Java中org.pircbotx.hooks.events.PrivateMessageEvent.getUser方法的典型用法代码示例。如果您正苦于以下问题:Java PrivateMessageEvent.getUser方法的具体用法?Java PrivateMessageEvent.getUser怎么用?Java PrivateMessageEvent.getUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.hooks.events.PrivateMessageEvent
的用法示例。
在下文中一共展示了PrivateMessageEvent.getUser方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("raw")) return;
final User u = e.getUser();
if (!PermissionHandler.isAuthedOrAdmin(u.getNick(), u.getServer())) {
e.respond("You are not allowed to do this.");
return;
}
String[] args = e.getMessage().trim().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1) {
e.respond("Usage: raw [command]");
return;
}
String rawCommand = StringUtils.join(args, " ");
e.getBot().sendRaw().rawLine(rawCommand);
e.respond("Attempted to send raw IRC line: " + rawCommand);
}
示例2: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("command")) return;
final User u = e.getUser();
if (!PermissionHandler.isAuthedOrAdmin(u.getNick(), u.getServer())) {
e.respond("You are not allowed to do this.");
return;
}
String[] args = e.getMessage().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1) {
e.respond("Usage: command [command]");
return;
}
final String commandToSend = StringUtils.join(args, " ").trim();
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), commandToSend);
e.respond("Sent command to server: /" + commandToSend);
}
示例3: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("privmsg")) return;
final User u = e.getUser();
if (!PermissionHandler.isAuthedOrAdmin(u.getNick(), u.getServer())) {
e.respond("You are not allowed to do this.");
return;
}
String[] args = e.getMessage().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 2) {
e.respond("Usage: privmsg [user] [message]");
return;
}
String sendTo = args[0];
String message = StringUtils.join(args, " ", 1, args.length);
final User t = e.getBot().getUserChannelDao().getUser(sendTo);
t.send().message(message);
e.respond("Sent message \"" + message + "\" to " + t.getNick() + ".");
}
示例4: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
if (!e.getMessage().trim().split(" ")[0].equalsIgnoreCase("message")) return;
final User u = e.getUser();
String[] args = e.getMessage().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 2) {
e.respond("Usage: message [name] [message]");
return;
}
final String target = args[0];
String message = StringUtils.join(args, " ", 1, args.length);
final Player t = plugin.getServer().getPlayer(target);
if (t == null) {
e.respond("No such player.");
return;
}
if (Config.allowColors) message = RUtils.ircColorsToMinecraftColors(message);
else message = Colors.removeFormattingAndColors(message);
String send = Config.ituMessage;
send = send.replace("{server}", e.getBot().getServerInfo().getServerName());
send = send.replace("{name}", u.getNick());
send = send.replace("{message}", message);
t.sendMessage(send);
}
示例5: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("deauthenticate")) return;
final User u = e.getUser();
if (!PermissionHandler.atLeastMod(u.getNick())) {
e.respond("You are not allowed to do this.");
return;
}
if (!PermissionHandler.isAuthenticated(u.getNick(), u.getServer())) {
e.respond("Not authenticated!");
return;
}
PermissionHandler.setAuthenticated(e.getUser().getNick(), e.getUser().getServer(), false);
e.respond("Deuthenticated!");
}
示例6: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("join")) return;
final User u = e.getUser();
if (!PermissionHandler.isAuthedOrAdmin(u.getNick(), u.getServer())) {
e.respond("You are not allowed to do this.");
return;
}
String[] args = e.getMessage().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1) {
e.respond("Usage: join [channel]");
return;
}
final String channel = args[0];
if (!channel.startsWith("#")) {
e.respond("Channel must start with \"#\" to be valid!");
return;
}
e.getBot().sendIRC().joinChannel(channel);
e.respond("Attempted to join channel " + channel + ".");
}
示例7: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("authenticate")) return;
final User u = e.getUser();
if (!PermissionHandler.atLeastMod(u.getNick())) {
e.respond("You are not allowed to do this.");
return;
}
String[] args = e.getMessage().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1) {
e.respond("Usage: authenticate [key]");
return;
}
final String salt = plugin.getConfig().getString("settings.auth.keys.salt", "");
String key;
try {
key = hash(StringUtils.join(args, " ") + salt);
} catch (NoSuchAlgorithmException ex) {
e.respond("Internal exception: " + ex.getMessage());
return;
}
final String checkAgainst = plugin.getConfig().getString("settings.auth.keys.users." + u.getNick(), "");
if (checkAgainst.isEmpty()) {
e.respond("There is no key stored for you!");
return;
}
if (!checkAgainst.equals(key)) {
e.respond("Invalid key!");
return;
}
PermissionHandler.setAuthenticated(u.getNick(), u.getServer(), true);
e.respond("Authenticated!");
}
示例8: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
@Override
public void onPrivateMessage(PrivateMessageEvent e) {
final String command = RUtils.getFirstWord(e.getMessage());
if (!command.equalsIgnoreCase("part")) return;
final User u = e.getUser();
if (!PermissionHandler.isAuthedOrAdmin(u.getNick(), u.getServer())) {
e.respond("You are not allowed to do this.");
return;
}
String[] args = e.getMessage().split(" ");
args = (String[]) ArrayUtils.subarray(args, 1, args.length);
if (args.length < 1) {
e.respond("Usage: part [channel]");
return;
}
final String channel = args[0];
if (!channel.startsWith("#")) {
e.respond("Channel must start with \"#\" to be valid!");
return;
}
Channel c = null;
for (Channel ch : e.getBot().getUserBot().getChannels()) {
if (!ch.getName().equalsIgnoreCase(channel)) continue;
c = ch;
break;
}
if (c == null) {
e.respond("Not in that channel.");
return;
}
c.send().part();
e.respond("Attempted to part channel " + channel + ".");
}