Code offering: Generic +reminders code



  • A friend asked me for this. I hope someone finds it useful. Ulterior motive: I have server/code questions. It's easier to get those answered when one has provided a suitable offering. I don't have a repository, so here you go.


    Description/help file:

       +remind <name|me> to <stuff>[ <in|every> [<X>] <days|weeks|months>]
    
       Examples:
         +remind me to Call Mom - will remind you every day
         +remind me to Howl at the moooon! every month
         +remind John to send that log in 3 days
    
       +reminders - Show all the reminders you have set.
       +reminder/view 1 - view reminder #1.
       +reminder/cancel 1 - get rid of reminder #1.
       +reminder/note 1=<stuff> - any notes you want the reminder to send you
    
       Notes:
         All reminders are sent at 2 AM.
         This code considers "a month" to be 28 days.
         Units of time that are not recognized will default to "days".
         Do not use this code for precision. Most third-party apps work better.
    
       Code notes:
         Required functions: header, footer, isstaff, alert
         Required objects: Cron object of some kind
         Required permissions: WIZARD due to attr reading/setting
         Limitations:
           Players can run out of space on themselves by setting a million
           reminders.
         Regrets: Did not code the display number to NOT be the ID.
    
       Credits: Melpomene@NOLA (melpomine@gmail.com|nola.mechanipus.com 2967)
    

    Note: game is still in development. Feel free to log in and whatnot, just don't be surprised it's not up.


    Code, unexploded because exploding is even spammier:

    @create Generic Reminder Code <GRC>=10
    
    @set GRC=SAFE INHERIT
    
    @desc GRC=%R[space(3)]+remind <name|me> to <stuff>\[ <in|every> \[<X>\] <days|weeks|months>\]%R%R[space(3)]Examples:%R[space(5)]+remind me to Call Mom - will remind you every day%R[space(5)]+remind me to Howl at the moooon! every month%R[space(5)]+remind John to send that log in 3 days%R%R[space(3)]+reminders - Show all the reminders you have set.%R[space(3)]+reminder/view 1 - view reminder #1.%R[space(3)]+reminder/cancel 1 - get rid of reminder #1.%R[space(3)]+reminder/note 1=<stuff> - any notes you want the reminder to send you%R%R[space(3)]Notes:%R[space(5)]All reminders are sent at 2 AM.%R[space(5)]This code considers "a month" to be 28 days.%R[space(5)]Units of time that are not recognized will default to "days".%R[space(5)]Do not use this code for precision. Most third-party apps work better.%R%R[space(3)]Code notes:%R[space(5)]Required functions: header, footer, isstaff, alert%R[space(5)]Required objects: Cron object of some kind%R[space(5)]Required permissions: WIZARD due to attr reading/setting%R[space(5)]Limitations:%R[space(7)]Players can run out of space on themselves by setting a million%R[space(7)]reminders.%R[space(5)]Regrets: Did not code the display number to NOT be the ID.%R%R[space(3)]Credits: Melpomene@NOLA (melpomine@gmail.com|nola.mechanipus.com 2967)%R
    
    
    &cmd-+remind GRC=$+remind * to *:@switch setr(E, if(and(not(strmatch(setr(P, pmatch(case(%0, me, %N, %0))), %#)), not(isstaff(%#))), Only staffers may set reminders for anyone other than themselves., if(not(t(%qP)), Could not find player %0., setq(3, extract(%1, sub(words(%1), 2), 3))[null(iter(%q3, if(isnum(%i0), setq(4, 1)))[if(not(t(%q4)), setq(4, switch(%q3, * month, M, * months, M, * day, D, * days, D, * weeks, W, * week, W, 0)))])][if(not(t(%q4)), setq(3, ))][setq(C, switch(%q3, * month, M, * months, M, * day, D, * days, D, * weeks, W, * week, W, 0))][setq(R, switch(%q3, * in *, I, in *, I, * every *, E, every *, E, 0))][setq(N, trim(squish(iter(%q3, if(isnum(%i0), %i0)))))][if(or(not(t(%qN)), not(isnum(%qN))), setq(N, 1))][setq(S, if(or(strmatch(%q3, * in *), strmatch(%q3, in *)), extract(%1, 1, sub(words(%1), match(revwords(%1), in))), if(or(strmatch(%q3, * every *), strmatch(%q3, every *)), extract(%1, 1, sub(words(%1), match(revwords(%1), every))), %1)))][if(not(t(%qS)), Could not figure out what you wanted me to remind you of!, setq(T, convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qN, case(%qC, W, 604800, M, 2419200, 86400)))))))])))=, {&_reminderCount %qP=setr(I, add(default(%qP/_reminderCount, 0), 1)); &_reminder-%qI-text %qP=%qS; &_reminder-%qI-cycle %qP=[if(t(%qC), %qC, D)]; &_reminder-%qI-next %qP=%qT; &_reminder-%qI-interval %qP=%qN; &_reminder-%qI-setter %qP=%#; &_reminder-%qI-repeat %qP=[case(%qR, I, 0, 1)]; @switch [gt(strlen(get(me/people-[setr(A, v(peopleCount))])), 7500)]=1, {&peopleCount me=setr(A, add(%qA, 1));}; &people-%qA me=[setunion(v(people-%qA), %qP)]; @set me/people-%qA=NO_COMMAND; @pemit %#=alert(Reminders) [case(%#, %qP, You, name(%qP))] will receive a reminder to "%qS" [case(%qR, I, in, every)] [if(gt(%qN, 1), %qN%b)][case(%qC, W, week, M, month, day)][if(gt(%qN, 1), s)][case(%qR, I,, . Your next reminder is)] on [timefmt($m/$d/$y at 2 AM, %qT)].[case(%qC, M, %bPlease note that a month is considered to be 28 days long.)];}, {@pemit %#=alert(Reminders) %qE;}
    @set GRC/cmd-+remind=no_parse
    
    &peopleCount GRC=1
    @set GRC/peopleCount=NO_COMMAND
    
    &trigger_reminders GRC=@dolist lattr(me/people-*)={@trigger me/trigger_parse-people=##;};
    @set GRC/trigger_reminders=NO_COMMAND
    
    &trigger_parse-people GRC=@dolist v(%0)={@trigger/notify me/trigger_remind-person=##; @wait me={@trigger me/trigger_clean-person=##;};}
    @set GRC/trigger_parse-people=NO_COMMAND
    
    &trigger_clean-person GRC=@switch words(lattr(%0/_reminder-*-text))=0, {@dolist lattr(me/people-*)={&## me=[setdiff(v(##), %0)];};}
    @set GRC/trigger_clean-person=NO_COMMAND
    
    &trigger_remind-person GRC=@switch t(setr(P, pmatch(%0)))=1, {@dolist lattr(%qP/_reminder-*-text)={@switch setq(0, first(rest(##, -), -))[setq(C, get(%qP/_reminder-%q0-cycle))][setq(I, get(%qP/_reminder-%q0-interval))][setq(R, get(%qP/_reminder-%q0-repeat))][setq(T, get(%qP/_reminder-%q0-next))][lt(%qT, add(secs(), 3600))]=1, {@mail/quick %qP/Reminder: [titlestr(setr(V, get(%qP/##)))]=%R%TRemember to: %qV[if(hasattr(%qP, _reminder-%q0-note), %R%R%TNote: [get(%qP/_reminder-%q0-note)])]%R%R This is a [case(%qR, 1, repeating, one-time)] reminder [case(setr(S, get(%qP/_reminder-%q0-setter)), %qP, you set for yourself, [name(%qS)] set for you)]. [case(%qR, 1, Your next reminder will be on [timefmt($m/$d/$y at 2 AM, convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qI, case(%qC, W, 604800, M, 2419200, 86400))))))]. This reminder will recur every %qI [case(%qC, W, week, M, month, day)][if(gt(%qI, 1), s)].)] To learn more about +reminders, type +help reminders. Thank you!; @switch %qR=1, {&_reminder-%q0-next %qP=[convtime(timefmt($a $b $d 02:00:00 $Y, add(secs(), mul(%qI, case(%qC, W, 604800, M, 2419200, 86400)))))];}, {@wipe %qP/_reminder-%q0-*;}}}}
    @set GRC/trigger_remind-person=NO_COMMAND
    
    &cmd-+reminders GRC=$+reminders:@pemit %#=if(t(setr(R, lattr(%#/_reminder-*-text))), header(Your active reminders)[space(3)]%cu[ljust(ID, 5)] [ljust(Reminder text, 57)] [ljust(Next, 8)]%cn%R[iter(%qR, space(3)[ljust(setr(0, first(rest(%i0, -), -))., 5)] [ljust(mid(get(%#/%i0), 0, 57), 57)] [ljust(timefmt($m/$d/$y, get(%#/_reminder-%q0-next)), 8)],, %R)][footer(+reminder/view # for more.)], alert(Reminders) You have no active reminders.);
    
    &cmd-+reminder_view GRC=$+reminder/view *:@switch setr(E, if(not(hasattr(%#, _reminder-%0-text)), You don't have a reminder #%0.))=, {@pemit %#=header(Reminder #%0)%r[wrap(Text: [get(%#/_reminder-%0-text)], 78, Left, space(3))]%R[if(hasattr(%#, _reminder-%0-note), wrap(Note: [get(%#/_reminder-%0-note)], 78, Left, space(3))%R)][columns(Set by: [name(get(%#/_reminder-%0-setter))]|Repeating: [case(setr(R, get(%#/_reminder-%0-repeat)), 1, on, off)]|Next reminder: [timefmt($m/$d/$y at 2 AM, get(%#/_reminder-%0-next))]|Occurs [case(%qR, 1, every, in)]: [setr(I, get(%#/_reminder-%0-interval))] [case(get(%#/_reminder-%0-cycle), W, week, M, month, day)][if(gt(%qI, 1), s)], 36, |, 3)]%R[footer(+reminder/note %0=<note> to set a note.)];}, {@pemit %#=alert(Reminders) %qE;}
    @set GRC/cmd-+reminder_view=no_parse
    
    &cmd-+reminder_note GRC=$+reminder/note *=*:@switch setr(E, if(not(hasattr(%#, _reminder-%0-text)), You don't have a reminder #%0.))=, {&_reminder-%0-note %#=%1; @pemit %#=alert(Reminders) You set a note for #%0: %1;}, {@pemit %#=alert(Reminders) %qE;}
    @set GRC/cmd-+reminder_note=no_parse
    
    &cmd-+reminder_cancel GRC=$+reminder/cancel *:@switch setr(E, if(not(hasattr(%#, _reminder-%0-text)), You don't have a reminder #%0.))=, {@pemit %#=alert(Reminders) You have canceled reminder #%0. If you wish to recreate it, run these commands:%R%R+remind me to [get(%#/_reminder-%0-text)] [case(get(%#/_reminder-%0-repeat), 1, every, in)] [setr(I, get(%#/_reminder-%0-interval))] [case(get(%#/_reminder-%0-cycle), W, week, M, month, day)][if(gt(%qI, 1), s)][if(hasattr(%#, _reminder-%0-note), %R+reminder/note [add(get(%#/_reminderCount), 1)]=[get(%#/_reminder-%0-note)])]; @wipe %#/_reminder-%0-*;}, {@pemit %#=alert(Reminders) %qE;}
    @set GRC/cmd-+reminder_note=no_parse
    
    @pemit %#=SET A CRON JOB UP. Sample below. For the below code to work, you need to be either holding the cron or in its location. Otherwise, replace the word CRON with your cron's DBref.
    
    @force me=&cron_job_GenericReminders CRON=@trigger [num(GRC)]/trigger_reminders
    &cron_time_GenericReminders CRON=|||02|00|
    

    Usage, modification, and posting/hosting rights granted so long as you leave the credits in and unmodified except to append your own.


  • Politics

    This would actually be super useful for any game where there are wait times for XP spending and in general where you feel you need to be reminded. I am unsure regarding the ability to remind other people of things--mostly because I can see the possibility for abuse. Maybe if people could choose to accept being reminded by certain people. For example, I am okay with being reminded to do something by @Thenomain, but I'd never let @Eerie have that sort of control because she's totes cray.

    Additionally, it would be more awesome if you could set the date to send the reminder on, instead of just 'in X [time value]'.



  • Feel free to extend it! The "remind <player> to <stuff>" command is staff-only, but players who get such reminders can view and cancel them if they like. Some people might not like that.

    The other part of this code, which I have not yet scribbled up but which should be pretty simple, is a +autojob object. It automatically opens a job on a player's behalf every X <weeks|months>. Handy for blood bathers and whatnot I'm told. (What's holding me up on making that one: I find the syntax ugly. +autojob <player>=<stuff> in <X> <time period> - it just... reads... bad. I have other stuff to do so I will get around to it.)


  • Politics

    @Melpomene, I can't really extend it because I know about as much about code as a llama knows about pasteurization. But it's good that you're opening it up for other coders to expand upon. It's a good idea.


Log in to reply
 

Looks like your connection to MU Soapbox was lost, please wait while we try to reconnect.