Browse Source

Fixed Update overwriting all modules.

Added check for module enabled on non-command handlers.
Changed version number in About and Version Reply to product version.
Changed Seen where you can only use it in a channel.
tags/3.0.2
Teknikode 4 years ago
parent
commit
7d377cc237

+ 20
- 1
Combot/Bot.cs View File

@@ -297,6 +297,25 @@ namespace Combot
ParseCommandMessage(DateTime.Now, message, new Nick { Nickname = IRC.Nickname }, location, type);
}

public bool IsCommand(string message)
{
bool isCommand = false;
string[] msgArgs = message.Split(new[] {' '}, 2, StringSplitOptions.RemoveEmptyEntries);
string command = msgArgs[0].Remove(0, ServerConfig.CommandPrefix.Length);
// Find the module that contains the command
Module module = Modules.Find(mod => mod.Commands.Exists(c => c.Triggers.Contains(command)) && mod.Loaded && mod.Enabled);
if (module != null)
{
// Find the command
Command cmd = module.Commands.Find(c => c.Triggers.Contains(command));
if (cmd != null)
{
isCommand = true;
}
}
return isCommand;
}

private void HandleJoinEvent(object sender, JoinChannelInfo info)
{
if (info.Nick.Nickname == IRC.Nickname)
@@ -460,7 +479,7 @@ namespace Combot
argsOnly.RemoveAt(0);

// Find the module that contains the command
Module module = Modules.Find(mod => mod.Commands.Exists(c => c.Triggers.Contains(command)) && mod.Loaded);
Module module = Modules.Find(mod => mod.Commands.Exists(c => c.Triggers.Contains(command)) && mod.Loaded && mod.Enabled);
if (module != null)
{
// Find the command

+ 1
- 0
Combot/Modules/Module.cs View File

@@ -155,6 +155,7 @@ namespace Combot.Modules
newModule = (Module)Activator.CreateInstance(t);
newModule.Copy(this);
newModule.Loaded = true;
newModule.ConfigPath = ConfigPath;
newModule.Bot = bot;
newModule.Initialize();
}

+ 5
- 6
Modules/About/About.cs View File

@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Reflection;

namespace Combot.Modules.Plugins
@@ -16,12 +17,10 @@ namespace Combot.Modules.Plugins
switch (foundCommand.Name)
{
case "About":
string ownerNum = " is";
if (Bot.ServerConfig.Owners.Count > 1)
{
ownerNum = "s are";
}
string aboutMessage = string.Format("Combot v{0} is created by Uncled1023. My current owner{1} {2}.", Assembly.GetExecutingAssembly().GetName().Version, ownerNum, string.Join(", ", Bot.ServerConfig.Owners));
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fileVersionInfo.ProductVersion;
string aboutMessage = string.Format("Combot v{0}. Created by Uncled1023. You can find my source at {1}. ", version, GetOptionValue("Source Code"));
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, aboutMessage);
break;
case "Source":

+ 2
- 1
Modules/Introductions/Introductions.cs View File

@@ -42,7 +42,8 @@ namespace Combot.Modules.Plugins

private void HandleJoinEvent(object sender, JoinChannelInfo info)
{
if (!Bot.ServerConfig.ChannelBlacklist.Contains(info.Channel)
if (Enabled
&& !Bot.ServerConfig.ChannelBlacklist.Contains(info.Channel)
&& !Bot.ServerConfig.NickBlacklist.Contains(info.Nick.Nickname)
&& !ChannelBlacklist.Contains(info.Channel)
&& !NickBlacklist.Contains(info.Nick.Nickname))

+ 2
- 1
Modules/Invite/Invite.cs View File

@@ -11,7 +11,8 @@ namespace Combot.Modules.Plugins

private void HandleInvite(object sender, InviteChannelInfo inviteInfo)
{
if (!Bot.ServerConfig.NickBlacklist.Contains(inviteInfo.Requester.Nickname)
if (Enabled
&& !Bot.ServerConfig.NickBlacklist.Contains(inviteInfo.Requester.Nickname)
&& !NickBlacklist.Contains(inviteInfo.Requester.Nickname))
{
if (!Bot.ServerConfig.ChannelBlacklist.Contains(inviteInfo.Channel) && !ChannelBlacklist.Contains(inviteInfo.Channel))

+ 16
- 4
Modules/Messaging/Messaging.cs View File

@@ -33,22 +33,34 @@ namespace Combot.Modules.Plugins

private void HandleChannelMessage(object sender, ChannelMessage message)
{
CheckMessages(message.Sender.Nickname);
if (Enabled)
{
CheckMessages(message.Sender.Nickname);
}
}

private void HandlePrivateMessage(object sender, PrivateMessage message)
{
CheckMessages(message.Sender.Nickname);
if (Enabled)
{
CheckMessages(message.Sender.Nickname);
}
}

private void HandleChannelNotice(object sender, ChannelNotice message)
{
CheckMessages(message.Sender.Nickname);
if (Enabled)
{
CheckMessages(message.Sender.Nickname);
}
}

private void HandlePrivateNotice(object sender, PrivateNotice message)
{
CheckMessages(message.Sender.Nickname);
if (Enabled)
{
CheckMessages(message.Sender.Nickname);
}
}

private void AddMessage(CommandMessage command, bool anonymous = false)

+ 5
- 1
Modules/Owner Control/Owner_Control.cs View File

@@ -199,7 +199,11 @@ namespace Combot.Modules.Plugins
break;
case "Update":
Bot.ServerConfig.Load();
Bot.Modules.ForEach(module => module.LoadConfig());
for (int i = 0; i < Bot.Modules.Count; i++)
{
Bot.Modules[i].LoadConfig();
}
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, "Update Complete");
break;
}
}

+ 2
- 1
Modules/Sed/Sed.cs View File

@@ -16,7 +16,8 @@ namespace Combot.Modules.Plugins

private void HandleChannelMessageEvent(object sender, ChannelMessage message)
{
if (!Bot.ServerConfig.ChannelBlacklist.Contains(message.Channel)
if (Enabled
&& !Bot.ServerConfig.ChannelBlacklist.Contains(message.Channel)
&& !Bot.ServerConfig.NickBlacklist.Contains(message.Sender.Nickname)
&& !ChannelBlacklist.Contains(message.Channel)
&& !NickBlacklist.Contains(message.Sender.Nickname))

+ 2
- 17
Modules/Seen/Module.config View File

@@ -20,28 +20,13 @@
"Description": "The nickname you want to view the information on.",
"AllowedValues": [],
"MessageTypes": [
0,
1,
2
0
],
"Required": true
},
{
"Name": "Channel",
"Description": "The channel you want to get last seen information for.",
"AllowedValues": [],
"MessageTypes": [
0,
1,
2
],
"Required": false
}
],
"AllowedMessageTypes": [
0,
1,
2
0
],
"AllowedAccess": [
0,

+ 1
- 1
Modules/Seen/Seen.cs View File

@@ -25,7 +25,7 @@ namespace Combot.Modules.Plugins

private void GetLastSeen(CommandMessage command)
{
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : null;
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location;
List<Dictionary<string, object>> channelList = GetChannelList(channel, command.Arguments["Nickname"]);
List<Dictionary<string, object>> partList = GetPartList(channel, command.Arguments["Nickname"]);
List<Dictionary<string, object>> joinList = GetJoinList(channel, command.Arguments["Nickname"]);

+ 33
- 0
Modules/Seen/Seen.csproj View File

@@ -13,6 +13,21 @@
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>ffdb7c34</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -57,9 +72,27 @@
<ItemGroup>
<None Include="Module.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)"

+ 1
- 1
Modules/Spam Control/Spam_Control.cs View File

@@ -25,7 +25,7 @@ namespace Combot.Modules.Plugins

private void HandleChannelMessage(object sender, ChannelMessage message)
{
if (!ChannelBlacklist.Contains(message.Channel) && !NickBlacklist.Contains(message.Sender.Nickname))
if (Enabled && !ChannelBlacklist.Contains(message.Channel) && !NickBlacklist.Contains(message.Sender.Nickname))
{
int timeThreshold = Convert.ToInt32(GetOptionValue("Time Threshold"));
int maxMessages = Convert.ToInt32(GetOptionValue("Max Messages"));

+ 4
- 2
Modules/Url Parsing/Url_Parsing.cs View File

@@ -18,10 +18,12 @@ namespace Combot.Modules.Plugins
{
Regex urlRegex = new Regex("(https?)://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?");

if (!Bot.ServerConfig.ChannelBlacklist.Contains(message.Channel)
if (Enabled
&& !Bot.ServerConfig.ChannelBlacklist.Contains(message.Channel)
&& !Bot.ServerConfig.NickBlacklist.Contains(message.Sender.Nickname)
&& !ChannelBlacklist.Contains(message.Channel)
&& !NickBlacklist.Contains(message.Sender.Nickname))
&& !NickBlacklist.Contains(message.Sender.Nickname)
&& !Bot.IsCommand(message.Message))
{
if (urlRegex.IsMatch(message.Message))
{

+ 26
- 12
Modules/Version/Version.cs View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
@@ -49,26 +50,39 @@ namespace Combot.Modules.Plugins

public void HandleVersionQuery(object sender, CTCPMessage message)
{
if (message.Command.ToLower() == "version")
if (Enabled
&& !Bot.ServerConfig.NickBlacklist.Contains(message.Sender.Nickname)
&& !NickBlacklist.Contains(message.Sender.Nickname))
{
Bot.IRC.Command.SendCTCPNotice(message.Sender.Nickname, "VERSION", string.Format("Combot v{0} on {1}", Assembly.GetExecutingAssembly().GetName().Version, GetOptionValue("Machine Reply")));
if (message.Command.ToLower() == "version")
{
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
string version = fileVersionInfo.ProductVersion;
Bot.IRC.Command.SendCTCPNotice(message.Sender.Nickname, "VERSION", string.Format("Combot v{0} on {1}", version, GetOptionValue("Machine Reply")));
}
}
}

public void HandleVersionResponse(object sender, CTCPMessage message)
{
if (message.Command == "VERSION")
if (Enabled
&& !Bot.ServerConfig.NickBlacklist.Contains(message.Sender.Nickname)
&& !NickBlacklist.Contains(message.Sender.Nickname))
{
listLock.EnterReadLock();
VersionItem versionItem = versionList.Find(item => item.Nick.ToLower() == message.Sender.Nickname.ToLower());
listLock.ExitReadLock();
if (versionItem != null)
if (message.Command == "VERSION")
{
string verResponse = string.Format("[{0}] Using version: {1}", versionItem.Nick, message.Arguments);
SendResponse(versionItem.MessageType, versionItem.Location, message.Sender.Nickname, verResponse);
listLock.EnterWriteLock();
versionList.RemoveAll(item => item.Nick == versionItem.Nick);
listLock.ExitWriteLock();
listLock.EnterReadLock();
VersionItem versionItem = versionList.Find(item => item.Nick.ToLower() == message.Sender.Nickname.ToLower());
listLock.ExitReadLock();
if (versionItem != null)
{
string verResponse = string.Format("[{0}] Using version: {1}", versionItem.Nick, message.Arguments);
SendResponse(versionItem.MessageType, versionItem.Location, message.Sender.Nickname, verResponse);
listLock.EnterWriteLock();
versionList.RemoveAll(item => item.Nick == versionItem.Nick);
listLock.ExitWriteLock();
}
}
}
}

+ 4
- 2
Modules/YouTube/YouTube.cs View File

@@ -31,10 +31,12 @@ namespace Combot.Modules.Plugins

private void HandleChannelMessage(object sender, ChannelMessage message)
{
if (!Bot.ServerConfig.ChannelBlacklist.Contains(message.Channel)
if (Enabled
&& !Bot.ServerConfig.ChannelBlacklist.Contains(message.Channel)
&& !Bot.ServerConfig.NickBlacklist.Contains(message.Sender.Nickname)
&& !ChannelBlacklist.Contains(message.Channel)
&& !NickBlacklist.Contains(message.Sender.Nickname))
&& !NickBlacklist.Contains(message.Sender.Nickname)
&& !Bot.IsCommand(message.Message))
{
Regex urlRegex = new Regex("(((youtube.*(v=|/v/))|(youtu\\.be/))(?<ID>[-_a-zA-Z0-9]+))");
if (urlRegex.IsMatch(message.Message))

Loading…
Cancel
Save