-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathPoll System - POLL.txt
76 lines (45 loc) · 12.5 KB
/
Poll System - POLL.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@@ DEPENDENCIES - CORE, Account System.
th u(NEWCOBJ,Poll System <POLL>,poll,,,,WIZARD SAFE !NO_COMMAND,INHERIT SIDEFX SAFE)
th u(NEWCOBJ,Poll Database <POLLDB>,polldb,u(cobj,poll),,1,WIZARD SAFE,INHERIT SIDEFX SAFE)
&CMD`+POLL`PENNMUSH [u(cobj,poll)]=$^(?s)(?\:\+)?(poll)(?\:/(\S+)?)?(?\: +(.+?))?(?\:=(.*))?$:@attach %!/CMD`+POLL`MAIN
@set [u(cobj,poll)]/CMD`+POLL`PENNMUSH=regexp
&CMD`+POLL`RHOSTMUSH [u(cobj,poll)]=$^(?s)(?\:\+)?(poll)(?\:/(\\S+)?)?(?\: +(.+?))?(?\:=(.*))?$:@attach %!/CMD`+POLL`MAIN
@set [u(cobj,poll)]/CMD`+POLL`RHOSTMUSH=regexp
&CMD`+POLL`MAIN [u(cobj,poll)]=th u(setq,com,lcstr(+%1));@attach %!/INC`CHECKPC=%#,0;@attach %!/INC`GETSWITCH=%2;@include %!/INC`[u(strfirstof,%q<switch>,MAIN)]=%3,%4
@set [u(cobj,poll)]/CMD`+POLL`[u(choosegame,RHOSTMUSH,PENNMUSH)]=no_command
&SWITCHES`PLAYER [u(cobj,poll)]=REMOVE|OTHER|FULL
&SWITCHES`ADMIN [u(cobj,poll)]=CREATE|RENAME|DELETE|OPEN|CLOSE|OPTION|DESCRIBE|HELP|MULTI
&SYSTEM`SWITCHES [u(cobj,poll)]=setunion(setunion(u(SWITCHES`PLAYER),u(SWITCHES`PLAYER`EXTRA),|,|),if(cor(u(isadmin,%#),elock(#1695/Basic,%#)),setunion(u(SWITCHES`ADMIN),u(SWITCHES`ADMIN`EXTRA),|,|)),|,|)
&SYSTEM`NAME [u(cobj,poll)]=POLL
&INC`MAIN [u(cobj,poll)]=@select/inline t(strlen(%0))[t(strlen(%1))]=10,{@attach %!/INC`DISPLAY},11,{@attach %!/INC`VOTE},0*,{@attach %!/INC`LISTALL}
&INC`LISTALL [u(cobj,poll)]=@check words(u(setr,polls,u(sortname,children(u(cobj,polldb)))))=@attach %!/INC`MSG=No polls to display.;@pemit %#=u(HEADER,mudname() - All Polls);@pemit %#=ansi(u(color,%#,COLUMN_NAMES),align(15 20 7 3 3 3 3 3 3 3 3 1,Name,Created,Status,A,B,C,D,E,F,X,Tot,V));@pemit %#=u(separator);@dolist/inline u(sortcreated,%q<polls>)={@pemit %#=align(15 20 7 3 3 3 3 3 3 3 3 1,u(pueblize,u(getmoniker,##),+poll [u(getmoniker,##)]),u(fancytime,u(csecs,##),%#),if(get(##/STATUS),Closed,Open),u(FUN`VOTECOUNT,##,A),u(FUN`VOTECOUNT,##,B),u(FUN`VOTECOUNT,##,C),u(FUN`VOTECOUNT,##,D),u(FUN`VOTECOUNT,##,E),u(FUN`VOTECOUNT,##,F),u(FUN`VOTECOUNT,##,X),u(nattr,##/VOTER`*),if(hasattr(##/VOTER`%q<t0accdb>),ansi(hg,Y),ansi(hr,N)))};@pemit %#=u(FOOTER)
&FUN`VOTECOUNT [u(cobj,poll)]=words(u(filter,VOTE,u(lattr,%0/VOTER`*),%b,%b,%0,%1))
&FIL`VOTE [u(cobj,poll)]=t(match(get(%1/%0),%2))
&INC`FINDPOLL [u(cobj,poll)]=@check strlen(%0)=@attach %!/INC`MSG=ERROR: Name field empty.;@select/inline words(u(setr,pollcheck,namegraball(children(u(cobj,polldb)),%0)))=0,{@stop 1=@attach %!/INC`MSG=ERROR: Poll '%0' was not found.},>1,{@stop 1=@attach %!/INC`MSG=ERROR: Multiple Polls found with a similar name. Which do you mean? Matches: [itemize(iter(%q<pollcheck>,u(pueblize,name(%i0),+poll [name(%i0)]),%b,|),|,and,\,)]},1,{th u(setq,poll%1,%q<pollcheck>);th u(setq,pollname%1,name(%q<pollcheck>))}
&INC`DISPLAY [u(cobj,poll)]=@include %!/INC`FINDPOLL=%0,1;@pemit %#=u(HEADER,Poll: %q<pollname1>);@pemit %#=get(%q<poll1>/DESCRIBE)[if(get(%q<poll1>/MULTI),%R%R[ansi(h,This is a Multi-Answer Poll. Select All That Apply.)])];@dolist/inline lattr(%q<poll1>/OPTION`*)={@pemit %#=u(separator,u(pueblize,ansi(hr,last(##,`)),+poll %q<pollname1>=[last(##,`)]));@pemit %#=get(%q<poll1>/##)};@pemit %#=u(subheader,if(strlen(u(setr,letter,get(%q<poll1>/VOTER`%q<t0accdb>))),You voted: %q<letter>,+poll %q<pollname1>=<letter> to vote!))
&INC`DESCRIBE [u(cobj,poll)]=@check strlen(%0)=@attach %!/INC`MSG=ERROR: Name field empty.;@include %!/INC`FINDPOLL=%0,1;@check strlen(%1)=@attach %!/INC`MSG=ERROR: Poll description field empty.;@select/inline u(setr,mail,gt(strlen(u(setr,olddesc,get(%q<poll1>/DESCRIBE))),0))=1,{@mail %#=%q<pollname1>/OLD POLL WAS:%R%q<olddesc>;@describe %q<poll1>=%1};@attach %!/INC`MSG=You have changed Poll %q<pollname1>'s description. Its old contents have been @mail'd to you.;@attach %!/INC`MSG`CHAN=Changed the Poll description for '[u(pueblize,%q<pollname1>,+poll %q<pollname1>)]'
&INC`CREATE [u(cobj,poll)]=@check strlen(%0)=@attach %!/INC`MSG=ERROR: Name field empty.;@stop isdbref(u(find_in,u(cobj,polldb),%0))=@attach %!/INC`MSG=ERROR: That Poll already exists. Use +poll/describe to change its description.;@check valid(name,%0)=@attach %!/INC`MSG=ERROR: That would not be a valid name for a THING. Avoid special symbols like &.;@check strlen(%1)=@attach %!/INC`MSG=ERROR: Poll description field empty.;@tel u(setr,poll,create(%0))=u(cobj,polldb);@parent %q<poll>=u(cobj,polldb);&STATUS %q<poll>=1;@describe %q<poll>=%1;@attach %!/INC`MSG=You have created the '%0' Poll.;@attach %!/INC`MSG`CHAN=Created a new +poll entry: '[u(pueblize,%0,+poll %0)]'
&INC`RENAME [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@check strlen(%1)=@attach %!/INC`MSG=ERROR: New name field empty.;@check valid(name,%1)=@attach %!/INC`MSG=ERROR: '%1' is not a valid poll name. Polls are stored as THING objects. Avoid characters like &.;@stop isobjid(u(find_in,u(cobj,polldb),%1))=@attach %!/INC`MSG=ERROR: Poll '%1' already exists.;@attach %!/INC`MSG=Poll '%q<pollname1>' Renamed to '%1'!;@attach %!/INC`MSG`CHAN={Poll '%q<pollname1>' Renamed to '%1'};@name %q<poll1>=%1
&INC`DELETE [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@attach %!/INC`VERIFY={WARNING: This will delete Poll '%q<pollname1>' and all data associated with it. Are you SURE you want to do this? Enter the same command again within ten seconds to verify.},FCLIST DELETE %q<poll1>;@attach %!/INC`MSG=Poll '%q<pollname1>' deleted!;@attach %!/INC`MSG`CHAN=Poll '%q<pollname1>' Deleted!;@attach %!/DELETE=%q<poll1>
&INC`OPTION [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@check match(A B C D E F,u(setr,letter,ucstr(before(%1,/))))=@attach %!/INC`MSG=ERROR: Must pick an option letter A-F.;@check strlen(u(setr,text,after(%1,/)))=@attach %!/INC`MSG=ERROR: Option description text field empty.;&OPTION`%q<letter> %q<poll1>=%q<text>;@attach %!/INC`MSG=Poll '%q<pollname1>' Option %q<letter> set to: %q<text>;@attach %!/INC`MSG`CHAN=Poll '%q<pollname1>' Option %q<letter> set to: %q<text>
&INC`MULTI [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;th u(setq,multi,not(get(%q<poll1>/MULTI)));&MULTI %q<poll1>=%q<multi>;@attach %!/INC`MSG=Poll '%q<pollname1>' is [if(%q<multi>,now a,no longer a)] multi-option Poll.;@attach %!/INC`MSG`CHAN=Poll '%q<pollname1>' is [if(%q<multi>,now a,no longer a)] multi-option Poll.
&INC`VOTE [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@stop get(%q<poll1>/STATUS)=@attach %!/INC`MSG=%q<pollname1> is already closed.;@check match(A B C D E F,u(setr,letter,ucstr(before(%1,/))))=@attach %!/INC`MSG=ERROR: Must pick an option letter A-F.;@check isdbref(%q<t0accdb>)=@attach %!/INC`MSG=ERROR: No account set for this character! Cannot vote.;@check hasattr(%q<poll1>/OPTION`%q<letter>)=@attach %!/INC`MSG=ERROR: %q<pollname1> does not have a %q<letter> option.;@attach %!/INC`MSG=You have voted for option %q<letter>.;th u(attrib_set,%q<poll1>,VOTER`%q<t0accdb>,if(get(%q<poll1>/MULTI),setunion(get(%q<poll1>/VOTER`%q<t0accdb>),%q<letter>),%q<letter>))
&INC`REMOVE [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@stop get(%q<poll1>/STATUS)=@attach %!/INC`MSG=%q<pollname1> is already closed.;@check get(%q<poll1>/MULTI)=@attach %!/INC`MSG=ERROR: %q<pollname1> is not a Multi-style poll!;@check match(A B C D E F X,u(setr,letter,ucstr(before(%1,/))))=@attach %!/INC`MSG=ERROR: Must pick an option letter A-F.;@check isdbref(u(setr,accid,u(accid,%#)))=@attach %!/INC`MSG=ERROR: No account set for this character! Cannot vote.;@check hasattr(%q<poll1>/OPTION`%q<letter>)=@attach %!/INC`MSG=ERROR: %q<pollname1> does not have a %q<letter> option.;@check match(get(%q<poll1>/VOTER`%q<t0accdb>),%q<letter>)=@attach %!/INC`MSG=ERROR: You did not vote for Option %q<letter>!;@attach %!/INC`MSG=Removed vote from option %q<letter>!;th u(attrib_set,%q<poll1>,VOTER`%q<t0accdb>,setdiff(get(%q<poll1>/VOTER`%q<t0accdb>),%q<letter>));@select/inline %q<letter>=X,{@attach %!/WIPE=%q<poll1>,VOTER`%q<t0accdb>`*};@select/inline strlen(get(%q<poll1>/VOTER`%q<t0accdb>))=0,{@attach %!/WIPE=%q<poll1>,VOTER`%q<t0accdb>};
&INC`OTHER [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@stop get(%q<poll1>/STATUS)=@attach %!/INC`MSG=%q<pollname1> is already closed.;@check isdbref(u(setr,accid,u(accid,%#)))=@attach %!/INC`MSG=ERROR: No account set for this character! Cannot vote.;@check strlen(%1)=@attach %!/INC`MSG=ERROR: 'Other' answer field empty.;@attach %!/INC`MSG=You have added an entry for 'Other'. Thank you for answering the poll!;th u(attrib_set,%q<poll1>,VOTER`%q<t0accdb>,if(get(%q<poll1>/MULTI),setunion(get(%q<poll1>/VOTER`%q<t0accdb>),X),X));&VOTER`%q<t0accdb>`OTHER %q<poll1>=%1;&VOTER`%q<t0accdb>`TIMESTAMP %q<poll1>=secs()
&INC`FULL [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@dolist/inline sortkey(#lambda/get(%q<poll1>/\%0`TIMESTAMP),filterbool(#lambda/hasattr(%q<poll1>/\%0`OTHER),lattr(%q<poll1>/VOTER`*)))={@pemit %#=u(separator);@pemit %#=get(%q<poll1>/%i0`OTHER)};@pemit %#=u(footer)
&INC`OPEN [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@@ @check get(%q<poll1>/STATUS)=@attach %!/INC`MSG=%q<pollname1> is already open.;@wipe %q<poll1>/STATUS;@attach %!/INC`MSG=Opened poll %q<pollname1>.;@attach %!/INC`MSG`CHAN=Poll '%q<pollname1>' has been opened!;@attach %!/INC`MSG=Poll '[u(pueblize,%q<pollname1>,+poll %q<pollname1>)]' is now open for voting! [ansi(hw,+poll %q<pollname1>)] to view it!,u(lwhoid)
&INC`CLOSE [u(cobj,poll)]=@attach %!/INC`FINDPOLL=%0,1;@stop get(%q<poll1>/STATUS)=@attach %!/INC`MSG=%q<pollname1> is already closed.;&STATUS %q<poll1>=1;@attach %!/INC`MSG=Closed poll %q<pollname1>.;@attach %!/INC`MSG`CHAN=Poll '%q<pollname1>' has been closed!;@attach %!/INC`MSG=Poll '[u(pueblize,%q<pollname1>,+poll %q<pollname1>)]' is now closed!,u(lwhoid)
&INC`HELP [u(cobj,poll)]=@pemit %#=u(header,Staff Help: +poll);@pemit %#=u(SHLP`+POLL);@pemit %#=u(footer))
&OBJECT`DESTROY [u(cobj,poll)]=@dolist/inline u(lattr,%!/OBJECT`DESTROY`*)={@trigger %!/##=%0,%1,%2,%3,%4,%5,%6,%7,%8,%9}
&OBJECT`DESTROY`PURGEPOLL [u(cobj,poll)]=@select/inline %2=PLAYER,{@dolist/inline children(u(cobj,polldb))={@attach %!/WIPE=##,VOTER`[before(%0,:)]}}
&SORTCREATED [u(cobj,poll)]=u(SORTCREATED`%va,%0,if(strlen(%1),%1,%B),if(strlen(%2),%2,%B))
&SORTCREATED`PENNMUSH [u(cobj,poll)]=sortkey(#lambda/csecs(\%0),%0,n,%1,%2)
&SORTCREATED`RHOSTMUSH [u(cobj,poll)]=sortby(#lambda/[lit([ncomp(convtime(createtime(%0),convtime(createtime(%1))])],%0,%1,%2)
&STARTUP [u(cobj,poll)]=@trigger %!/LOOP`NAGGER
&LOOP`NAGGER [u(cobj,poll)]=th u(setq,polls,u(sortcreated,u(filter,OPEN,children(u(cobj,polldb)))));@dolist u(lwhoid)={@stop u(isguest,##);th u(setq,accid,u(accid,##));@check %q<t0accdb>;@check words(u(setr,unanswered,u(filter,UNANSWERED,%q<polls>,%b,%b,%q<t0accdb>)));@attach %!/INC`MSG=You have yet to cast your vote on the following polls: [iter(%q<unanswered>,'[u(pueblize,name(%i0),+poll [name(%i0)])]',%b,\,%b)],before(##,:)};@wait mul(60,60,2)=@trigger %!/LOOP`NAGGER
&FIL`OPEN [u(cobj,poll)]=not(get(%0/STATUS))
&FIL`UNANSWERED [u(cobj,poll)]=not(hasattr(%0/VOTER`%1))
&HLP`+poll [u(cobj,poll)]=The Poll system's used to manage any number of questions posed to the playerbase by admin on [mudname()].%R%R[ansi(hc,Commands)]%R[align(5 [sub(u(width,%#),6)],,[ansi(hw,+poll)] - Lists all Polls in use.%R[ansi(hw,+poll <name>)] - List details about a poll.%R[ansi(h,+poll/full <name>)] - List 'other' answers to the poll. Can be REALLY spammy...%R[ansi(hw,+poll <name>=<letter>)] - Cast your vote. Just use it again with a different letter to change it. For multi-type polls\, each vote is added to a different option.%R[ansi(h,+poll/other <name>=<text>)] - Cast your vote for a write-in 'other' entry. If none of the existing options are sufficient. This is counted as a letter X vote.%R[ansi(h,+poll/remove <name>=<letter>)] - Works only for Multi-type polls. Remove a wrongly-cast vote. Don't forget to cast the right one! Use the letter X for removing an Other entry.%R%RPoll votes are tied to your account. One account\, one vote.%R%R<name> can be a partial match.)]
+help/add Community/+poll=[u(cobj,poll)]/HLP`+poll
&SHLP`+poll [u(cobj,poll)]=[ansi(hc,Staff Commands)]%R[align(5 [sub(u(width,%#),6)],,[ansi(hw,+poll/create <name>=<description>)] - Creates a new poll.%R[ansi(h,+poll/rename <name>=<newname>)] - Rename a poll.%R[ansi(h,+poll/delete <name>)] - Deletes a poll.%R[ansi(h,+poll/open <name>)] - Opens a poll so others can vote. Using this command announces it to everyone online.%R[ansi(h,+poll/close <name>)] - Close a poll. Announces to everyone online. Closed polls can't be voted on.%R[ansi(h,+poll/describe <name>=<description>)] - Updates a poll's description.%R[ansi(h,+poll/option <name>=<letter>/<text>)] - Set/describe a poll's options. Available letters: A through F.%R[ansi(h,+poll/multi <name>)] - Toggle a Poll's Multi-mode on or off. Polls begin with it off. Multi-mode polls allow people to vote for more than thing at a time.)]
+shelp/add Community/+poll=[u(cobj,poll)]/SHLP`+poll