@@ -1,7 +1,7 @@ | |||
| |||
Microsoft Visual Studio Solution File, Format Version 12.00 | |||
# Visual Studio 2013 | |||
VisualStudioVersion = 12.0.31101.0 | |||
# Visual Studio 14 | |||
VisualStudioVersion = 14.0.22823.1 | |||
MinimumVisualStudioVersion = 10.0.40219.1 | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interface", "Interface\Interface.csproj", "{AE4AFD7A-CAA4-46A0-9E00-2B3D53F8D0AB}" | |||
EndProject | |||
@@ -75,6 +75,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Timer", "Modules\Timer\Time | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Whois", "Modules\Whois\Whois.csproj", "{A6EDD673-A10D-48BC-81D9-506D08AEC083}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Custom Commands", "Custom Commands\Custom Commands\Custom Commands.csproj", "{B84A8D1B-C10A-4879-912A-83725A1638D1}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Any CPU = Debug|Any CPU | |||
@@ -201,6 +203,10 @@ Global | |||
{A6EDD673-A10D-48BC-81D9-506D08AEC083}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{A6EDD673-A10D-48BC-81D9-506D08AEC083}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{A6EDD673-A10D-48BC-81D9-506D08AEC083}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{B84A8D1B-C10A-4879-912A-83725A1638D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{B84A8D1B-C10A-4879-912A-83725A1638D1}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{B84A8D1B-C10A-4879-912A-83725A1638D1}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{B84A8D1B-C10A-4879-912A-83725A1638D1}.Release|Any CPU.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -232,5 +238,6 @@ Global | |||
{7D7B5FCB-C9CC-4CB1-B5EF-827BD3398E39} = {D157677E-4D33-4156-B55E-E21C4B5A3024} | |||
{84166880-FC04-4F50-90CD-8486B797948A} = {D157677E-4D33-4156-B55E-E21C4B5A3024} | |||
{A6EDD673-A10D-48BC-81D9-506D08AEC083} = {D157677E-4D33-4156-B55E-E21C4B5A3024} | |||
{B84A8D1B-C10A-4879-912A-83725A1638D1} = {D157677E-4D33-4156-B55E-E21C4B5A3024} | |||
EndGlobalSection | |||
EndGlobal |
@@ -0,0 +1,82 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |||
<PropertyGroup> | |||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
<ProjectGuid>{B84A8D1B-C10A-4879-912A-83725A1638D1}</ProjectGuid> | |||
<OutputType>Library</OutputType> | |||
<AppDesignerFolder>Properties</AppDesignerFolder> | |||
<RootNamespace>Custom_Commands</RootNamespace> | |||
<AssemblyName>Custom Commands</AssemblyName> | |||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> | |||
<FileAlignment>512</FileAlignment> | |||
<TargetFrameworkProfile /> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<DebugSymbols>true</DebugSymbols> | |||
<DebugType>full</DebugType> | |||
<Optimize>false</Optimize> | |||
<OutputPath>..\..\Bin\Debug\Modules\Custom Commands\</OutputPath> | |||
<DefineConstants>DEBUG;TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
<DebugType>pdbonly</DebugType> | |||
<Optimize>true</Optimize> | |||
<OutputPath>..\..\Bin\Release\Modules\Custom Commands\</OutputPath> | |||
<DefineConstants>TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Reference Include="System" /> | |||
<Reference Include="System.Core" /> | |||
<Reference Include="System.Xml.Linq" /> | |||
<Reference Include="System.Data.DataSetExtensions" /> | |||
<Reference Include="Microsoft.CSharp" /> | |||
<Reference Include="System.Data" /> | |||
<Reference Include="System.Xml" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="Custom_Commands.cs" /> | |||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\..\Combot\Combot.csproj"> | |||
<Project>{23e4c371-16e4-4fac-8b11-44288399bb55}</Project> | |||
<Name>Combot</Name> | |||
</ProjectReference> | |||
<ProjectReference Include="..\..\IRCServices\IRCServices.csproj"> | |||
<Project>{65fcbf1c-8c9e-4688-becc-185d9030899f}</Project> | |||
<Name>IRCServices</Name> | |||
</ProjectReference> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Include="Module.Default.json"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</None> | |||
<None Include="packages.config" /> | |||
</ItemGroup> | |||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
<PropertyGroup> | |||
<PostBuildEvent>md "$(SolutionDir)$(ConfigurationName)\Modules\$(TargetName)" | |||
copy /Y "$(TargetPath)" "$(SolutionDir)$(ConfigurationName)\Modules\$(TargetName)" | |||
copy /Y "$(TargetDir)Module.Default.json" "$(SolutionDir)$(ConfigurationName)\Modules\$(TargetName)"</PostBuildEvent> | |||
</PropertyGroup> | |||
<Import Project="..\..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets')" /> | |||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | |||
<PropertyGroup> | |||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> | |||
</PropertyGroup> | |||
<Error Condition="!Exists('..\..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\GitVersionTask.2.0.1\Build\GitVersionTask.targets'))" /> | |||
</Target> | |||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
Other similar extension points exist, see Microsoft.Common.targets. | |||
<Target Name="BeforeBuild"> | |||
</Target> | |||
<Target Name="AfterBuild"> | |||
</Target> | |||
--> | |||
</Project> |
@@ -0,0 +1,78 @@ | |||
using Combot.IRCServices; | |||
namespace Combot.Modules.Plugins | |||
{ | |||
public class Custom_Commands : Module | |||
{ | |||
public override void Initialize() | |||
{ | |||
Bot.CommandReceivedEvent += HandleCommandEvent; | |||
} | |||
public override void ParseCommand(CommandMessage command) | |||
{ | |||
Command foundCommand = Commands.Find(c => c.Triggers.Contains(command.Command)); | |||
switch (foundCommand.Name) | |||
{ | |||
case "Custom Command": | |||
string action = command.Arguments["Action"]; | |||
switch (action.ToLower()) | |||
{ | |||
case "add": | |||
string addTrigger = command.Arguments["Trigger"]; | |||
string addResponse = command.Arguments["Response"]; | |||
AddCommand(command.Nick, addTrigger, addResponse); | |||
break; | |||
case "del": | |||
string delTrigger = command.Arguments["Trigger"]; | |||
DeleteCommand(command.Nick, delTrigger); | |||
break; | |||
case "edit": | |||
string editTrigger = command.Arguments["Trigger"]; | |||
string editResponse = command.Arguments["Response"]; | |||
EditCommand(command.Nick, editTrigger, editResponse); | |||
break; | |||
case "view": | |||
if (command.Arguments.ContainsKey("Trigger")) | |||
{ | |||
ViewTrigger(command.Nick, command.Arguments["trigger"]); | |||
} | |||
else | |||
{ | |||
ViewTriggers(command.Nick); | |||
} | |||
break; | |||
} | |||
break; | |||
default: | |||
//todo add check for custom commands here | |||
break; | |||
} | |||
} | |||
private void AddCommand(Nick caller, string trigger, string response) | |||
{ | |||
} | |||
private void DeleteCommand(Nick caller, string trigger) | |||
{ | |||
} | |||
private void EditCommand(Nick caller, string trigger, string response) | |||
{ | |||
} | |||
private void ViewTriggers(Nick caller) | |||
{ | |||
} | |||
private void ViewTrigger(Nick caller, string trigger) | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,9 @@ | |||
{ | |||
"Name": "Custom Commands", | |||
"ClassName": "Custom_Commands", | |||
"Enabled": true, | |||
"ChannelBlacklist": [], | |||
"NickBlacklist": [], | |||
"Commands": [], | |||
"Options": [] | |||
} |
@@ -0,0 +1,33 @@ | |||
using System.Reflection; | |||
using System.Runtime.CompilerServices; | |||
using System.Runtime.InteropServices; | |||
// General Information about an assembly is controlled through the following | |||
// set of attributes. Change these attribute values to modify the information | |||
// associated with an assembly. | |||
[assembly: AssemblyTitle("Custom_Commands Module")] | |||
[assembly: AssemblyDescription("")] | |||
[assembly: AssemblyConfiguration("")] | |||
[assembly: AssemblyCompany("Teknik")] | |||
[assembly: AssemblyProduct("Combot")] | |||
[assembly: AssemblyCopyright("Copyright © 2015")] | |||
[assembly: AssemblyTrademark("")] | |||
[assembly: AssemblyCulture("")] | |||
// Setting ComVisible to false makes the types in this assembly not visible | |||
// to COM components. If you need to access a type in this assembly from | |||
// COM, set the ComVisible attribute to true on that type. | |||
[assembly: ComVisible(false)] | |||
// The following GUID is for the ID of the typelib if this project is exposed to COM | |||
[assembly: Guid("5c350b8e-5820-4034-9d67-49d2ddbfcc6f")] | |||
// Version information for an assembly consists of the following four values: | |||
// | |||
// Major Version | |||
// Minor Version | |||
// Build Number | |||
// Revision | |||
// | |||
// You can specify all the values or you can default the Build and Revision Numbers | |||
// by using the '*' as shown below: |
@@ -0,0 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="GitVersionTask" version="2.0.1" targetFramework="net451" developmentDependency="true" /> | |||
</packages> |
@@ -58,23 +58,14 @@ namespace Combot.Modules.Plugins | |||
mysqlCase = "CAST(`channelmessages`.`message` AS BINARY)"; | |||
} | |||
string mysqlMatch = match.Replace(@"\s", "[:space:]").Replace(@"\", @"\\"); | |||
List<Dictionary<string, object>> resultList = GetMessageList(message.Channel, message.Sender.Nickname, mysqlMatch, mysqlCase); | |||
List<Dictionary<string, object>> resultList = GetMessageList(message.Channel, message.Sender.Nickname, mysqlMatch, mysqlCase, message.Message); | |||
if (resultList.Any()) | |||
{ | |||
IEnumerable<Dictionary<string, object>> validList = resultList.Where(item => item["message"].ToString() != message.Message); | |||
if (validList.Any()) | |||
{ | |||
string oldMessage = validList.First()["message"].ToString(); | |||
Regex messageRegex = new Regex(match, matchOptions); | |||
string newMessage = messageRegex.Replace(oldMessage, replace, replaceNum); | |||
string replacedMessage = string.Format("\u0002{0}\u0002 meant to say: {1}", message.Sender.Nickname, newMessage); | |||
SendResponse(MessageType.Channel, message.Channel, message.Sender.Nickname, replacedMessage); | |||
} | |||
else | |||
{ | |||
string noMatch = string.Format("You do not have any previous messages that match \u0002{0}\u0002.", match); | |||
SendResponse(MessageType.Channel, message.Channel, message.Sender.Nickname, noMatch); | |||
} | |||
string oldMessage = resultList.First()["message"].ToString(); | |||
Regex messageRegex = new Regex(match, matchOptions); | |||
string newMessage = messageRegex.Replace(oldMessage, replace, replaceNum); | |||
string replacedMessage = string.Format("\u0002{0}\u0002 meant to say: {1}", message.Sender.Nickname, newMessage); | |||
SendResponse(MessageType.Channel, message.Channel, message.Sender.Nickname, replacedMessage); | |||
} | |||
else | |||
{ | |||
@@ -85,7 +76,7 @@ namespace Combot.Modules.Plugins | |||
} | |||
} | |||
private List<Dictionary<string, object>> GetMessageList(string channel, string nickname, string regex, string caseString) | |||
private List<Dictionary<string, object>> GetMessageList(string channel, string nickname, string regex, string caseString, string originalMessage) | |||
{ | |||
Database database = new Database(Bot.ServerConfig.Database); | |||
string search = "SELECT `channelmessages`.`message`, `channelmessages`.`date_added` FROM `channelmessages` " + | |||
@@ -95,9 +86,10 @@ namespace Combot.Modules.Plugins | |||
"ON `channelmessages`.`channel_id` = `channels`.`id` " + | |||
"INNER JOIN `servers` " + | |||
"ON `channelmessages`.`server_id` = `servers`.`id` " + | |||
"WHERE `servers`.`name` = {0} AND `channels`.`name` = {1} AND `nicks`.`nickname` = {2} AND " + caseString + " REGEXP {3} " + | |||
"ORDER BY date_added DESC"; | |||
return database.Query(search, new object[] { Bot.ServerConfig.Name, channel, nickname, regex }); | |||
"WHERE `servers`.`name` = {0} AND `channels`.`name` = {1} AND `nicks`.`nickname` = {2} AND `channelmessages`.`message` != {3} AND " + caseString + " REGEXP {4} " + | |||
"ORDER BY date_added DESC " + | |||
"LIMIT 1"; | |||
return database.Query(search, new object[] { Bot.ServerConfig.Name, channel, nickname, originalMessage, regex }); | |||
} | |||
} | |||
} |