本文整理汇总了Java中org.pircbotx.Channel.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.getName方法的具体用法?Java Channel.getName怎么用?Java Channel.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.Channel
的用法示例。
在下文中一共展示了Channel.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCommand
import org.pircbotx.Channel; //导入方法依赖的package包/类
@Override
public void onCommand(PircBotX bot, User user, Channel channel, List<String> lines, String... args) {
if (args.length < 2) {
lines.add("This command requires at least two args.");
return;
}
String message = Joiner.on(' ').join(args);
TellMessage send = new TellMessage(args[0], message, channel.getName(), user.getNick());
if (!tells.containsValue(send)) {
tells.put(send.getSendTo(), send);
MessageSender.INSTANCE.enqueueNotice(bot, user.getNick(), "I'll pass that along.");
} else {
MessageSender.INSTANCE.enqueueNotice(bot, user.getNick(), "I can't let you do that.");
}
}
示例2: onCommand
import org.pircbotx.Channel; //导入方法依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
String channelname = null;
if(!isPrivate){ channelname = prefix + channel.getName(); } else { channelname = user.getNick(); }
if(args.length > 1 && args[0].startsWith("#")){channelname = args[0]; args=ArrayUtils.remove(args,0); }
if (command.equalsIgnoreCase("act") || command.equalsIgnoreCase("do") || command.equalsIgnoreCase("a")) {
Registry.messageQueue.get(network).add("PRIVMSG " + channelname + " :\u0001ACTION " + StringUtils.join(args," ") + "\u0001");
} else if (command.equalsIgnoreCase("prism")) {
Registry.messageQueue.get(network).add("PRIVMSG " + channelname + " :" + GeneralUtils.prism(StringUtils.join(args," ")));
} else {
if(args.length > 1 && !Character.isLetterOrDigit(args[0].charAt(0)) && args[0].charAt(1) == "#".charAt(0)){
channelname = args[0]; args = ArrayUtils.remove(args,0);
}
Registry.messageQueue.get(network).add("PRIVMSG " + channelname + " :" + StringUtils.join(args," "));
}
}
示例3: onCommand
import org.pircbotx.Channel; //导入方法依赖的package包/类
@Override
public void onCommand(PircBotX bot, User user, Channel channel, List<String> lines, String... args) {
if ((channel != null && channel.getName().equals(this.channel)) || this.channel == null) {
String to = channel == null ? user.getNick() : channel.getName();
String msg = IRCUtils.getMessageWithArgs(user, message, args);
if (this.isAction) {
MessageSender.INSTANCE.enqueueAction(bot, to, msg);
} else {
MessageSender.INSTANCE.enqueue(bot, channel == null ? user.getNick() : channel.getName(), IRCUtils.getMessageWithArgs(user, message, args));
}
}
}
示例4: getLine
import org.pircbotx.Channel; //导入方法依赖的package包/类
public Line getLine(Channel channel, int id) {
Line line = manager.app.databaseManager.get(Line.class, id);
String server = channel.<Bot>getBot().manager.name;
String channelName = channel.getName();
return line.server.equals(server) && line.channel.equals(channelName) ? line : null;
}
示例5: onCommand
import org.pircbotx.Channel; //导入方法依赖的package包/类
@Override
public void onCommand(PircBotX bot, User user, Channel channel, List<String> lines, String... args) {
boolean global = false;
boolean action = false;
PermLevel level = PermLevel.DEFAULT;
if (args.length > 0) {
while (args[0].startsWith("-")) {
global |= args[0].equalsIgnoreCase("-global");
action |= args[0].equalsIgnoreCase("-action");
if (args[0].toLowerCase().contains("-permlevel=")) {
String levelStr = args[0].split("=")[1];
try {
level = PermLevel.valueOf(levelStr.toUpperCase(Locale.ENGLISH));
} catch (Exception e) {
lines.add(levelStr + " is not a valid perm level. Using default.");
}
}
args = ArrayUtils.remove(args, 0);
}
}
if (args.length < 2) {
lines.add("This requires at least two args, [command name] and [message]!");
return;
}
String cmdName = args[0];
args = ArrayUtils.remove(args, 0);
String toAdd = StringUtils.join(args, ' ');
CustomCommand command = null;
if (global && PermRegistry.INSTANCE.isController(user)) {
command = new CustomCommand(cmdName, level, toAdd);
} else if (global) {
lines.add("You must be a controller to add global commands!");
return;
} else if (channel != null) {
command = new CustomCommand(cmdName, level, toAdd, channel.getName());
} else {
lines.add("You cannot add non-global commands in private message!");
return;
}
command.setIsAction(action);
commandsAdded.add(command);
lines.add("Registered " + (global ? "global " : "") + "command " + cmdName);
}
示例6: onCommand
import org.pircbotx.Channel; //导入方法依赖的package包/类
@Override
public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
String chan = null;
String net = null;
boolean isAction = false;
boolean isModify = false;
boolean isDelete = false;
if (args[0].equalsIgnoreCase(".")) {
net = IRCUtils.getNetworkNameByNetwork(network);
chan = channel.getName();
args = ArrayUtils.remove(args, 0);
}
if (command.equalsIgnoreCase("cact") || command.equalsIgnoreCase("customact")) {
isAction = true;
}
String cCommand;
if (args[0].startsWith("+")) {
cCommand = args[0].replaceFirst("\\+", "");
isModify = true;
} else if (args[0].startsWith("-")) {
cCommand = args[0].replaceFirst("\\-", "");
isDelete = true;
} else {
cCommand = args[0];
}
cCommand = cCommand.toLowerCase();
Record customCommand = DatabaseUtils.getChannelCustomCommand(net, chan, cCommand);
if (isModify && customCommand != null && userPermLevel >= customCommand.getValue(CUSTOMCOMMANDS.PERMLEVEL) && !customCommand.getValue(CUSTOMCOMMANDS.ISLOCKED)) {
customCommand.setValue(CUSTOMCOMMANDS.PERMLEVEL, Integer.parseInt(args[1]));
customCommand.setValue(CUSTOMCOMMANDS.ISACTION, isAction);
customCommand.setValue(CUSTOMCOMMANDS.VALUE, GeneralUtils.buildMessage(2, args.length, args).replace("\n", " "));
DatabaseUtils.updateCustomCommand(customCommand);
IRCUtils.sendMessage(user, network, channel, "Custom Command modified", prefix);
} else if (isDelete && customCommand != null && userPermLevel >= customCommand.getValue(CUSTOMCOMMANDS.PERMLEVEL) && !customCommand.getValue(CUSTOMCOMMANDS.ISLOCKED)) {
DatabaseUtils.removeCustomCommand(net, chan, cCommand);
IRCUtils.sendMessage(user, network, channel, "Custom Command removed", prefix);
} else if (customCommand == null && Registry.ircCommands.get(cCommand) == null && !isDelete && !isModify) {
DatabaseUtils.addCustomCommand(net, chan, cCommand, Integer.parseInt(args[1]), GeneralUtils.buildMessage(2, args.length, args).replace("\n", " "), false, isAction);
IRCUtils.sendMessage(user, network, channel, "Custom Command added", prefix);
} else {
IRCUtils.sendError(user, network, channel, "Command already exists (If you were adding) or Command does not exist, or The command is locked (Either could be the problem if you were modifying)", prefix);
}
}