Ejemplo n.º 1
0
        private async Task WriteReminder(StreamWriter writer, string message, ChatReply chatReply, string replyTo, IServiceProvider services)
        {
            string username = chatReply.User.Substring(1).Split("!")[0];

            string[] input    = message.Split("-");
            Reminder reminder = Reminder.CreateReminder(input, username, replyTo);

            if (reminder != null)
            {
                using var scope = services.CreateScope();
                ReminderRepository repository  = scope.ServiceProvider.GetRequiredService <ReminderRepository>();
                Reminder           newReminder = await repository.Insert(reminder);

                writer.WriteLine(newReminder?.GetSendMessage());
                writer.Flush();
                await ReminderContainer.AddReminder(reminder);
            }
            else
            {
                writer.WriteLine($"PRIVMSG {replyTo} reminder format is #y#mo#w#d#m#h#s - reminder message");
                writer.Flush();
            }
        }