Giter Site home page Giter Site logo

schedulerbot's People

Contributors

jespirit avatar pyrox18 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

jespirit biskit1

schedulerbot's Issues

EventParser incorrectly detecting seasons as date ranges

Reset the timezone entry in the database for a calendar if the timezone is found to be invalid. Probably can implement as an additional calendar service method, and call it when catching the KeyNotFoundException when attempting to retrieve the timezone from the Tzdb collection. see next comment

https://sentry.io/pyrox18/schedulerbot/issues/712811536/

KeyNotFoundException: The given key 'start' was not present in the dictionary.
  File "/src/SchedulerBot.Client/Parsers/EventParser.cs", line 258, in ParseEventTimestamps
    Void ParseEventTimestamps(System.String, System.String, SchedulerBot.Data.Models.Event ByRef)
  File "/src/SchedulerBot.Client/Parsers/EventParser.cs", line 27, in ParseNewEvent
    SchedulerBot.Data.Models.Event ParseNewEvent(System.String[], System.String)
  File "/src/SchedulerBot.Client/Commands/EventCommands.cs", line 53, in Create
    Void MoveNext()
  Module "DSharpPlus.CommandsNext.Command", line 654, in ExecuteAsync
    Void MoveNext()
...
(2 additional frame(s) were not displayed)

The given key 'start' was not present in the dictionary.

Updating an event with incorrect flag still shows 'Updated event.'

SchedulerBot Version: v2.1.4 a055321

I was testing the other changes I made and came across this.

+event list 1

first-event

I want to update the description. Notice: I don't enter any event name or date/time information.
+event update 1 --description new description here

update-event-bug

I just wanted to update the description, mispelled flag (should be --desc), and it still shows that the event was updated 'Updated event.'

+event update and list hang when event has no name

I tried creating an event and then updating the event to start at a later time, except I didn't include the name for the event. The event is updated with the new time (I checked PostgreSQL database) but the "Updated event." and the yellow event information box doesn't show up. It seems that SchedulerBot just hangs. The same thing happens when I run the +event list 1 command to display the event details and again SchedulerBot hangs.

Steps to recreate:

  1. +event dummy1 today at 10:00pm
  2. +event update 1 today at 10:30pm (SchedulerBot hangs here)
  3. +event list 1 (SchedulerBot hangs again here)

It seems as if I was able to fix it by testing to check if the event name was null or empty before adding a field to the DiscordEmbedBuilder in EventEmbedFactory.cs file.

embed.AddField("Event Name", string.IsNullOrEmpty(evt.Name) ? "N/A" : evt.Name);

event-update-hangs

Installation and usage assumes a Git bash prompt

I was following the steps in the "Installation and Usage" and I didn't even realize the commands were intended to be used a Git bash or similiar environment. In fact, I had problems migrating the data in step 6. I was using the Visual Studio command prompt, so I had to use an alternative so I can set the environment variable on the same line as running the command.

Git Bash

$ ASPNETCORE_ENVIRONMENT=Development dotnet ef database update -s ../SchedulerBot.Client/SchedulerBot.Client.csproj

Windows Command Prompt

> set "ASPNETCORE_ENVIRONMENT=Development" && dotnet ef database update -s ..\SchedulerBot.Client\SchedulerBot.Client.csproj

Note: You have to include the quotes because ASPNETCORE_ENVIRONMENT will actually include the trailing space. I was getting the following error because there was a space just before the .json file extension.

System.IO.FileNotFoundException: Could not find file 'D:\Path\To\Repos\SchedulerBot\SchedulerBot.Client\appsettings.Development .json'.

Date and time ranges will throw KeyNotFoundException

I was doing research on the natural language feature that was used to parse date and time text information and I was able to generate an exception when you use keywords like before, after, since, and until without specifying either the start or end of the date or time range.

Below are some of the examples to recreate the exception.

+event dummy before november 10

