Browse Source

Added Decide module.

Fixed small bugs.
master
Teknikode 8 years ago
parent
commit
f20dc195e4
  1. 2
      .gitignore
  2. 8
      Combot.sln
  3. 35
      Combot/Databases/Database.cs
  4. 2
      Combot/Modules/Command.cs
  5. 4
      Combot/Modules/Module.cs
  6. 2
      Combot/Modules/Option.cs
  7. 2
      Interface/Interface.csproj
  8. 42
      Modules/Decide/Decide.cs
  9. 79
      Modules/Decide/Decide.csproj
  10. 84
      Modules/Decide/Module.config
  11. 36
      Modules/Decide/Properties/AssemblyInfo.cs
  12. 4
      Modules/Decide/packages.config
  13. 4
      Modules/Fun/Fun.cs
  14. 2
      Modules/Introductions/Introductions.cs
  15. 2
      Modules/Messaging/Messaging.cs
  16. 2
      Modules/Owner Control/Owner_Control.cs
  17. 2
      Modules/Spam Control/Module.config
  18. 1
      Modules/Spam Control/Spam Control.csproj
  19. 15
      Modules/Spam Control/Spam_Control.cs
  20. 3
      Modules/Url Parsing/Url_Parsing.cs

2
.gitignore vendored

@ -212,3 +212,5 @@ pip-log.txt @@ -212,3 +212,5 @@ pip-log.txt
#Mr Developer
.mr.developer.cfg
Combot.Servers.config
Combot.Servers.Debug.config
Combot.Servers.Release.config

8
Combot.sln

@ -5,6 +5,7 @@ VisualStudioVersion = 12.0.31101.0 @@ -5,6 +5,7 @@ VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interface", "Interface\Interface.csproj", "{AE4AFD7A-CAA4-46A0-9E00-2B3D53F8D0AB}"
ProjectSection(ProjectDependencies) = postProject
{6CB41404-02E8-4CA3-834C-CE8C30999450} = {6CB41404-02E8-4CA3-834C-CE8C30999450}
{2CE88104-14EB-436A-9E74-610212FF42F6} = {2CE88104-14EB-436A-9E74-610212FF42F6}
{6F4BBF10-0D1A-4092-8A06-C7587EBC3F03} = {6F4BBF10-0D1A-4092-8A06-C7587EBC3F03}
{D469C717-7625-40F1-966D-3C9DD00F5B9C} = {D469C717-7625-40F1-966D-3C9DD00F5B9C}
@ -85,6 +86,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Channel Rules", "Modules\Ch @@ -85,6 +86,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Channel Rules", "Modules\Ch
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "About", "Modules\About\About.csproj", "{0DAE9869-DE0E-442F-B8EF-B4F54EDE9559}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decide", "Modules\Decide\Decide.csproj", "{6CB41404-02E8-4CA3-834C-CE8C30999450}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -191,6 +194,10 @@ Global @@ -191,6 +194,10 @@ Global
{0DAE9869-DE0E-442F-B8EF-B4F54EDE9559}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DAE9869-DE0E-442F-B8EF-B4F54EDE9559}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DAE9869-DE0E-442F-B8EF-B4F54EDE9559}.Release|Any CPU.Build.0 = Release|Any CPU
{6CB41404-02E8-4CA3-834C-CE8C30999450}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CB41404-02E8-4CA3-834C-CE8C30999450}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CB41404-02E8-4CA3-834C-CE8C30999450}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CB41404-02E8-4CA3-834C-CE8C30999450}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -218,5 +225,6 @@ Global @@ -218,5 +225,6 @@ Global
{FE9C7DB3-C4AA-4CF4-A6CF-CBE2244D3F2D} = {D157677E-4D33-4156-B55E-E21C4B5A3024}
{569F61C2-3B06-4313-A299-E643C3786D3D} = {D157677E-4D33-4156-B55E-E21C4B5A3024}
{0DAE9869-DE0E-442F-B8EF-B4F54EDE9559} = {D157677E-4D33-4156-B55E-E21C4B5A3024}
{6CB41404-02E8-4CA3-834C-CE8C30999450} = {D157677E-4D33-4156-B55E-E21C4B5A3024}
EndGlobalSection
EndGlobal

