Start tidying some stuff up, & support date ranges
This commit is contained in:
parent
4875d749d1
commit
131157c50b
3 changed files with 10 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Recognizers.Text;
|
||||
using Microsoft.Recognizers.Text.DateTime;
|
||||
using SBRL.Geometry;
|
||||
|
@ -57,7 +58,7 @@ namespace RhinoReminds
|
|||
throw new AIException($"Error: An invalid type of {type} was encountered ('datetime' expected).");
|
||||
|
||||
|
||||
string result = type == "datetimerange" ? aiResult["start"] : aiResult["value"];
|
||||
string result = Regex.IsMatch(type, @"range$") ? aiResult["start"] : aiResult["value"];
|
||||
return DateTime.Parse(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace RhinoReminds
|
|||
}
|
||||
|
||||
private void sendChatMessage(Jid to, string message) {
|
||||
Console.WriteLine($"[Rhino/Send/Chat] Sending {message} -> {to}");
|
||||
//Console.WriteLine($"[Rhino/Send/Chat] Sending {message} -> {to}");
|
||||
client.SendMessage(
|
||||
to, message,
|
||||
null, null, MessageType.Chat
|
||||
|
@ -166,7 +166,7 @@ namespace RhinoReminds
|
|||
}
|
||||
private void sendChatReply(Message originalMessage, string reply)
|
||||
{
|
||||
Console.WriteLine($"[Rhino/Send/Reply] Sending {reply} -> {originalMessage.From}");
|
||||
//Console.WriteLine($"[Rhino/Send/Reply] Sending {reply} -> {originalMessage.From}");
|
||||
client.SendMessage(
|
||||
originalMessage.From, reply,
|
||||
null, originalMessage.Thread, MessageType.Chat
|
||||
|
|
|
@ -8,10 +8,14 @@ namespace RhinoReminds
|
|||
{
|
||||
public delegate void OnReminderListUpdateHandler(object sender, Reminder newReminder);
|
||||
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class ReminderList
|
||||
{
|
||||
private int nextId = 0;
|
||||
[JsonProperty]
|
||||
public int NextId { get; private set; } = 0;
|
||||
private object saveLock = new object();
|
||||
|
||||
[JsonProperty]
|
||||
public SortedList<DateTime, Reminder> Reminders = new SortedList<DateTime, Reminder>();
|
||||
|
||||
public event OnReminderListUpdateHandler OnReminderListUpdate;
|
||||
|
@ -22,7 +26,7 @@ namespace RhinoReminds
|
|||
}
|
||||
|
||||
public Reminder CreateReminder(Jid inJid, DateTime time, string message) {
|
||||
Reminder result = new Reminder(nextId++, $"{inJid.Node}@{inJid.Domain}", time, message);
|
||||
Reminder result = new Reminder(NextId++, $"{inJid.Node}@{inJid.Domain}", time, message);
|
||||
Console.WriteLine($"[Rhino/ReminderList] Created reminder {result}");
|
||||
Reminders.Add(time, result);
|
||||
OnReminderListUpdate(this, result);
|
||||
|
|
Loading…
Reference in a new issue