An error has occurred. Please report this in the support server using the support command.
Error event ID: 8a3c07e7-56cd-448a-880e-eccf644840ab
The given key 'start' was not present in the dictionary.

+event dummy after november 10

An error has occurred. Please report this in the support server using the support command.
Error event ID: 47f3b521-d8fe-415b-be69-2cc84eca03b2
The given key 'end' was not present in the dictionary.

+event dummy since november 10

An error has occurred. Please report this in the support server using the support command.
Error event ID: 16296126-a36a-424d-b903-3d100b178e2d
The given key 'end' was not present in the dictionary.

+event dummy until november 10

An error has occurred. Please report this in the support server using the support command.
Error event ID: 9c8d6900-6de9-4198-a50f-6bd1e60da76f
The given key 'start' was not present in the dictionary.

I was able to trace it and it comes down to parsing date and time ranges, specifically subtypes daterange, timerange, and datetimerange.

string fromString = resolutionValues.First()["start"];
string toString = resolutionValues.First()["end"];

string fromString = resolutionValues.First()["start"];
string toString = resolutionValues.First()["end"];

I guess you can create a new exception type like class InvalidDateTimeRange or just throw EventParseException when the start or end keys do not exist.

AmbiguousTimeException is thrown when parsing timestamps that are ambiguous due to daylight savings

This issue is due to the use of the AtStrictly method to convert timestamps to zoned timestamps.

https://sentry.io/pyrox18/schedulerbot/issues/713200092/

AmbiguousTimeException: Specified argument was out of the range of valid values.
Parameter name: Local time 11/04/2018 01:00:00 is ambiguous in time zone America/New_York
  Module "NodaTime.TimeZones.Resolvers+<>c", line 7, in <.cctor>b__28_2
    NodaTime.ZonedDateTime <.cctor>b__28_2(NodaTime.ZonedDateTime, NodaTime.ZonedDateTime)
  Module "NodaTime.TimeZones.Resolvers+<>c__DisplayClass27_0", line 82, in CreateMappingResolver { <lambda> }
    NodaTime.ZonedDateTime <CreateMappingResolver>b__0(NodaTime.TimeZones.ZoneLocalMapping)
  File "/src/SchedulerBot.Data/Services/EventService.cs", line 458, in AdjustTimestampsToTimezone
    Void AdjustTimestampsToTimezone(SchedulerBot.Data.Models.Event ByRef, System.String)
  File "/src/SchedulerBot.Data/Services/EventService.cs", line 68, in GetEventsAsync
    Void MoveNext()
  File "/src/SchedulerBot.Client/Commands/EventCommands.cs", line 110, in List
    Void MoveNext()
...
(4 additional frame(s) were not displayed)

Specified argument was out of the range of valid values.
Parameter name: Local time 11/04/2018 01:00:00 is ambiguous in time zone America/New_York

Event parser throws ArgumentOutOfRangeException when repeat flag is passed without an argument

Need to add checks for repeat flag arguments (and potentially all other flags) to prevent this error from occurring.

https://sentry.io/pyrox18/schedulerbot/issues/716327494/

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  File "/src/SchedulerBot.Client/Parsers/EventParser.cs", line 85, in ParseEventInputFlags
    Void ParseEventInputFlags(System.String[], SchedulerBot.Data.Models.Event ByRef, System.String)
  File "/src/SchedulerBot.Client/Parsers/EventParser.cs", line 29, in ParseNewEvent
    SchedulerBot.Data.Models.Event ParseNewEvent(System.String[], System.String)
  File "/src/SchedulerBot.Client/Commands/EventCommands.cs", line 53, in Create
    Void MoveNext()
  Module "DSharpPlus.CommandsNext.Command", line 654, in ExecuteAsync
    Void MoveNext()
...
(1 additional frame(s) were not displayed)

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Add monthly event repeat type based on weekday