35
Combot/Databases/Database.cs

@ -19,32 +19,42 @@ namespace Combot.Databases @@ -19,32 +19,42 @@ namespace Combot.Databases
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())
if (Connected)
{
Dictionary<string, object> row = new Dictionary<string, object>();
for (int i = 0; i < reader.FieldCount; i++)
MySqlCommand cmd = PrepareQuery(query, args);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
row.Add(reader.GetName(i), reader.GetValue(i));
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);
}
rows.Add(row);
reader.Close();
}
reader.Close();
return rows;
}
public object ScalarQuery(string query, params object[] args)
{
MySqlCommand cmd = PrepareQuery(query, args);
return cmd.ExecuteScalar();
if (Connected)
{
MySqlCommand cmd = PrepareQuery(query, args);
return cmd.ExecuteScalar();
}
return null;
}
public void Execute(string query, params object[] args)
{
MySqlCommand cmd = PrepareQuery(query, args);
cmd.ExecuteNonQuery();
if (Connected)
{
MySqlCommand cmd = PrepareQuery(query, args);
cmd.ExecuteNonQuery();
}
}
private void Connect(DatabaseConfig config)
@ -72,6 +82,7 @@ namespace Combot.Databases @@ -72,6 +82,7 @@ namespace Combot.Databases
{
if (Connection != null && Connected)
{
Connected = false;
Connection.Close();
}
}

2
Combot/Modules/Command.cs

@ -95,7 +95,7 @@ namespace Combot.Modules @@ -95,7 +95,7 @@ namespace Combot.Modules
{
CommandArgument.DependentArgumentInfo checkedArgument = Arguments[i].DependentArguments.Find(dep => Arguments.Exists(val => val.Name == dep.Name));
int argIndex = validArguments.FindIndex(arg => arg.Name == checkedArgument.Name);
if (passedArgs.Count > argIndex)
if (passedArgs.Count > argIndex && argIndex >= 0)
{
if (checkedArgument.Values.Exists(check => check.ToLower() == passedArgs[argIndex].ToLower()))
{

4
Combot/Modules/Module.cs

@ -174,9 +174,9 @@ namespace Combot.Modules @@ -174,9 +174,9 @@ namespace Combot.Modules
return newModule;
}
public dynamic GetOptionValue(string name)
public object GetOptionValue(string name)
{
dynamic foundValue = null;
object foundValue = null;
Option foundOption = Options.Find(opt => opt.Name == name);
if (foundOption != null)
{

2
Combot/Modules/Option.cs

@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
{
public string Name { get; set; }
public string Description { get; set; }
public dynamic Value { get; set; }
public object Value { get; set; }
public Option()
{

2
Interface/Interface.csproj

@ -148,7 +148,7 @@ @@ -148,7 +148,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(SolutionDir)Combot.Servers.Config" "$(TargetDir)"</PostBuildEvent>
<PostBuildEvent>copy "$(SolutionDir)Combot.Servers.$(ConfigurationName).config" "$(TargetDir)Combot.Servers.config"</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.

42
Modules/Decide/Decide.cs

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
namespace Combot.Modules.Plugins
{
public class Decide : 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 "Decide":
string options = command.Arguments["Options"].ToString();
List<string> optionList = options.Split(new[] {" or "}, StringSplitOptions.RemoveEmptyEntries).ToList();
if (optionList.Count > 1)
{
Random rand = new Random();
int choiceIndex = rand.Next(0, optionList.Count);
JArray prefixes = (JArray)GetOptionValue("Choice Prefixes");
int prefixIndex = rand.Next(0, prefixes.Count);
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("{0} {1}", prefixes[prefixIndex], optionList[choiceIndex]));
}
else
{
Random rand = new Random();
JArray answers = (JArray)GetOptionValue("Choice Answers");
int answerIndex = rand.Next(0, answers.Count);
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("{0}", answers[answerIndex]));
}
break;
}
}
}
}

79
Modules/Decide/Decide.csproj

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
<?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>{6CB41404-02E8-4CA3-834C-CE8C30999450}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Decide</RootNamespace>
<AssemblyName>Decide</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\Decide\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\Decide\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<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="Decide.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>
<None Include="packages.config" />
</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>

84
Modules/Decide/Module.config

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
{
"Name": "Decide",
"ClassName": "Decide",
"Enabled": true,
"ChannelBlacklist": [],
"NickBlacklist": [],
"Commands": [
{
"Name": "Decide",
"Description": "Makes a decision based on the options given.",
"Enabled": true,
"ChannelBlacklist": [],
"NickBlacklist": [],
"Triggers": [
"decide"
],
"Arguments": [
{
"Name": "Options",
"Description": "The options you want decided on for. Separate options by \u0002or\u0002.",
"AllowedValues": [],
"DependentArguments": [],
"MessageTypes": [
0,
1,
2
],
"Required": true
}
],
"AllowedMessageTypes": [
0,
1,
2
],
"AllowedAccess": [
0,
1,
2,
3,
4,
5,
6
],
"ShowHelp": true,
"SpamCheck": true
}
],
"Options": [
{
"Name": "Choice Prefixes",
"Description": "The list of prefixes to use for when choosing an option.",
"Value": [
"Hm... I'd have to say",
"Do",
"Absolutly",
"How about",
"You should",
"Possibly",
"Not",
"Please do"
]
},
{
"Name": "Choice Answers",
"Description": "The list of answers for a single option question.",
"Value": [
"Maybe...",
"Sure!",
"Just a little",
"How about no",
"Never in a million years",
"But of course!",
"Why not?",
"Yes",
"No",
"Never",
"Possibly",
"Surely",
"Very probable"
]
}
]
}

36
Modules/Decide/Properties/AssemblyInfo.cs

@ -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("Decide 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")]

4
Modules/Decide/packages.config

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
</packages>

4
Modules/Fun/Fun.cs

@ -17,7 +17,7 @@ namespace Combot.Modules.Plugins @@ -17,7 +17,7 @@ namespace Combot.Modules.Plugins
{
case "Love":
Random random = new Random();
int randNum = random.Next(0, 3);
int randNum = random.Next(0, 4);
switch (randNum)
{
case 0:
@ -48,7 +48,7 @@ namespace Combot.Modules.Plugins @@ -48,7 +48,7 @@ namespace Combot.Modules.Plugins
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, "Sure is enterprise quality in here.");
break;
case "Bot Response":
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, GetOptionValue("Response"));
SendResponse(command.MessageType, command.Location, command.Nick.Nickname, GetOptionValue("Response").ToString());
break;
}
}

2
Modules/Introductions/Introductions.cs

@ -46,7 +46,7 @@ namespace Combot.Modules.Plugins @@ -46,7 +46,7 @@ namespace Combot.Modules.Plugins
if (results.Any())
{
Random randNum = new Random();
int index = randNum.Next(results.Count - 1);
int index = randNum.Next(0, results.Count);
Dictionary<string, object> intro = results[index];
Bot.IRC.SendPrivateMessage(info.Channel, string.Format("\u200B{0}", intro["message"]));
}

2
Modules/Messaging/Messaging.cs

