Some fixes

This commit is contained in:
Deukhoofd 2018-04-21 23:01:44 +02:00
parent 670df57e86
commit 42d169f157
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
4 changed files with 22 additions and 2 deletions

View File

@ -56,15 +56,17 @@ namespace DeukBot4.MessageHandlers
using (var client = new WebClient()) using (var client = new WebClient())
{ {
var content = client.DownloadData(attachment.Url); var content = client.DownloadData(attachment.Url);
var uri = new Uri($"{Settings.URL}/{attachment.Filename}"); var uri = new Uri($"{Settings.URL}/{attachment.Filename}-{DateTime.UtcNow:s}");
client.Credentials = new NetworkCredential(Settings.Username, Settings.Password); client.Credentials = new NetworkCredential(Settings.Username, Settings.Password);
try try
{ {
client.UploadData(uri, "PUT", content); client.UploadData(uri, "PUT", content);
var attachmentSplit = attachment.Filename.Split('.');
var eb = new EmbedBuilder() var eb = new EmbedBuilder()
{ {
Title = "Image Backed Up", Title = "Image Backed Up",
Description = $"Image with the name {attachment.Filename} was backed up", Description = $"Image with the name ``{attachment.Filename}`` was backed up as " +
$"``{attachmentSplit[0]}-{DateTime.UtcNow:s}.{attachmentSplit[1]}``",
ThumbnailUrl = attachment.Url, ThumbnailUrl = attachment.Url,
Timestamp = DateTime.UtcNow Timestamp = DateTime.UtcNow
}; };

View File

@ -18,6 +18,7 @@ namespace DeukBot4.MessageHandlers
CommandHandler.CommandHandler.HandleMessage(message); CommandHandler.CommandHandler.HandleMessage(message);
HandlePrivateMessage(message); HandlePrivateMessage(message);
ImageBackupHandler.Backup(message); ImageBackupHandler.Backup(message);
DeltaHandler(message);
#pragma warning restore 4014 #pragma warning restore 4014
} }
catch (Exception e) catch (Exception e)
@ -33,5 +34,21 @@ namespace DeukBot4.MessageHandlers
await Logger.Log(($"Private Message: {message.Author.Username}- {message.Content}")); await Logger.Log(($"Private Message: {message.Author.Username}- {message.Content}"));
} }
} }
private static async Task DeltaHandler(SocketMessage message)
{
var lower = message.Content.ToLowerInvariant().Split(' ');
foreach (var s in lower)
{
var diff = Utilities.Lehvenstein.LevenshteinDistance(s, "delta");
if (diff <= 1)
{
await message.Channel.SendMessageAsync("uhh excuse me it's called Origin and it's an art");
break;
}
}
}
} }
} }

View File

@ -51,6 +51,7 @@ namespace DeukBot4
await Client.CurrentUser.ModifyAsync(properties => await Client.CurrentUser.ModifyAsync(properties =>
{ {
properties.Username = Settings.Username; properties.Username = Settings.Username;
properties.Avatar = new Image("avatar.png");
}); });
BotId = Client.CurrentUser.Id; BotId = Client.CurrentUser.Id;
} }

BIN
DeukBot4/avatar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB