chat filter: add clan chat
This commit is contained in:
@@ -110,11 +110,22 @@ public interface ChatFilterConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "filterClanChat",
|
||||
name = "Filter clan Chat Members",
|
||||
description = "Filter your clan chat members' messages",
|
||||
position = 7
|
||||
)
|
||||
default boolean filterClanChat()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "filterLogin",
|
||||
name = "Filter Logged In/Out Messages",
|
||||
description = "Filter your private chat to remove logged in/out messages",
|
||||
position = 7
|
||||
position = 8
|
||||
)
|
||||
default boolean filterLogin()
|
||||
{
|
||||
@@ -125,7 +136,7 @@ public interface ChatFilterConfig extends Config
|
||||
keyName = "filterGameChat",
|
||||
name = "Filter Game Chat",
|
||||
description = "Filter your game chat messages",
|
||||
position = 8
|
||||
position = 9
|
||||
)
|
||||
default boolean filterGameChat()
|
||||
{
|
||||
@@ -136,7 +147,7 @@ public interface ChatFilterConfig extends Config
|
||||
keyName = "collapseGameChat",
|
||||
name = "Collapse Game Chat",
|
||||
description = "Collapse duplicate game chat messages into a single line",
|
||||
position = 9
|
||||
position = 10
|
||||
)
|
||||
default boolean collapseGameChat()
|
||||
{
|
||||
@@ -147,7 +158,7 @@ public interface ChatFilterConfig extends Config
|
||||
keyName = "collapsePlayerChat",
|
||||
name = "Collapse Player Chat",
|
||||
description = "Collapse duplicate player chat messages into a single line",
|
||||
position = 10
|
||||
position = 11
|
||||
)
|
||||
default boolean collapsePlayerChat()
|
||||
{
|
||||
@@ -158,7 +169,7 @@ public interface ChatFilterConfig extends Config
|
||||
keyName = "maxRepeatedPublicChats",
|
||||
name = "Repeat filter",
|
||||
description = "Block player chat message if repeated this many times. 0 is off",
|
||||
position = 11
|
||||
position = 12
|
||||
)
|
||||
default int maxRepeatedPublicChats()
|
||||
{
|
||||
|
||||
@@ -53,6 +53,7 @@ import net.runelite.api.Client;
|
||||
import net.runelite.api.FriendsChatManager;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.clan.ClanChannel;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.OverheadTextChanged;
|
||||
import net.runelite.api.events.ScriptCallbackEvent;
|
||||
@@ -170,6 +171,8 @@ public class ChatFilterPlugin extends Plugin
|
||||
case PRIVATECHAT:
|
||||
case MODPRIVATECHAT:
|
||||
case FRIENDSCHAT:
|
||||
case CLAN_CHAT:
|
||||
case CLAN_GUEST_CHAT:
|
||||
if (shouldFilterPlayerMessage(Text.removeTags(name)))
|
||||
{
|
||||
message = censorMessage(name, message);
|
||||
@@ -271,7 +274,8 @@ public class ChatFilterPlugin extends Plugin
|
||||
boolean isMessageFromSelf = playerName.equals(client.getLocalPlayer().getName());
|
||||
return !isMessageFromSelf &&
|
||||
(config.filterFriends() || !client.isFriended(playerName, false)) &&
|
||||
(config.filterFriendsChat() || !isFriendsChatMember(playerName));
|
||||
(config.filterFriendsChat() || !isFriendsChatMember(playerName)) &&
|
||||
(config.filterClanChat() || !isClanChatMember(playerName));
|
||||
}
|
||||
|
||||
private boolean isFriendsChatMember(String name)
|
||||
@@ -280,6 +284,23 @@ public class ChatFilterPlugin extends Plugin
|
||||
return friendsChatManager != null && friendsChatManager.findByName(name) != null;
|
||||
}
|
||||
|
||||
private boolean isClanChatMember(String name)
|
||||
{
|
||||
ClanChannel clanChannel = client.getClanChannel();
|
||||
if (clanChannel != null && clanChannel.findMember(name) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
clanChannel = client.getGuestClanChannel();
|
||||
if (clanChannel != null && clanChannel.findMember(name) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
String censorMessage(final String username, final String message)
|
||||
{
|
||||
String strippedMessage = jagexPrintableCharMatcher.retainFrom(message)
|
||||
|
||||
Reference in New Issue
Block a user