Status +Check

A +check global that returns the current time, unread @mail and Myrddin's BBS posts, as well as a custom ONCHECK attribute. Players can also subscribe to run this command hourly.

Author: Walker@M*U*S*H
Category: Globals
Features: #lambda, %:.
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Status +Check

@create status check
@link status check = #2
@lock/Basic status check==me
@lset status check/Basic=no_inherit
@set status check=!NO_COMMAND
@set status check=WIZARD
@power status check = No_Pay
&.REVAL status check=[null(regmatch(0, repeat(\(\), 36), 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) The preceding call clears all q-registers.)][u(%0/%1)]
&CHAN_GAGGED status check=pos(G, cflags(%0, %qd))
&CHECKERS status check=
@set status check/CHECKERS=no_command
&CMD.DOCHECK status check=$+check:@pemit %#=u(fun.check,%@)
&CMD.DOCHECKHELP status check=$+check/help:@pemit %#=u(describe)
&CMD.SUBSCRIBE status check=$+check/subscribe:@pemit %#=You are now subscribed for hourly +checks. ; &checkers me=setunion(v(checkers),%:)
&CMD.UNSUBSCRIBE status check=$+check/unsubscribe:@pemit %#=You are no longer subscribed for hourly +checks. ; &checkers me=setdiff(v(checkers),%:)
&CRON_HOURLY status check=@dol filterbool(#lambda/inc(conn(\%0)),v(checkers))=@pemit/silent ##=u(fun.check,##)
&DESCRIBE status check=Command: [ansi(h,+check)]%r%rThis command will show you:%r%rSync:%r%b%bTime: <the current time>%r%b%bMail: <mail unread>/<mail total>%r%b%b\[+bb Unread: <unread BB posts, if any>\]%r%b%bIdle: <Your idle time> \[Dark or Hidden flags\]%r%b%b\[Gagged channels: <Channels you are gagging, if any>\]%r%b%b\[result of your &oncheck attribute evaluated\]%r
@set status check/DESCRIBE=no_command visual public nearby
&FUN.CHECK status check=[setq(d,%0)]%rSync:%r%b%bTime: [time(if(hasattr(%0,tz),%0))]%r%b%bMail: [elements(setr(1,mailfstats(%qd)),6)]/[elements(%q1,5)][if(setr(b,ulocal(fun_bbunread,%qd)),%r%b%b+bb Unread: [edit(%qb,.,\,,#,)])]%r%b%bIdle: [squish(timestring(idle(%qd)))]%b%b[if(hasflag(%qd,dark),DARK%b)][if(hidden(%qd),HIDDEN)][if(strlen(setr(c,u(gagged_channels,%qd))),%r%b%bGagged Channels: %qc)]%r[if(hasattr(%qd,oncheck),u(fun.getoncheck,%qd)%r)]
&FUN.GETONCHECK status check=ulocal(.reval,%0,oncheck)
&FUN_BBUNREAD status check=[setq(9,xget(#111,groups))][setq(2,setdiff(iter(setr(0,u(#111/valid_groups,%0,read)),get(%i0/mess_lst)),setr(1,xget(%0,BB_READ))))][squish(iter(%q9,[if(setr(3,setinter(%q2,xget(%i0,mess_lst))),#[member(%q9,itext(0))]/[iter(%q3,[member(xget(itext(1),mess_lst),itext(0))],%b,.)])],%b,%b))]
&GAGGED_CHANNELS status check=filterbool(chan_gagged,channels(%qd))

th Edit #111 in FUN_BBUNREAD to the dbref of the 'bbpocket' of your Myrddin's BBS.
th To enable subscriptions, make sure the CRON_HOURLY attribute is triggered once an hour.