Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Implement user_masks[] option
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed Sep 27, 2015
1 parent e67a276 commit 5a59f0d
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 23 deletions.
18 changes: 16 additions & 2 deletions src/main/java/com/cnaude/purpleirc/PurpleBot.java
Expand Up @@ -155,6 +155,7 @@ public final class PurpleBot {
public String defaultCustomPrefix;
public CaseInsensitiveMap<CaseInsensitiveMap<CaseInsensitiveMap<String>>> commandMap;
public CaseInsensitiveMap<CaseInsensitiveMap<List<String>>> extraCommandMap;
public CaseInsensitiveMap<CaseInsensitiveMap<List<String>>> commandUsermasksMap;
public CaseInsensitiveMap<Long> joinNoticeCooldownMap;
public ArrayList<CommandSender> whoisSenders;
public List<String> channelCmdNotifyRecipients;
Expand Down Expand Up @@ -203,6 +204,7 @@ public PurpleBot(File file, PurpleIRC plugin) {
this.channelCmdNotifyIgnore = new ArrayList<>();
this.commandMap = new CaseInsensitiveMap<>();
this.extraCommandMap = new CaseInsensitiveMap<>();
this.commandUsermasksMap = new CaseInsensitiveMap<>();
this.joinNoticeCooldownMap = new CaseInsensitiveMap<>();
this.enabledMessages = new CaseInsensitiveMap<>();
this.firstOccurrenceReplacements = new CaseInsensitiveMap<>();
Expand Down Expand Up @@ -717,6 +719,7 @@ private boolean loadConfig() {
worldList.clear();
commandMap.clear();
extraCommandMap.clear();
commandUsermasksMap.clear();

channelCmdNotifyEnabled = config.getBoolean("command-notify.enabled", false);
plugin.logDebug(" CommandNotifyEnabled => " + channelCmdNotifyEnabled);
Expand Down Expand Up @@ -980,34 +983,45 @@ private boolean loadConfig() {
// build command map
CaseInsensitiveMap<CaseInsensitiveMap<String>> map = new CaseInsensitiveMap<>();
CaseInsensitiveMap<List<String>> extraMap = new CaseInsensitiveMap<>();
CaseInsensitiveMap<List<String>> userMaskMap = new CaseInsensitiveMap<>();
try {
for (String command : config.getConfigurationSection("channels." + enChannelName + ".commands").getKeys(false)) {
plugin.logDebug(" Command => " + command);
CaseInsensitiveMap<String> optionPair = new CaseInsensitiveMap<>();
List<String> extraCommands = new ArrayList<>();
List<String> userMasks = new ArrayList<>();
String commandKey = "channels." + enChannelName + ".commands." + command + ".";

optionPair.put("modes", config.getString(commandKey + "modes", "*"));
optionPair.put("private", config.getString(commandKey + "private", "false"));
optionPair.put("ctcp", config.getString(commandKey + "ctcp", "false"));
optionPair.put("game_command", config.getString(commandKey + "game_command", ""));
optionPair.put("game_command_usage", config.getString(commandKey + "game_command_usage", ""));
optionPair.put("sender", config.getString(commandKey + "sender", "CONSOLE"));
extraCommands.addAll(config.getStringList(commandKey + "extra_commands"));
plugin.logDebug("extra_commands: " + extraCommands.toString());
optionPair.put("private_listen", config.getString(commandKey + "private_listen", "true"));
optionPair.put("channel_listen", config.getString(commandKey + "channel_listen", "true"));
optionPair.put("perm", config.getString(commandKey + "perm", ""));
for (String s : optionPair.keySet()) {
config.set(commandKey + s, optionPair.get(s));
}

extraCommands.addAll(config.getStringList(commandKey + "extra_commands"));
plugin.logDebug("extra_commands: " + extraCommands.toString());
userMasks.addAll(config.getStringList(commandKey + "user_masks"));
plugin.logDebug("user_masks: " + userMasks.toString());

map.put(command, optionPair);
extraMap.put(command, extraCommands);
userMaskMap.put(command, userMasks);
config.set(commandKey + "extra_commands", extraCommands);
config.set(commandKey + "user_masks", userMasks);
}
} catch (Exception ex) {
plugin.logError("No commands found for channel " + enChannelName);
}
commandMap.put(channelName, map);
extraCommandMap.put(channelName, extraMap);
commandUsermasksMap.put(channelName, userMaskMap);
if (map.isEmpty()) {
plugin.logInfo("No commands specified!");
}
Expand Down
Expand Up @@ -18,7 +18,6 @@

import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.TemplateName;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.Packets;
import com.comphenix.protocol.ProtocolLibrary;
Expand Down
73 changes: 53 additions & 20 deletions src/main/resources/SampleBot.yml
Expand Up @@ -41,7 +41,7 @@ autoconnect: 'false'
password: ''
# identify password (sent to NickServ)
ident-password: ''
# command-prefix - The bot will listen for commands that start with this.
# command-prefix - The bot will listen for commands that start with this.
command-prefix: '.'
# quit-message - Message the bot will send when it quits the server
quit-message: '&r[&5PurpleIRC&r] &rGood bye!'
Expand Down Expand Up @@ -101,12 +101,12 @@ action-commands:
bot-linking-enabled: false
# Map of remote linked bots and codes. Use /irc link and /irc linkaccept
bot-links:
# - remotebot: 249505593790847552435733176657146971496
# - remotebot: 249505593790847552435733176657146971496
# channels - List the channels your bot will join here
channels:
# Channel name must be surrounded by sing quotes to be YAML compliant.
# Use %2E instead of dots in the channel names.
# Example: minecraft%2Etest == minecraft.test
# Example: minecraft%2Etest == minecraft.test
'#minecraft-test':
# message prefix (replaces %CHANNELPREFIX%
prefix: ''
Expand All @@ -122,18 +122,18 @@ channels:
# topic - Channel topic
topic: New topic
# topic-protect - Prevent others from changing the topic
topic-protect: false
topic-protect: false
# Enable chanserve mode for topic set command (/msg chanserv topic #channel <topic>
topic-chanserv: false
# If the Shortify plugin is installed then shoten URLs sent from IRC
shortify: true
# Enable or disable message filtering
enable-filtering: false
# Filters. These wll be removed from IRC to game messages.
filter-list:
filter-list:
- AwesomeBot
# enabled-messages - These are the message types that are either sent to the game or IRC
# config.yml. Remove or comment the messages you don't want.
# config.yml. Remove or comment the messages you don't want.
enabled-messages:
# These messages are sent from game to IRC (see permissions)
- console-chat
Expand All @@ -146,8 +146,8 @@ channels:
- game-achievement
- game-mode
- fake-join
- fake-quit
# Essentials helpop messages (/helpop /amsg /ac)
- fake-quit
# Essentials helpop messages (/helpop /amsg /ac)
- ess-helpop
# Prism
#- prism-rollback
Expand Down Expand Up @@ -178,7 +178,7 @@ channels:
- irc-action-dynmap-web-chat
# mcMMO messages sent to IRC
- mcmmo-admin-chat
- mcmmo-party-chat
- mcmmo-party-chat
- mcmmo-chat
# mcMMO messages sent from IRC. Replace [PARTY] with destination mcMMO party
- irc-mcmmo-admin-chat
Expand Down Expand Up @@ -227,17 +227,17 @@ channels:
#- game-a-chat
# AdminPrivateChat messages IRC to game
#- irc-a-chat
# Hero channel destination for IRC messages
# Hero channel destination for IRC messages
hero-channel: admin
# Towny channel destination for IRC messages
towny-channel: irc
# Log all messages from IRC to HeroChat
# Log all messages from IRC to HeroChat
log-irc-to-hero-chat: false
# ops - IRC hostname mask styled ops list
ops:
ops:
- '*!*sarah@example.com'
# muted - IRC users that should not be heard in game
muted:
muted:
- KuShy
# Set ignore-irc-chat to true if you are using @chat and don't want regular IRC chat in your game
ignore-irc-chat: false
Expand Down Expand Up @@ -295,81 +295,111 @@ channels:
private: false
ctcp: false
game_command: '@chat'
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
ochat:
modes: '*'
private: false
ctcp: false
game_command: '@ochat'
game_command: '@ochat'
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
h:
modes: '*'
private: false
ctcp: false
game_command: '@hchat'
game_command: '@hchat'
extras_commands: []
private_listen: true
channel_listen: true
channel_listen: true
user_masks: []
perm: ''
msg:
modes: '*'
private: true
ctcp: false
game_command: '@msg'
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
list:
modes: '*'
private: false
ctcp: false
game_command: '@list'
game_command: '@list'
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
help:
modes: '*'
private: false
ctcp: false
game_command: '@help'
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
uptime:
modes: '*'
private: false
ctcp: false
game_command: '@uptime'
game_command: '@uptime'
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
version:
modes: '*'
private: false
ctcp: false
game_command: '@versionfull'
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
lag:
modes: '*'
private: false
ctcp: false
game_command: lag
game_command: lag
extras_commands: []
private_listen: true
channel_listen: true
user_masks: []
perm: ''
mb:
modes: 'o'
private: 'false'
ctcp: 'false'
game_command: '@rtsmb'
extras_commands: []
private_listen: 'true'
channel_listen: 'true'
user_masks: []
perm: ''
lv:
modes: 'o'
private: 'false'
ctcp: 'false'
game_command: '@list'
extra_commands:
extra_commands:
- '@version'
private_listen: 'true'
channel_listen: 'true'
user_masks: []
perm: ''
## Uncomment this if you want to hook into AdminPrivateChat
# a:
Expand All @@ -379,6 +409,7 @@ channels:
# game_command: '@a'
# private_listen: true
# channel_listen: true
# user_masks: []
## Uncomment this to allow gamemode changes via IRC
# gamemode:
# modes: 'o'
Expand All @@ -387,6 +418,7 @@ channels:
# game_command: 'gamemode %ARGS%'
# private_listen: true
# channel_listen: true
# user_masks: []
## Sample of %ARGX% and %ARGX+% with game_command_usage
# mute:
# modes: o
Expand All @@ -400,3 +432,4 @@ channels:
# channel_listen: 'true'
# perm: ''
# sender: CONSOLE
# user_masks: []

0 comments on commit 5a59f0d

Please sign in to comment.