mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-18 16:15:19 +01:00
Irc mute now handles user masks.
This commit is contained in:
parent
8dff546768
commit
52a3e9bedb
@ -20,6 +20,8 @@ import com.cnaude.purpleirc.PurpleIRC;
|
||||
import com.cnaude.purpleirc.Utilities.BotsAndChannels;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.pircbotx.Channel;
|
||||
import org.pircbotx.User;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -65,7 +67,24 @@ public class Mute implements IRCCommandInterface {
|
||||
for (String botName : bac.bot) {
|
||||
for (String channelName : bac.channel) {
|
||||
for (int i = idx; i < args.length; i++) {
|
||||
plugin.ircBots.get(botName).mute(channelName, sender, args[i]);
|
||||
|
||||
String nick = args[i];
|
||||
String mask = nick;
|
||||
Channel channel = plugin.ircBots.get(botName).getChannel(channelName);
|
||||
if (channel != null) {
|
||||
for (User user : channel.getUsers()) {
|
||||
if (user.getNick().equalsIgnoreCase(nick)) {
|
||||
mask = "*!*" + user.getLogin() + "@" + user.getHostmask();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mask.split("[\\!\\@]", 3).length == 3) {
|
||||
plugin.ircBots.get(botName).mute(channelName, sender, mask);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid user or mask: "
|
||||
+ ChatColor.WHITE + mask);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.cnaude.purpleirc.Events;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
@ -73,10 +73,19 @@ public class IRCMessageHandler {
|
||||
}
|
||||
plugin.logDebug("processMessage: " + message);
|
||||
String channelName = channel.getName();
|
||||
|
||||
for (String userMask : ircBot.muteList.get(channelName)) {
|
||||
if (ircBot.checkUserMask(user, userMask)) {
|
||||
plugin.logDebug("User " + user.getNick() + " matches mute mask " + userMask + ". Ignoring message.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ircBot.muteList.get(channelName).contains(user.getNick())) {
|
||||
plugin.logDebug("User is muted. Ignoring message from " + user.getNick() + ": " + message);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.logDebug("commandPrefix.length(): " + ircBot.commandPrefix.length());
|
||||
String command = message.split(" ")[0];
|
||||
if (command.length() > ircBot.commandPrefix.length()) {
|
||||
|
@ -484,14 +484,14 @@ public final class PurpleBot {
|
||||
*
|
||||
* @param channelName
|
||||
* @param sender
|
||||
* @param user
|
||||
* @param userMask
|
||||
*/
|
||||
public void mute(String channelName, CommandSender sender, String user) {
|
||||
if (muteList.get(channelName).contains(user)) {
|
||||
sender.sendMessage("User '" + user + "' is already muted.");
|
||||
public void mute(String channelName, CommandSender sender, String userMask) {
|
||||
if (muteList.get(channelName).contains(userMask)) {
|
||||
sender.sendMessage("User '" + userMask + "' is already muted.");
|
||||
} else {
|
||||
sender.sendMessage("User '" + user + "' is now muted.");
|
||||
muteList.get(channelName).add(user);
|
||||
sender.sendMessage("User '" + userMask + "' is now muted.");
|
||||
muteList.get(channelName).add(userMask);
|
||||
saveConfig("channels." + encodeChannel(getConfigChannelName(channelName)) + ".muted", muteList.get(channelName));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user