本文整理汇总了Java中org.pircbotx.hooks.events.PrivateMessageEvent.respond方法的典型用法代码示例。如果您正苦于以下问题:Java PrivateMessageEvent.respond方法的具体用法?Java PrivateMessageEvent.respond怎么用?Java PrivateMessageEvent.respond使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.hooks.events.PrivateMessageEvent
的用法示例。
在下文中一共展示了PrivateMessageEvent.respond方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: exePrivate
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
public void exePrivate(PrivateMessageEvent event, String[] args) throws Exception {
int rateScale = 5;
try{
rateScale = Integer.parseInt(args[args.length - 1]);
event.respond("I rate " + Utils.arrayToString(Utils.trimArray(args, 1)) + " a " + Utils.getRandomNumber(rateScale, false) + " out of " + rateScale + ".");
}catch(NumberFormatException e){
event.respond("I rate " + Utils.arrayToString(args) + " a " + Utils.getRandomNumber(5, false) + " out of 5.");
}
}
示例8: exePrivate
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
public void exePrivate(PrivateMessageEvent event, String[] args) throws Exception {
String song = Utils.arrayToString(Utils.trimArray(args, 0));
for(int i = 0; i < FileUtils.getNumberOfLinesInFile(linkFilePath); i++) {
if(FileUtils.readLineFromFile(linkFilePath, i + 1).startsWith(song)) {
event.respond("Enjoy! " + FileUtils.readLineFromFile(linkFilePath, i + 1).replace(song + " | ", ""));
break;
}
}
}
示例9: exePrivate
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
public void exePrivate(PrivateMessageEvent event, String[] args) throws Exception {
if(args.length > 0) {
event.respond("This command doesn't use any parameters!");
return;
}
int numberOfResponses = FileUtils.getNumberOfLinesInFile(quotesFilePath);
Utils.sendMessage(event, FileUtils.readLineFromFile(quotesFilePath, Utils.getRandomNumber(numberOfResponses, true)));
}
示例10: exePrivate
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
public void exePrivate(PrivateMessageEvent event, String[] args) throws Exception {
String target = Utils.arrayToString(Utils.trimArray(args, 0));
int numberOfResponses = FileUtils.getNumberOfLinesInFile(responseFilePath);
String response = FileUtils.readLineFromFile(responseFilePath, Utils.getRandomNumber(numberOfResponses, true)).replaceAll("#C", target.substring(0, 1).toUpperCase() + target.substring(1)).replaceAll("#", target);
event.respond(response);
}
示例11: onPrivateMessage
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
/**
* This is 80% duplicated code from the onMessage function.
* This allows it to respond as expected to a private query.
* There is no parseInvite, and neural network queries don't need to be prepended
* TODO: don't duplicate code...
* @param event PrivateMessageEvent received by the bot
*/
@Override
public void onPrivateMessage(PrivateMessageEvent event) {
if( parseRemind(event) || parsePing(event) || parseSource(event)) return;
String query = event.getMessage();
if (!query.isEmpty()) {
query = Swiggityspeare_utils.trimNick(query, bot_nick); //trim off `swiggityspeare` from input
if(include_nick_in_query) query = event.getUser().getNick() + ": " + query;
String response = Swiggityspeare_utils.getString(query, neuralNetworkDirectory, neuralNetworkFile);
event.respond(response);
}
}
示例12: 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!");
}
示例13: 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 + ".");
}
示例14: exePrivate
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
public void exePrivate(PrivateMessageEvent event, String[] args) throws Exception {
if(args.length == 0){
event.respond("Here's a " + Reference.cookieTypes[Utils.getRandomNumber(Reference.cookieTypes.length, true)] + " cookie for you!");
}
}
示例15: exePrivate
import org.pircbotx.hooks.events.PrivateMessageEvent; //导入方法依赖的package包/类
public void exePrivate(PrivateMessageEvent event, String[] args) throws Exception {
if(args.length == 0){
event.respond("Sorry, I don't have an official help command yet. You can find a temporary listing of all the commands at https://www.github.com/Geforce132/Geffy");
}
}