forked from fuzzball-muck/fuzzball-muf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd-@ignore.muf
235 lines (197 loc) · 7.29 KB
/
cmd-@ignore.muf
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@program cmd-@ignore.muf
1 9999 d
i
( cmd-@ignore 10 Sep 2002 by Steve <muf@quantumrain.com> )
$author Steve <muf@quantumrain.com>
$version 1.0
( -- Options -- )
( Change this line to whatever you use to determine if someone is a guest )
$def Guest? ( d -- i ) name "Guest" stringpfx
( -- No more options -- )
: StripDuplicates[ str:Line str:ToRemove -- str:Line ]
ToRemove @ ToRemove @ strcat var! ToRemoveTwice
Line @ begin dup ToRemoveTwice @ instr while ToRemove @ ToRemoveTwice @ subst repeat
;
: StrWnk[ str:Line -- str:Line ]
Line @ 1 strcut tolower swap toupper swap strcat
;
: Array_Commas[ arr:Array str:And -- str:Text ]
Array @ array_count 2 > if
Array @ array_vals array_make array_reverse dup 0 []
swap 0 array_delitem array_reverse
", " array_join " " And @ " " strcat strcat strcat swap strcat
else
Array @ " " And @ " " strcat strcat array_join
then
;
: Array_Quote[ arr:Array -- arr:Array ]
Array @ dictionary? if
{ Array @ foreach "\"%~\"" fmtstring repeat }dict
else
{ Array @ foreach "\"%~\"" fmtstring swap pop repeat }list
then
;
: Array_StrWnk[ arr:Array -- arr:Array ]
Array @ dictionary? if
{ Array @ foreach "%~" fmtstring StrWnk repeat }dict
else
{ Array @ foreach "%~" fmtstring StrWnk swap pop repeat }list
then
;
: Array_Filter[ arr:Array any:Context addr:Func -- arr:Accept arr:Reject ]
{ }dict var! Accept
{ }dict var! Reject
Array @ foreach
over over Context @ Func @ execute if
Accept @ rot ->[] Accept !
else
Reject @ rot ->[] Reject !
then
repeat
Accept @ Reject @
;
: AppInfoMsgArray[ arr:Array str:Msg -- ]
Array @ if
{ {
Array @ array_count 1 = if
"is" "is"
"isn't" "isn't"
"s" ""
"es" ""
"ies" ""
else
"is" "are"
"isn't" "aren't"
"s" "s"
"es" "es"
"ies" "ies"
then
"array" Array @ array_strwnk array_quote dup "and" array_commas
"arrayor" rot "or" array_commas
}dict }list
Msg @ array_fmtstrings me @ 1 array_make array_notify
then
;
: AppParsePlayersSub[ str:Text any:Context -- any:Data ]
Text @ pmatch dup not if pop Text @ part_pmatch then
;
: AppParseAddRemoveList[ str:Args any:Context addr:MatchFunc -- list:Add list:Remove list:Unknown ]
{ }list var! Add
{ }list var! Remove
{ }list var! Unknown
Args @ strip dup if
" " StripDuplicates " " explode_array foreach swap pop
dup "!" stringpfx if 1 strcut swap pop 1 else 0 then var! Removing? var! Text
Text @ Context @ MatchFunc @ execute dup if
Removing? @ if
Remove @ array_appenditem Remove !
else
Add @ array_appenditem Add !
then
else pop Text @ Unknown @ array_appenditem Unknown ! then
repeat
else pop then
Add @ Remove @ Unknown @
;
: AppParseAddRemovePlayers[ str:Args -- list:Add list:Remove ]
Args @ 0 'AppParsePlayersSub AppParseAddRemoveList
"I don't recognise the player%[s]s named %[array]s." AppInfoMsgArray
;
: DisplayIgnores[ ref:Who -- ]
Who @ array_get_ignorelist dup not if
pop "no one"
else Array_StrWnk Array_Quote "and" Array_Commas then
me @ dup Who @ = if
"You are currently ignoring "
else
Who @ name " is currently ignoring " strcat
then rot "." strcat strcat notify
;
: ReallyIgnoring?[ ref:Player ref:Who -- int:Result ]
Player @ array_get_ignorelist Who @ array_findval if 1 else 0 then
;
: Ignore_ProcessOptionsClearSub[ idx:Idx ref:Who ref:Player -- int:Result ]
Player @ Who @ ReallyIgnoring? if
Player @ Who @ ignore_del 1
else 0 then
;
: Ignore_ProcessOptionsSetSub[ idx:Idx ref:Who ref:Player -- int:Result ]
Player @ Who @ ReallyIgnoring? if 0 else
Player @ Who @ ignore_add 1
then
;
: ProcessIgnores[ ref:Who str:List -- ]
List @ AppParseAddRemovePlayers
Who @ 'Ignore_ProcessOptionsClearSub Array_Filter rot
dup Who @ array_findval if
{ Who @ }list swap array_diff
me @ Who @ = if
Who @ "You stick your fingers in your ears and shout \"Lalala!\" as loud as you can, but you just can't seem to be able to ignore yourself!" notify
else
me @ "You can't make a player ignore themselves!" notify
then
then
Who @ 'Ignore_ProcessOptionsSetSub Array_Filter
me @ Who @ = if
"%[array]s %[is]s already on your ignore list." AppInfoMsgArray
"Adding %[array]s to your ignore list." AppInfoMsgArray
"%[array]s %[is]sn't on your ignore list." AppInfoMsgArray
"Removing %[array]s from your ignore list." AppInfoMsgArray
else
{ "%[array]s %[is]s already on " Who @ name "'s ignore list." }join AppInfoMsgArray
{ "Adding %[array]s to " Who @ name "'s ignore list." }join AppInfoMsgArray
{ "%[array]s %[is]sn't on " Who @ name "'s ignore list." }join AppInfoMsgArray
{ "Removing %[array]s from " Who @ name "'s ignore list." }join AppInfoMsgArray
then
;
: ProcessCommands[ ref:Who str:List -- ]
List @ strip if
Who @ List @ ProcessIgnores
else
Who @ DisplayIgnores
then
;
: DisplayHelp[ -- ]
{
"@Ignore v1.0 Help Page"
"-----------------------------------------------------------------------------"
"Instructions:"
" @ignore may be used to manage your list of ignored players. Any player"
" who you have placed on your ignore list you will NOT hear any messages"
" (says/poses/pages/etc...) from at all."
" "
"Commands:"
" @ignore View your list of currently ignored players."
" @ignore <player> Add <player> to your list of ignored players."
" @ignore !<player> Remove <player> from your list of ignored players."
me @ "WIZARD" flag? if
" "
" @ignore <plyr>= View <plyr>'s list of currently ignored players."
" @ignore <plyr>=<who> Add <who> to <plyr>'s list of ignored players."
" @ignore <plyr>=!<who> Remove <who> from <plyr>'s list of ignored players."
then
}tell
;
: Main[ str:Args -- ]
"me" match me ! me @ Guest? if
me @ "Permission denied." notify
else
"ignore_support" sysparm "yes" strcmp if
me @ "Ignore not supported." notify
else
Args @ "#help" strcmp if
Args @ "=" instr if
me @ "WIZARD" flag? if
Args @ "=" split swap strip dup pmatch dup if swap pop swap ProcessCommands else
pop me @ "I don't recognise the player named \"" rot "\"." notify pop
then
else me @ "Permission denied." notify then
else me @ Args @ ProcessCommands then
else DisplayHelp then
then
then
;
.
c
q
@set cmd-@ignore.muf=M3