kangarko / ChatControl-Red

Issue tracker and documentation for the next generation ChatControl Red, the most advanced chat management plugin.
49 stars 23 forks source link

Add "begin" option for messages #2329

Closed TomLewis closed 1 year ago

TomLewis commented 1 year ago

Summary

You have an expire https://github.com/kangarko/ChatControl-Red/wiki/Messages#expires But there is no "begin" so we cant pre-make messages for the future!

  1. up-coming events
  2. The actual event day to auto broadcast messages
  3. Could be used in the MOTD to alert of scheduled maintenence ahead of time
  4. Seasonal things that happen every season and need the message changed in timings y

So then we can set a start and end time for a timed message, not just when it expires.

What would happen if we didn't implement this feature? Why not having this feature is a problem?

Cant tell messages when to dispaly from, only expire.

kangarko commented 1 year ago

Love it! Got to do after holidays (Monday)

TomLewis commented 1 year ago

Super, Im going to pre-make a ton of message early in anticipation haha

You could even include a bunch of pre-made timed messages/MOTD messages in your configs to explain how to use it for things like holidays!

I also thought it would be great to combine this with permissions! Another use case:

  1. You have events that you need staff to prep for, you can remind them with timed messages and auto disabled the timed message after the date with the already existing "expire"
  2. Staff reminder for Season dates, we split the servers event calendar up into the 4 seasons of the year, we could alert staff in advance that the season is upcoming and to start preparing!
  3. This now becomes a calendar, so people could use this for all sorts for their server, if they have a specific theme, say wherewolves and they want timed messages to appear for certain moon cycles etc LOL im sure it opens up a lot of options for unique servers, if they are given the idea of how they can use it creatively!
kangarko commented 1 year ago

Love it! It's done, just make sure to stick with this syntax:

Screenshot 2023-04-09 at 14 36 33

Could you be so nice and provide back some of the messages you create to give back to the community? I feel it would be an awesome addition and I of course will give you full credit! :)

TomLewis commented 1 year ago

Brilliant thanks! Will do!

TomLewis commented 1 year ago

Thought of something for the example I was making, there is no way to do "recurring" dates! So same time every year for example, because if I make an example for Christmas 2023, it wont work for christmas 2024! how did I not think of that until I was making the configs! haha

I guess at this point, its cron!

Im not sure the best way to do it, either, for begins and expires, if the user does not include a year, its a reoccuring date, or have a variable to say its reoccuring, but then if they set a year, that wont work, but what if people want it every tuesday at 1am?

You could follow the crontab system https://crontab.guru/#

Theres bound to be a standard for this.

I also thought, that if you had a date/time conditon you could use in-side formats, you could have 1 format you could use for many differnt dates! But its odd to mix Visuals formats with logic in the MVC logic.

Heres an example of the first set I am setting up:

Screenshot 2023-04-18 at 15 35 15

ElBananaa commented 1 year ago

Best thing to do here imo (and also probably the easiest one for both Kangarko and the users) is to use * if you want to repeat an event every hour/day/month, just like cron expressions. So either players would specify a date, or repeat using *. If they somehow don't specify a year, just make it so it won't work. Simply add a note to wiki that says: stick with this syntax as kangarko did when he pushed this feature.

Btw @kangarko I just noticed you are using java.text.SimpleDateFormat instead of java.time, may I ask why? iirc java.time is better for pretty much everything ^^

kangarko commented 1 year ago

I can just add {CURRENT_X} where X can be MINUTE, HOUR, DAY, WEEK, MONTH, YEAR etc.

Would that work?

kangarko commented 1 year ago

begins 22 Dec {CURRENT_YEAR}, 00:00 expires 24 Dec {CURRENT_YEAR}, 00:00

so it would work every year

TheIntolerant commented 1 year ago

Tbf, later today I can test these JavaScript variables I have made and make them public by making a pull request to add them by default

I will post examples of how these variables could be used to make a rule execute only during a specific day of the week, hour, month etc.

Right now I'm working on a university assignment but in a few hours I'll see if I can do some quick tests to make sure I haven't missed any errors (but there shouldn't be any errors)

TheIntolerant commented 1 year ago

The JavaScript variables I made for my own servers would work perfectly for reoccurring events etc. Give me a few hours and today sometime I'll make a pull request

TomLewis commented 1 year ago

begins 22 Dec {CURRENT_YEAR}, 00:00 expires 24 Dec {CURRENT_YEAR}, 00:00

so it would work every year

A placeholder would work, this should work for doing selections between months too, so I could target say summer holidays when the players are not at school.

ElBananaa commented 1 year ago

Using {CURRENT_YEAR} or whatever doesn't really seem intuitive for people, does it?

TomLewis commented 1 year ago

Using {CURRENT_YEAR} or whatever doesn't really seem intuitive for people, does it?

Yeah but its easy to program and add LOL and that gets it working at least for now?

I do always have to stop and think about Cron, as its in such a weird order.

TheIntolerant commented 1 year ago

I would personally suggest {EVERY_X} instead of {CURRENT_X}

As {EVERY_YEAR} makes more sense to me at least than {CURRENT_YEAR}

TheIntolerant commented 1 year ago
I'll make a pull request to add these variables I made Variable Name Description
{time_minutes} Shows the minutes of the current time
{time_hours} Shows the hours of the current time
{time_day} Shows the calendar day
{time_month} Shows the calendar month
{time_year} Shows the calendar year
{time_weekday} Shows the day of the week (monday, tuesday etc.)

That way you could also do things like etc

# You can also run messages which are only shown during a specific time period
# In this example, the message is only shown on the 1st - 3rd of January
group new_years
delay 900 seconds
require receiver script {time_day} < 4 && {time_month} == 1
message:
- &aHappy New Years &fEveryone!
TheIntolerant commented 1 year ago

To start uses these variables just download them here and drop them into /plugins/ChatControlRed/variables

BUT using these variables in the script operators can be difficult for longer time periods!

So I would still strongly encourage the additional placeholder {EVERY_x} as it would definitely be a worthwhile addition!!

kangarko commented 1 year ago

I have simplified this and added the following: https://github.com/kangarko/ChatControl-Red/wiki/Rules#begins-and-expires

Thanks to everyone for input!

TomLewis commented 1 year ago

I have simplified this and added the following: https://github.com/kangarko/ChatControl-Red/wiki/Rules#begins-and-expires

Thanks to everyone for input!

Thanks, this will work well, sorry I didnt think of it in the initial request! Its funny you only think of things when you go to implement them and be like, whoops forgot about this! haha

Variables will work great.

kangarko commented 1 year ago

Yep, same happens to me! Thanks for the input!