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 namespace DeukBot4.APIHandlers
{ {
public class CatPicHandler public static class CatPicHandler
{ {
private const string URL = "https://cataas.com"; private const string URL = "https://cataas.com";

View File

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

View File

@ -82,21 +82,32 @@ namespace DeukBot4.MessageHandlers
if (!(message.Author is IGuildUser guildUser)) if (!(message.Author is IGuildUser guildUser))
return; return;
string newName; 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') if (lower[0] != 'i')
return; return;
if (lower.StartsWith("i'm ")) if (lower.StartsWith("i'm "))
{ {
newName = message.Content.Remove(0, 4); newName = content.Remove(0, 4);
} }
else if (lower.StartsWith("im ")) else if (lower.StartsWith("im "))
{ {
newName = message.Content.Remove(0, 3); newName = content.Remove(0, 3);
} }
else if (lower.StartsWith("i am ")) else if (lower.StartsWith("i am "))
{ {
newName = message.Content.Remove(0, 5); newName = content.Remove(0, 5);
} }
else else
{ {