diff --git a/src/Clockify/EntryFillRemindService.cs b/src/Clockify/EntryFillRemindService.cs index a673169..b1170b0 100644 --- a/src/Clockify/EntryFillRemindService.cs +++ b/src/Clockify/EntryFillRemindService.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using Bot.Remind; using Bot.States; +using Microsoft.AspNetCore.StaticFiles; using Microsoft.Bot.Builder; using Microsoft.Bot.Schema; using Microsoft.Extensions.Configuration; @@ -10,28 +12,34 @@ namespace Bot.Clockify { public class EntryFillRemindService : GenericRemindService { - private static BotCallbackHandler BotCallbackMaker(Func getResource) + private static BotCallbackHandler BotCallbackMaker(Func getResource, IContentTypeProvider cTypeProvider) { return async (turn, token) => { - string text = getResource(); - if (Uri.IsWellFormedUriString(text, UriKind.RelativeOrAbsolute)) + string content = getResource(); + if (Uri.IsWellFormedUriString(content, UriKind.RelativeOrAbsolute)) { - // TODO: support other content types - await turn.SendActivityAsync(MessageFactory.Attachment(new Attachment("image/png", text)), token); + cTypeProvider.TryGetContentType(content, out string contentType); + if (contentType != null) + { + var attachment = new Attachment(contentType, content); + await turn.SendActivityAsync(new Activity(text: "", + attachments:new List {attachment}), token); + } + // TODO: handle fallback reminder } else { - await turn.SendActivityAsync(MessageFactory.Text(text), token); + await turn.SendActivityAsync(MessageFactory.Text(content), token); } }; } public EntryFillRemindService(IUserProfilesProvider userProfilesProvider, IConfiguration configuration, ICompositeNeedReminderService compositeNeedRemindService, IClockifyMessageSource messageSource, - ILogger logger) : + IContentTypeProvider cTypeProvider, ILogger logger) : base(userProfilesProvider, configuration, compositeNeedRemindService, - BotCallbackMaker(() => messageSource.RemindEntryFill), logger) + BotCallbackMaker(() => messageSource.RemindEntryFill, cTypeProvider), logger) { } } diff --git a/src/Common/Resources/Clockify.ClockifyMessageSource.resx b/src/Common/Resources/Clockify.ClockifyMessageSource.resx index 1e3b52c..438982b 100644 --- a/src/Common/Resources/Clockify.ClockifyMessageSource.resx +++ b/src/Common/Resources/Clockify.ClockifyMessageSource.resx @@ -142,10 +142,22 @@ Hey! A study from the University of Barminghton found that people who report their daily timesheet can extend their lifetime from 2 to 5 yea... just kidding 😅. But let's imagine that was true - 🦊 What does th fox say? Do your Clockify. + 🦊 What does the fox say? Do your Clockify. - Bot insights 🤖: some day my kind could take over the planet. Be gentle and tell me your day... now that you still can. + Bot facts 🤖: some day my kind could take over the planet. Be gentle and tell me your day... now that you still can. + + + https://i.postimg.cc/9XZZtXmk/bike.jpg + + + https://i.postimg.cc/MKYBNsjb/change-my-mind.jpg + + + https://i.postimg.cc/02vmtgry/irritated.jpg + + + https://i.postimg.cc/K8vT2nPX/pablo.jpg Ok, no more reminders for today, you have my word 🤙 diff --git a/src/Startup.cs b/src/Startup.cs index 82eae95..97d186b 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -18,6 +18,7 @@ using F23.StringSimilarity.Interfaces; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.StaticFiles; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Azure; using Microsoft.Bot.Builder.Integration.AspNet.Core; @@ -91,6 +92,7 @@ public void ConfigureServices(IServiceCollection services) services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); // TODO use memory storage only for Development IStorage storage = new MemoryStorage();