Better handling of dadjokes

This commit is contained in:
Deukhoofd 2018-07-30 20:24:55 +02:00
parent 9fd67f6ec7
commit fe6639a1e0
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 19 additions and 8 deletions

View File

@ -8,7 +8,7 @@ using Discord;
namespace DeukBot4.APIHandlers
{
public class CatPicHandler
public static class CatPicHandler
{
private const string URL = "https://cataas.com";

View File

@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.App" Version="2.0.0" />
<PackageReference Include="Discord.Net" Version="2.0.0-beta" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Npgsql" Version="4.0.0-preview1" />
<PackageReference Include="Npgsql" Version="4.0.2" />
</ItemGroup>
</Project>

View File

@ -82,21 +82,32 @@ namespace DeukBot4.MessageHandlers
if (!(message.Author is IGuildUser guildUser))
return;
string newName;
var lower = message.Content.ToLowerInvariant();
var content = message.Content;
var lower = content.ToLowerInvariant();
if (lower.StartsWith("hi "))
{
lower = lower.Remove(0, 3);
content = content.Remove(0, 3);
}
else if (lower.StartsWith("hello "))
{
lower = lower.Remove(0, 6);
content = content.Remove(0, 6);
}
if (lower[0] != 'i')
return;
if (lower.StartsWith("i'm "))
{
newName = message.Content.Remove(0, 4);
newName = content.Remove(0, 4);
}
else if (lower.StartsWith("im "))
{
newName = message.Content.Remove(0, 3);
newName = content.Remove(0, 3);
}
else if (lower.StartsWith("i am "))
{
newName = message.Content.Remove(0, 5);
newName = content.Remove(0, 5);
}
else
{