@ -55,7 +55,7 @@ namespace Combot.Modules.Plugins @@ -55,7 +55,7 @@ namespace Combot.Modules.Plugins
{
List<Dictionary<string, object>> currentMessages = GetSentMessages(command.Arguments["Nickname"]);
int numMessages = currentMessages.Select(msg => GetNickname((int) msg["nick_id"]) == command.Nick.Nickname).Count();
if (numMessages < GetOptionValue("Max Messages"))
if (numMessages < (int)GetOptionValue("Max Messages"))
{
AddNick(command.Nick.Nickname);
AddNick(command.Arguments["Nickname"]);

2
Modules/Owner Control/Owner_Control.cs

@ -3,6 +3,7 @@ using System.Diagnostics; @@ -3,6 +3,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
namespace Combot.Modules.Plugins
{
@ -86,6 +87,7 @@ namespace Combot.Modules.Plugins @@ -86,6 +87,7 @@ namespace Combot.Modules.Plugins
break;
case "server":
Bot.Disconnect();
Thread.Sleep(1000);
Bot.Connect();
break;
case "client":

2
Modules/Spam Control/Module.config

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
"Value": 5
},
{
"Name": "Maximum Highlights",
"Name": "Max Highlights",
"Description": "The maximum number of highlights allowed in a set period of time.",
"Value": 5
},

1
Modules/Spam Control/Spam Control.csproj

@ -58,6 +58,7 @@ @@ -58,6 +58,7 @@
<ItemGroup>
<None Include="Module.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

15
Modules/Spam Control/Spam_Control.cs

@ -27,6 +27,9 @@ namespace Combot.Modules.Plugins @@ -27,6 +27,9 @@ namespace Combot.Modules.Plugins
{
if (!ChannelBlacklist.Contains(message.Channel) && !NickBlacklist.Contains(message.Sender.Nickname))
{
int timeThreshold = Convert.ToInt32(GetOptionValue("Time Threshold"));
int maxMessages = Convert.ToInt32(GetOptionValue("Max Messages"));
int maxHighlights = Convert.ToInt32(GetOptionValue("Max Highlights"));
// Check for line spam
if (SpamMessageList.Exists(msg => msg.Channel == message.Channel && msg.Nick == message.Sender.Nickname))
{
@ -34,12 +37,12 @@ namespace Combot.Modules.Plugins @@ -34,12 +37,12 @@ namespace Combot.Modules.Plugins
SpamMessageInfo info = SpamMessageList.Find(msg => msg.Channel == message.Channel && msg.Nick == message.Sender.Nickname);
SpamMessageLock.ExitReadLock();
TimeSpan difference = message.TimeStamp.Subtract(info.FirstMessageTime);
if (difference.TotalMilliseconds < (int) GetOptionValue("Time Threshold"))
if (difference.TotalMilliseconds < timeThreshold)
{
info.Lines++;
if (info.Lines > (int) GetOptionValue("Max Messages"))
if (info.Lines > maxMessages)
{
Bot.IRC.SendKick(info.Channel, info.Nick, string.Format("Please do not spam. You have messaged {0} times within {1}ms.", info.Lines, GetOptionValue("Time Threshold")));
Bot.IRC.SendKick(info.Channel, info.Nick, string.Format("Please do not spam. You have messaged {0} times within {1}ms.", info.Lines, timeThreshold));
SpamMessageLock.EnterWriteLock();
SpamMessageList.Remove(info);
SpamMessageLock.ExitWriteLock();
@ -89,12 +92,12 @@ namespace Combot.Modules.Plugins @@ -89,12 +92,12 @@ namespace Combot.Modules.Plugins
SpamHighlightInfo info = SpamHighlightList.Find(highlight => highlight.Channel == message.Channel && highlight.Nick == message.Sender.Nickname);
SpamHighlightLock.ExitReadLock();
TimeSpan difference = message.TimeStamp.Subtract(info.FirstHighlightTime);
if (difference.TotalMilliseconds < (int) GetOptionValue("Time Threshold"))
if (difference.TotalMilliseconds < timeThreshold)
{
info.Highlights += foundNicks.Count;
if (info.Highlights > (int) GetOptionValue("Maximum Highlights"))
if (info.Highlights > maxHighlights)
{
Bot.IRC.SendKick(info.Channel, info.Nick, string.Format("Please do not highlight spam. You have highlighted {0} nicks within {1}ms.", info.Highlights, GetOptionValue("Time Threshold")));
Bot.IRC.SendKick(info.Channel, info.Nick, string.Format("Please do not highlight spam. You have highlighted {0} nicks within {1}ms.", info.Highlights, timeThreshold));
SpamHighlightLock.EnterWriteLock();
SpamHighlightList.Remove(info);
SpamHighlightLock.ExitWriteLock();

3
Modules/Url Parsing/Url_Parsing.cs

@ -27,6 +27,9 @@ namespace Combot.Modules.Plugins @@ -27,6 +27,9 @@ namespace Combot.Modules.Plugins
Uri url = new Uri(urlMatch.Value);
WebRequest webRequest = HttpWebRequest.Create(url);
webRequest.Method = "HEAD";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
using (WebResponse webResponse = webRequest.GetResponse())
{
string contentType = webResponse.ContentType.Split('/')[0];

Loading…
Cancel
Save