This repeat type should cause an event to reschedule itself to the same day of the nth week in the following month.

e.g. +event Test Oct 1 2018 9am --repeat mw creates an event that falls on the first Monday of October 2018. The repeat trigger should reschedule the event to the first Monday of November 2018, which is 5 November 2018.

  • Create new repeat type in the RepeatType enum
  • Add repeat logic in RepeatJob
  • Add mw as argument for the --repeat flag
  • Update help commands for +event and +event update

'Event' reference type is passed by reference

The Event class is a reference type, should you be passing the Event object by reference to methods ParseEventInputFlags and ParseEventTimestamps? I don't believe those methods actually modify the storage location of the evt argument.

public static Event ParseUpdateEvent(Event evt, string[] args, string timezone)
{
var bodyString = ParseEventInputBody(args);
if (!string.IsNullOrEmpty(bodyString))
{
ParseEventTimestamps(bodyString, timezone, ref evt);
}
ParseEventInputFlags(args, ref evt, timezone);
return evt;
}

private static void ParseEventInputFlags(string[] args, ref Event evt, string timezone) {...}
private static void ParseEventTimestamps(string bodyString, string timezone, ref Event evt) {...}

Since, the ref keyword would actually allow one to replace the object that evt refers to. As a reference: C# ref keyword

class Product
{
    public Product(string name, int newID)
    {
        ItemName = name;
        ItemID = newID;
    }

    public string ItemName { get; set; }
    public int ItemID { get; set; }
}

private static void ModifyProductsByReference()
{
    // Declare an instance of Product and display its initial values.
    Product item = new Product("Fasteners", 54321);
    System.Console.WriteLine("Original values in Main.  Name: {0}, ID: {1}\n",
        item.ItemName, item.ItemID);

    // Pass the product instance to ChangeByReference.
    ChangeByReference(ref item);
    System.Console.WriteLine("Back in Main.  Name: {0}, ID: {1}\n",
        item.ItemName, item.ItemID);
}

private static void ChangeByReference(ref Product itemRef)
{
    // Change the address that is stored in the itemRef parameter.   
    itemRef = new Product("Stapler", 99999);

    // You can change the value of one of the properties of
    // itemRef. The change happens to item in Main as well.
    itemRef.ItemID = 12345;
}

Update configuration examples in readme

Most of the settings are already present in SchedulerBot.Client/appsettings.json, so the configuration sections in the readme should be rewritten to indicate that appsettings.*.json files are only for overriding the default settings provided.

Also need to remove the Redis connection string requirement, as that's no longer part of the bot's requirements.

  • Remove Redis connection string from appsettings.Development.json example
  • Rewrite "Installation and Usage" step 4 to indicate that the development configuration file should only include properties that the user wants to override from the default appsettings.json file
  • Modify appsettings.Development.json example to only include the Logging.LogLevel.Default, ConnectionStrings.SchedulerBotContext and Bot.Token properties
  • Modify appsettings.Production.json example to only include the properties from appsettings.Development.json minus Logging.LogLevel.Default, with the addition of Raven.DSN
  • Add statement in the "Production Configuration" section indicating that the configuration settings can also be modified by passing environment variables (reference)

Local reference 'updatedEvent' is never used

Event updatedEvent;
try
{
updatedEvent = EventParser.ParseUpdateEvent(evt, args, timezone);
}
catch (DateTimeInPastException)
{
await ctx.RespondAsync("Cannot create an event that starts or ends in the past, or has a reminder that is in the past.");
return;
}
catch (EventEndBeforeStartException)
{
await ctx.RespondAsync("Cannot create an event that ends before it starts.");
return;
}
catch (EventParseException)
{
await ctx.RespondAsync("Failed to parse event data.");
return;
}
Event savedEvent;
savedEvent = await _eventService.UpdateEventAsync(evt);

Line 243 should be:

savedEvent = await _eventService.UpdateEventAsync(updatedEvent);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.