Browse Source

Fixed rules being able to be added by anyone.

Fixed rules not checking channel access.
Fixed privalege being added for nick in all channels when message type was for a channel.
Added handling of exceptions for Mysql database.
tags/3.0.5
Teknikode 4 years ago
parent
commit
968e7649e7

+ 25
- 6
Combot/Bot.cs View File

@@ -571,15 +571,34 @@ namespace Combot
CommandMessage newCommand = new CommandMessage();
newCommand.Nick.Copy(sender);
bool nickFound = false;
IRC.Channels.ForEach(channel => channel.Nicks.ForEach(nick =>
if (messageType == MessageType.Channel)
{
if (nick.Nickname == newCommand.Nick.Nickname)
Channel foundChannel = IRC.Channels.Find(chan => chan.Name == location);
if (foundChannel != null)
{
nickFound = true;
newCommand.Nick.AddModes(nick.Modes);
newCommand.Nick.AddPrivileges(nick.Privileges);
foundChannel.Nicks.ForEach(nick =>
{
if (nick.Nickname == newCommand.Nick.Nickname)
{
nickFound = true;
newCommand.Nick.AddModes(nick.Modes);
newCommand.Nick.AddPrivileges(nick.Privileges);
}
});
}
}));
}
else
{
IRC.Channels.ForEach(channel => channel.Nicks.ForEach(nick =>
{
if (nick.Nickname == newCommand.Nick.Nickname)
{
nickFound = true;
newCommand.Nick.AddModes(nick.Modes);
newCommand.Nick.AddPrivileges(nick.Privileges);
}
}));
}
// Nickname has not been found, so need to run a query for nick's modes
if (!nickFound)
{

+ 21
- 0
Combot/Databases/Database.cs View File

@@ -50,6 +50,13 @@ namespace Combot.Databases
MysqlErrorEvent(this, exception.Message);
}
}
catch (Exception exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
DatabaseLock.ExitWriteLock();
}
return rows;
@@ -74,6 +81,13 @@ namespace Combot.Databases
MysqlErrorEvent(this, exception.Message);
}
}
catch (Exception exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
DatabaseLock.ExitWriteLock();
return result;
}
@@ -98,6 +112,13 @@ namespace Combot.Databases
MysqlErrorEvent(this, exception.Message);
}
}
catch (Exception exception)
{
if (MysqlErrorEvent != null)
{
MysqlErrorEvent(this, exception.Message);
}
}
DatabaseLock.ExitWriteLock();
}
}

+ 21
- 17
Modules/Channel Rules/Channel_Rules.cs View File

@@ -14,12 +14,28 @@ namespace Combot.Modules.Plugins

public override void ParseCommand(CommandMessage command)
{
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location;
Command foundCommand = Commands.Find(c => c.Triggers.Contains(command.Command));
switch (foundCommand.Name)
{
case "Rules":
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location;
if (command.Arguments.ContainsKey("Action"))
case "Rules Display":
List<Dictionary<string, object>> foundRules = GetRuleList(channel);
if (foundRules.Any())
{
int index = 1;
foundRules.ForEach(rule =>
{
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("Rule \u0002#{0}\u0002: {1}", index, rule["rule"]));
index++;
});
}
else
{
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("There are no rules for \u0002{0}\u0002", channel));
}
break;
case "Rules Modification":
if (Bot.CheckChannelAccess(channel, command.Nick.Nickname, command.Access))
{
string action = command.Arguments["Action"].ToString();
switch (action.ToLower())
@@ -37,20 +53,8 @@ namespace Combot.Modules.Plugins
}
else
{
List<Dictionary<string, object>> foundRules = GetRuleList(channel);
if (foundRules.Any())
{
int index = 1;
foundRules.ForEach(rule =>
{
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("Rule \u0002#{0}\u0002: {1}", index, rule["rule"]));
index++;
});
}
else
{
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("There are no rules for \u0002{0}\u0002", channel));
}
string noAccessMessage = string.Format("You do not have access to \u0002{0}\u000F on \u0002{1}\u000F.", command.Command, channel);
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, noAccessMessage);
}
break;
}

+ 41
- 6
Modules/Channel Rules/Module.config View File

@@ -6,7 +6,7 @@
"NickBlacklist": [],
"Commands": [
{
"Name": "Rules",
"Name": "Rules Display",
"Description": "Displays the rules for a given channel.",
"Enabled": true,
"ChannelBlacklist": [],
@@ -14,6 +14,45 @@
"Triggers": [
"rules"
],
"Arguments": [
{
"Name": "Channel",
"Description": "The channel the rules are for.",
"AllowedValues": [],
"DependentArguments": [],
"MessageTypes": [
1,
2
],
"Required": true
}
],
"AllowedMessageTypes": [
0,
1,
2
],
"AllowedAccess": [
0,
1,
2,
3,
4,
5,
6
],
"ShowHelp": true,
"SpamCheck": true
},
{
"Name": "Rules Modification",
"Description": "Displays the rules for a given channel.",
"Enabled": true,
"ChannelBlacklist": [],
"NickBlacklist": [],
"Triggers": [
"rule"
],
"Arguments": [
{
"Name": "Channel",
@@ -39,7 +78,7 @@
1,
2
],
"Required": false
"Required": true
},
{
"Name": "ID",
@@ -88,10 +127,6 @@
2
],
"AllowedAccess": [
0,
1,
2,
3,
4,
5,
6

Loading…
Cancel
Save