forked from Uncled1023/Combot
Browse Source
Added logging module. Started Configuration module. Started Introduction module.master
26 changed files with 1088 additions and 58 deletions
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
namespace Combot.Configurations |
||||
{ |
||||
public class DatabaseConfig |
||||
{ |
||||
public string Server { get; set; } |
||||
public int Port { get; set; } |
||||
public string Database { get; set; } |
||||
public string Username { get; set; } |
||||
public string Password { get; set; } |
||||
|
||||
public DatabaseConfig() |
||||
{ |
||||
SetDefaults(); |
||||
} |
||||
|
||||
public void SetDefaults() |
||||
{ |
||||
Server = "localhost"; |
||||
Port = 3306; |
||||
Database = string.Empty; |
||||
Username = string.Empty; |
||||
Password = string.Empty; |
||||
} |
||||
} |
||||
} |
@ -1,51 +1,19 @@
@@ -1,51 +1,19 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
|
||||
namespace Combot.Configurations |
||||
namespace Combot.Configurations |
||||
{ |
||||
public class HostConfig |
||||
{ |
||||
public HostConfig() |
||||
{ |
||||
Host = string.Empty; |
||||
Port = 0; |
||||
} |
||||
public string Host { get; set; } |
||||
public int Port { get; set; } |
||||
|
||||
private string _Host; |
||||
public string Host |
||||
public HostConfig() |
||||
{ |
||||
get |
||||
{ |
||||
return _Host; |
||||
} |
||||
|
||||
set |
||||
{ |
||||
if (_Host != value) |
||||
{ |
||||
_Host = value; |
||||
} |
||||
} |
||||
SetDefaults(); |
||||
} |
||||
|
||||
private int _Port; |
||||
public int Port |
||||
public void SetDefaults() |
||||
{ |
||||
get |
||||
{ |
||||
return _Port; |
||||
} |
||||
|
||||
set |
||||
{ |
||||
if (_Port != value) |
||||
{ |
||||
_Port = value; |
||||
} |
||||
} |
||||
Host = string.Empty; |
||||
Port = 0; |
||||
} |
||||
} |
||||
} |
||||
|
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using Combot.Configurations; |
||||
using MySql.Data.MySqlClient; |
||||
|
||||
namespace Combot.Databases |
||||
{ |
||||
public class Database |
||||
{ |
||||
private bool Connected { get; set; } |
||||
private MySqlConnection Connection { get; set; } |
||||
|
||||
public Database(DatabaseConfig config) |
||||
{ |
||||
Connected = false; |
||||
Connection = null; |
||||
Connect(config); |
||||
} |
||||
|
||||
public List<Dictionary<string, object>> Query(string query, params object[] args) |
||||
{ |
||||
MySqlCommand cmd = PrepareQuery(query, args); |
||||
MySqlDataReader reader = cmd.ExecuteReader(); |
||||
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>(); |
||||
while (reader.Read()) |
||||
{ |
||||
Dictionary<string, object> row = new Dictionary<string, object>(); |
||||
for (int i = 0; i < reader.FieldCount; i++) |
||||
{ |
||||
row.Add(reader.GetName(i), reader.GetValue(i)); |
||||
} |
||||
rows.Add(row); |
||||
} |
||||
reader.Close(); |
||||
return rows; |
||||
} |
||||
|
||||
public object ScalarQuery(string query, params object[] args) |
||||
{ |
||||
MySqlCommand cmd = PrepareQuery(query, args); |
||||
return cmd.ExecuteScalar(); |
||||
} |
||||
|
||||
public void Execute(string query, params object[] args) |
||||
{ |
||||
MySqlCommand cmd = PrepareQuery(query, args); |
||||
cmd.ExecuteNonQuery(); |
||||
} |
||||
|
||||
private void Connect(DatabaseConfig config) |
||||
{ |
||||
if (Connection == null) |
||||
{ |
||||
if (config.Server != string.Empty && config.Database != string.Empty && config.Username != string.Empty && config.Password != string.Empty) |
||||
{ |
||||
string strCon = string.Format("Server={0}; database={1}; user={2}; password={3}; port={4}; charset=utf8", config.Server, config.Database, config.Username, config.Password, config.Port); |
||||
Connection = new MySqlConnection(strCon); |
||||
try |
||||
{ |
||||
Connection.Open(); |
||||
Connected = true; |
||||
} |
||||
catch (MySqlException ex) |
||||
{ |
||||
Connected = false; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void Disconnect() |
||||
{ |
||||
if (Connection != null && Connected) |
||||
{ |
||||
Connection.Close(); |
||||
} |
||||
} |
||||
|
||||
private MySqlCommand PrepareQuery(string query, object[] args) |
||||
{ |
||||
if (Connected) |
||||
{ |
||||
MySqlCommand cmd = new MySqlCommand(); |
||||
cmd.Connection = Connection; |
||||
for (int i = 0; i < args.Length; i++) |
||||
{ |
||||
string param = "{" + i + "}"; |
||||
string paramName = "@DBVar_" + i; |
||||
query = query.Replace(param, paramName); |
||||
cmd.Parameters.AddWithValue(paramName, args[i]); |
||||
} |
||||
cmd.CommandText = query; |
||||
return cmd; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -1,4 +1,5 @@
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<packages> |
||||
<package id="MySql.Data" version="6.9.5" targetFramework="net451" /> |
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" /> |
||||
</packages> |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
namespace Combot.Modules.Plugins |
||||
{ |
||||
public class Configuration : Module |
||||
{ |
||||
public override void Initialize() |
||||
{ |
||||
Bot.CommandReceivedEvent += HandleCommandEvent; |
||||
} |
||||
|
||||
public override void ParseCommand(CommandMessage command) |
||||
{ |
||||
Command foundCommand = Commands.Find(c => c.Triggers.Contains(command.Command)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
<?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>{516ECE98-0D6D-4713-AEDA-EDF47FFAA80B}</ProjectGuid> |
||||
<OutputType>Library</OutputType> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
<RootNamespace>Configuration</RootNamespace> |
||||
<AssemblyName>Configuration</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\Modules\Configuration\Debug\</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\Modules\Configuration\Release\</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="Configuration.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.config"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
<PropertyGroup> |
||||
<PostBuildEvent>mkdir "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)" |
||||
copy /Y "$(TargetPath)" "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)" |
||||
copy /Y "$(TargetDir)Module.config" "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)"</PostBuildEvent> |
||||
</PropertyGroup> |
||||
<!-- 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,156 @@
@@ -0,0 +1,156 @@
|
||||
{ |
||||
"Name": "Configuration", |
||||
"ClassName": "Configuration", |
||||
"Enabled": true, |
||||
"ChannelBlacklist": [], |
||||
"NickBlacklist": [], |
||||
"Commands": [ |
||||
{ |
||||
"Name": "Config", |
||||
"Description": "Allows you access to the configuration", |
||||
"Enabled": true, |
||||
"ChannelBlacklist": [], |
||||
"NickBlacklist": [], |
||||
"Triggers": [ |
||||
"config" |
||||
], |
||||
"Arguments": [ |
||||
{ |
||||
"Name": "Type", |
||||
"Description": "The type of config you want to interact with.", |
||||
"AllowedValues": [ |
||||
"Command", |
||||
"Module", |
||||
"Server" |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "Command", |
||||
"Description": "The command you want to interact with.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Type", |
||||
"Values": [ |
||||
"Command" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "Module", |
||||
"Description": "The module you want to interact with.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Type", |
||||
"Values": [ |
||||
"Module" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "Action", |
||||
"Description": "The action you want to perform on the config.", |
||||
"AllowedValues": [ |
||||
"View", |
||||
"Edit" |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "Name", |
||||
"Description": "The name of the variable you want to interact with.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Action", |
||||
"Values": [ |
||||
"View" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": false |
||||
}, |
||||
{ |
||||
"Name": "Name", |
||||
"Description": "The name of the variable you want to interact with.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Action", |
||||
"Values": [ |
||||
"Edit" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "Value", |
||||
"Description": "The new value for the defined variable.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Action", |
||||
"Values": [ |
||||
"Edit" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
} |
||||
], |
||||
"AllowedMessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"AllowedAccess": [ |
||||
6 |
||||
], |
||||
"ShowHelp": true, |
||||
"SpamCheck": true |
||||
} |
||||
], |
||||
"Options": [] |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
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("Configuration 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:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using Combot.Databases; |
||||
using Combot.IRCServices.Messaging; |
||||
|
||||
namespace Combot.Modules.Plugins |
||||
{ |
||||
public class Introductions : Module |
||||
{ |
||||
public override void Initialize() |
||||
{ |
||||
Bot.CommandReceivedEvent += HandleCommandEvent; |
||||
Bot.IRC.Message.JoinChannelEvent += HandleJoinEvent; |
||||
} |
||||
|
||||
public override void ParseCommand(CommandMessage command) |
||||
{ |
||||
Command foundCommand = Commands.Find(c => c.Triggers.Contains(command.Command)); |
||||
switch (foundCommand.Name) |
||||
{ |
||||
case "Introduction": |
||||
string method = command.Arguments["Method"]; |
||||
switch (method.ToLower()) |
||||
{ |
||||
case "add": |
||||
AddIntroduction(command); |
||||
break; |
||||
case "edit": |
||||
break; |
||||
case "delete": |
||||
break; |
||||
case "view": |
||||
break; |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
private void HandleJoinEvent(object sender, JoinChannelInfo info) |
||||
{ |
||||
|
||||
} |
||||
|
||||
private void AddIntroduction(CommandMessage command) |
||||
{ |
||||
string channel = command.Arguments.ContainsKey("Channel") ? command.Arguments["Channel"] : command.Location; |
||||
Database database = new Database(Bot.ServerConfig.Database); |
||||
|
||||
// Check to see if they have reached the max number of introductions
|
||||
string search = "SELECT `introductions`.`id` FROM `introductions` INNER JOIN `nicks` " + |
||||
"ON `introductions`.`nick_id` = `nicks`.`id` " + |
||||
"INNER JOIN `channels` " + |
||||
"ON `introductions`.`channel_id` = `channels`.`id` " + |
||||
"INNER JOIN `servers` " + |
||||
"ON `nicks`.`server_id` = `servers`.`id` " + |
||||
"WHERE `servers`.`name` = {0} AND `channels`.`name` = {1} AND `nicks`.`nickname` = {2}"; |
||||
List<Dictionary<string, object>> results = database.Query(search, new object[] { Bot.ServerConfig.Name, channel, command.Nick.Nickname }); |
||||
|
||||
if (results.Count < Convert.ToInt32(GetOptionValue("Max Introductions"))) |
||||
{ |
||||
|
||||
AddChannel(channel); |
||||
AddNick(command.Nick.Nickname); |
||||
string query = "INSERT INTO `introductions` SET " + |
||||
"`server_id` = (SELECT `id` FROM `servers` WHERE `name` = {0}), " + |
||||
"`channel_id` = (SELECT `channels`.`id` FROM `channels` INNER JOIN `servers` ON `servers`.`id` = `channels`.`server_id` WHERE `servers`.`name` = {1} && `channels`.`name` = {2}), " + |
||||
"`nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {3} && `nickname` = {4}), " + |
||||
"`message` = {5}, " + |
||||
"`date_added` = {6}"; |
||||
database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, channel, Bot.ServerConfig.Name, command.Nick.Nickname, command.Arguments["Message"], command.TimeStamp}); |
||||
} |
||||
else |
||||
{ |
||||
string maxMessage = "You already have the maximum number of introductions for this channel. Delete one before trying to add another."; |
||||
switch (command.MessageType) |
||||
{ |
||||
case MessageType.Channel: |
||||
Bot.IRC.SendPrivateMessage(command.Location, maxMessage); |
||||
break; |
||||
case MessageType.Query: |
||||
Bot.IRC.SendPrivateMessage(command.Nick.Nickname, maxMessage); |
||||
break; |
||||
case MessageType.Notice: |
||||
Bot.IRC.SendNotice(command.Nick.Nickname, maxMessage); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
<?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>{6FEDA88B-70F0-4E7B-9079-C5530247F8AB}</ProjectGuid> |
||||
<OutputType>Library</OutputType> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
<RootNamespace>Introductions</RootNamespace> |
||||
<AssemblyName>Introductions</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\Modules\Introductions\Debug\</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\Modules\Introductions\Release\</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="Introductions.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.config"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
<PropertyGroup> |
||||
<PostBuildEvent>mkdir "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)" |
||||
copy /Y "$(TargetPath)" "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)" |
||||
copy /Y "$(TargetDir)Module.config" "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)"</PostBuildEvent> |
||||
</PropertyGroup> |
||||
<!-- 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,124 @@
@@ -0,0 +1,124 @@
|
||||
{ |
||||
"Name": "Introductions", |
||||
"ClassName": "Introductions", |
||||
"Enabled": true, |
||||
"ChannelBlacklist": [], |
||||
"NickBlacklist": [], |
||||
"Commands": [ |
||||
{ |
||||
"Name": "Introduction", |
||||
"Description": "Modify your introductions or view them.", |
||||
"Enabled": true, |
||||
"ChannelBlacklist": [], |
||||
"NickBlacklist": [], |
||||
"Triggers": [ |
||||
"intro" |
||||
], |
||||
"Arguments": [ |
||||
{ |
||||
"Name": "Channel", |
||||
"Description": "The channel you want to modify the intro on.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [], |
||||
"MessageTypes": [ |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "Method", |
||||
"Description": "What you want to do with the introduction.", |
||||
"AllowedValues": [ |
||||
"Add", |
||||
"Edit", |
||||
"Delete", |
||||
"View" |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "ID", |
||||
"Description": "The ID of the introduction you want to edit or delete.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Method", |
||||
"Values": [ |
||||
"Edit", |
||||
"Delete" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
}, |
||||
{ |
||||
"Name": "ID", |
||||
"Description": "The ID of the introduction you want to view.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Method", |
||||
"Values": [ |
||||
"View" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": false |
||||
}, |
||||
{ |
||||
"Name": "Message", |
||||
"Description": "The message you want to set as your introduction.", |
||||
"AllowedValues": [], |
||||
"DependentArguments": [ |
||||
{ |
||||
"Name": "Method", |
||||
"Values": [ |
||||
"Add", |
||||
"Edit" |
||||
] |
||||
} |
||||
], |
||||
"MessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"Required": true |
||||
} |
||||
], |
||||
"AllowedMessageTypes": [ |
||||
0, |
||||
1, |
||||
2 |
||||
], |
||||
"AllowedAccess": [ |
||||
6 |
||||
], |
||||
"ShowHelp": true, |
||||
"SpamCheck": true |
||||
} |
||||
], |
||||
"Options": [ |
||||
{ |
||||
"Name": "Max Introductions", |
||||
"Description": "The maximum number of introductions allowed for a nick on a given channel.", |
||||
"Value": 5 |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
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("Introductions 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:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
@ -0,0 +1,107 @@
@@ -0,0 +1,107 @@
|
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
using Combot.Databases; |
||||
using Combot.IRCServices.Messaging; |
||||
|
||||
namespace Combot.Modules.Plugins |
||||
{ |
||||
public class Logging : Module |
||||
{ |
||||
public override void Initialize() |
||||
{ |
||||
//Bot.CommandReceivedEvent += HandleCommandEvent;
|
||||
Bot.IRC.ConnectEvent += AddServer; |
||||
Bot.IRC.Message.ChannelMessageReceivedEvent += LogChannelMessage; |
||||
Bot.IRC.Message.PrivateMessageReceivedEvent += LogPrivateMessage; |
||||
Bot.IRC.Message.JoinChannelEvent += LogChannelJoin; |
||||
Bot.IRC.Message.PartChannelEvent += LogChannelPart; |
||||
Bot.IRC.Message.KickEvent += LogChannelKick; |
||||
Bot.IRC.Message.QuitEvent += LogQuit; |
||||
} |
||||
|
||||
public override void ParseCommand(CommandMessage command) |
||||
{ |
||||
Command foundCommand = Commands.Find(c => c.Triggers.Contains(command.Command)); |
||||
} |
||||
|
||||
private void LogChannelMessage(object sender, ChannelMessage message) |
||||
{ |
||||
AddNick(message.Sender.Nickname); |
||||
Database database = new Database(Bot.ServerConfig.Database); |
||||
string query = "INSERT INTO `channelmessages` SET " + |
||||
"`server_id` = (SELECT `id` FROM `servers` WHERE `name` = {0}), " + |
||||
"`channel_id` = (SELECT `channels`.`id` FROM `channels` INNER JOIN `servers` ON `servers`.`id` = `channels`.`server_id` WHERE `servers`.`name` = {1} && `channels`.`name` = {2}), " + |
||||
"`nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {3} && `nickname` = {4}), " + |
||||
"`message` = {5}, " + |
||||
"`date_added` = {6}"; |
||||
database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, message.Channel, Bot.ServerConfig.Name, message.Sender.Nickname, message.Message, message.TimeStamp}); |
||||
} |
||||
|
||||
private void LogPrivateMessage(object sender, PrivateMessage message) |
||||
{ |
||||
AddNick(message.Sender.Nickname); |
||||
Database database = new Database(Bot.ServerConfig.Database); |
||||
string query = "INSERT INTO `privatemessages` SET " + |
||||
"`server_id` = (SELECT `id` FROM `servers` WHERE `name` = {0}), " + |
||||
"`nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {1} && `nickname` = {2}), " + |
||||
"`message` = {3}, " + |
||||
"`date_added` = {4}"; |
||||
database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, message.Sender.Nickname, message.Message, message.TimeStamp}); |
||||
} |
||||
|
||||
private void LogChannelJoin(object sender, JoinChannelInfo info) |
||||
{ |
||||
if (info.Nick.Nickname == Bot.IRC.Nickname) |
||||
{ |
||||
AddChannel(info.Channel); |
||||
} |
||||
AddNick(info.Nick.Nickname); |
||||
Database database = new Database(Bot.ServerConfig.Database); |
||||
string query = "INSERT INTO `channeljoins` SET " + |
||||
"`server_id` = (SELECT `id` FROM `servers` WHERE `name` = {0}), " + |
||||
"`channel_id` = (SELECT `channels`.`id` FROM `channels` INNER JOIN `servers` ON `servers`.`id` = `channels`.`server_id` WHERE `servers`.`name` = {1} && `channels`.`name` = {2}), " + |
||||
"`nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {3} && `nickname` = {4}), " + |
||||
"`date_added` = {5}"; |
||||
database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, info.Channel, Bot.ServerConfig.Name, info.Nick.Nickname, info.TimeStamp}); |
||||
} |
||||
|
||||
private void LogChannelPart(object sender, PartChannelInfo info) |
||||
{ |
||||
AddNick(info.Nick.Nickname); |
||||
Database database = new Database(Bot.ServerConfig.Database); |
||||
string query = "INSERT INTO `channelparts` SET " + |
||||
"`server_id` = (SELECT `id` FROM `servers` WHERE `name` = {0}), " + |
||||
"`channel_id` = (SELECT `channels`.`id` FROM `channels` INNER JOIN `servers` ON `servers`.`id` = `channels`.`server_id` WHERE `servers`.`name` = {1} && `channels`.`name` = {2}), " + |
||||
"`nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {3} && `nickname` = {4}), " + |
||||
"`date_added` = {5}"; |
||||
database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, info.Channel, Bot.ServerConfig.Name, info.Nick.Nickname, info.TimeStamp}); |
||||
} |
||||
|
||||
private void LogChannelKick(object sender, KickInfo info) |
||||
{ |
||||
AddNick(info.Nick.Nickname); |
||||
AddNick(info.KickedNick.Nickname); |
||||
Database database = new Database(Bot.ServerConfig.Database); |
||||
string query = "INSERT INTO `channelkickss` SET " + |
||||
"`server_id` = (SELECT `id` FROM `servers` WHERE `name` = {0}), " + |
||||
"`channel_id` = (SELECT `channels`.`id` FROM `channels` INNER JOIN `servers` ON `servers`.`id` = `channels`.`server_id` WHERE `servers`.`name` = {1} && `channels`.`name` = {2}), " + |
||||
"`nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {3} && `nickname` = {4}), " + |
||||
"`kicked_nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {5} && `nickname` = {6}), " + |
||||
"`reason` = {7}, " + |
||||
"`date_added` = {8}"; |
||||
database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, info.Channel, Bot.ServerConfig.Name, info.Nick.Nickname, Bot.ServerConfig.Name, info.KickedNick.Nickname, info.Reason, info.TimeStamp}); |
||||
} |
||||
|
||||
private void LogQuit(object sender, QuitInfo info) |
||||
{ |
||||
AddNick(info.Nick.Nickname); |
||||
Database database = new Database(Bot.ServerConfig.Database); |
||||
string query = "INSERT INTO `quits` SET " + |
||||
"`server_id` = (SELECT `id` FROM `servers` WHERE `name` = {0}), " + |
||||
"`nick_id` = (SELECT `nicks`.`id` FROM `nicks` INNER JOIN `servers` ON `servers`.`id` = `nicks`.`server_id` WHERE `servers`.`name` = {1} && `nickname` = {2}), " + |
||||
"`message` = {3}, " + |
||||
"`date_added` = {4}"; |
||||
database.Execute(query, new object[] {Bot.ServerConfig.Name, Bot.ServerConfig.Name, info.Nick.Nickname, info.Message, info.TimeStamp}); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
<?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>{289A0E25-F669-4E00-9DB9-0C5AE51E2BCC}</ProjectGuid> |
||||
<OutputType>Library</OutputType> |
||||
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
<RootNamespace>Logging</RootNamespace> |
||||
<AssemblyName>Logging</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\Modules\Logging\Debug\</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\Modules\Logging\Release\</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="Logging.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.config"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
<PropertyGroup> |
||||
<PostBuildEvent>mkdir "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)" |
||||
copy /Y "$(TargetPath)" "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)" |
||||
copy /Y "$(TargetDir)Module.config" "$(SolutionDir)Bin\Interface\$(ConfigurationName)\Modules\$(TargetName)"</PostBuildEvent> |
||||
</PropertyGroup> |
||||
<!-- 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,9 @@
@@ -0,0 +1,9 @@
|
||||
{ |
||||
"Name": "Logging", |
||||
"ClassName": "Logging", |
||||
"Enabled": true, |
||||
"ChannelBlacklist": [], |
||||
"NickBlacklist": [], |
||||
"Commands": [], |
||||
"Options": [] |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
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("Logging 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:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")] |
||||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Loading…
Reference in new issue