pyrox18 / schedulerbot Goto Github PK
View Code? Open in Web Editor NEWA Discord bot for scheduling events
License: GNU General Public License v3.0
A Discord bot for scheduling events
License: GNU General Public License v3.0
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'.
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.
appsettings.Development.json
exampleappsettings.json
fileappsettings.Development.json
example to only include the Logging.LogLevel.Default
, ConnectionStrings.SchedulerBotContext
and Bot.Token
propertiesappsettings.Production.json
example to only include the properties from appsettings.Development.json
minus Logging.LogLevel.Default
, with the addition of Raven.DSN
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.
SchedulerBot/SchedulerBot.Client/Parsers/EventParser.cs
Lines 32 to 42 in 85bfb78
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;
}
SchedulerBot Version: v2.1.4 a055321
I was testing the other changes I made and came across this.
+event list 1
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
I just wanted to update the description, mispelled flag (should be --desc
), and it still shows that the event was updated 'Updated event.'
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.
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
.
SchedulerBot/SchedulerBot.Client/Parsers/EventParser.cs
Lines 295 to 296 in 85bfb78
SchedulerBot/SchedulerBot.Client/Parsers/EventParser.cs
Lines 367 to 368 in 85bfb78
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.
An event's reminder field does not save when a remind flag is passed in an event update command.
SchedulerBot/SchedulerBot.Client/Commands/EventCommands.cs
Lines 221 to 243 in 85bfb78
Line 243 should be:
savedEvent = await _eventService.UpdateEventAsync(updatedEvent);
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.
RepeatType
enumRepeatJob
mw
as argument for the --repeat
flag+event
and +event update
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
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
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:
+event dummy1 today at 10:00pm
+event update 1 today at 10:30pm
(SchedulerBot hangs here)+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);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.