public NotifyEventTests() { NotifyEventManager.LoadAndEnableEvents(); if (File.Exists(NotifyEventManager.NOTIFY_FILE_PATH)) { File.Delete(NotifyEventManager.NOTIFY_FILE_PATH); } }
public async Task EventUnsubscribe(CommandContext ctx, [RemainingText] string eventName) { logger.Info("Event Unsubscribe Command", Useful.GetDiscordName(ctx)); bool result = NotifyEventManager.UnsubscribeUserToEvent(ctx.User.Id, ctx.Guild.Id, eventName); string message = result ? "Removed sucessfully from " + eventName : "Error"; await ctx.Message.RespondAsync(message).ConfigureAwait(false); }
public void NoRepatedEventNames() { //Example for event starting at 6am utc, repeating every day string userInput = "Genshin3; 13 March 2021, 06:00AM; 1:0:0:0"; NotifyEventManager.AddEvent(userInput); Assert.Throws <ArgumentException>(() => NotifyEventManager.AddEvent(userInput)); Assert.Equal(1, NotifyEventManager.NotifyEventCount()); }
public void ParseUserInput() { //Example for event starting at 6am utc, repeating every day string userInput = "Genshin Impact Daily login; 13 March 2021, 06:00AM; 1:0:0:0"; DateTime date = new DateTime(2021, 03, 13, 6, 0, 0, DateTimeKind.Utc); TimeSpan span = new TimeSpan(1, 0, 0, 0); (string, DateTime, TimeSpan)result = NotifyEventManager.InputArgumentToEventData(userInput); Assert.Equal("Genshin Impact Daily login", result.Item1); Assert.Equal(date, result.Item2); Assert.Equal(span, result.Item3); }
public void NoRepeatedUserSubscriber() { //Example for event starting at 6am utc, repeating every day string userInput = "Genshin2; 13 March 2021, 06:00AM; 1:0:0:0"; NotifyEventManager.AddEvent(userInput); ulong userID = 132; ulong userGuild = 321; NotifyEventManager.SubscribeUserToEvent(userID, userGuild, "Genshin2"); Assert.False(NotifyEventManager.SubscribeUserToEvent(userID, userGuild, "Genshin2")); }
public async Task EventDisable(CommandContext ctx, [RemainingText] string eventName) { logger.Info("Event Disable Command", Useful.GetDiscordName(ctx)); try { NotifyEventManager.DisableEvent(eventName); await ctx.Message.RespondAsync("Disabled " + eventName + " sucessfully").ConfigureAwait(false); } catch (ArgumentException ex) { await ctx.Message.RespondAsync("Error, event probably not found").ConfigureAwait(false); logger.Error("Error disabling event: " + ex.Message, Useful.GetDiscordName(ctx)); } }
public async Task EventDelete(CommandContext ctx, [RemainingText] string eventName) { logger.Info("Remove Event Command", Useful.GetDiscordName(ctx)); string message; try { NotifyEventManager.RemoveEvent(eventName); message = "Event Removed."; } catch (Exception ex) { message = "Event not removed. Error: " + ex.Message; } await ctx.Message.RespondAsync(message).ConfigureAwait(false); }
public async Task EventCreate(CommandContext ctx, [RemainingText] string args) { logger.Info("Create Event Command", Useful.GetDiscordName(ctx)); string message; try { NotifyEventManager.AddEvent(args); message = "Event added. Now activate it manually"; } catch (Exception ex) { message = "Event not created, error: " + ex.Message; } await ctx.Message.RespondAsync(message).ConfigureAwait(false); }
public async Task EventList(CommandContext ctx, [RemainingText] string args) { logger.Info("List Event Command", Useful.GetDiscordName(ctx)); if (NotifyEventManager.NotifyEventCount() == 0) { await ctx.Message.RespondAsync("No Events saved").ConfigureAwait(false); return; } string[] events = NotifyEventManager.getNotifyEventDetails(!string.IsNullOrWhiteSpace(args) && args.Trim().ToLower() == "extra"); StringBuilder builder = new StringBuilder().Append("```"); foreach (string eventDetail in events) { builder.AppendLine(eventDetail); } builder.Append("```"); await ctx.Message.RespondAsync(builder.ToString()).ConfigureAwait(false); }
public void EventNotFoundError() { Assert.Throws <NullReferenceException>(() => NotifyEventManager.EnableEvent("Booba")); }