File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,10 @@ func runCommands(line string, u *User) {
135
135
case "mute" :
136
136
muteCMD (strings .TrimSpace (strings .TrimPrefix (line , "mute" )), u )
137
137
return
138
+ case "clear" :
139
+ if clear_if_rest_empty (strings .TrimSpace (strings .TrimPrefix (line , "clear" )), u ) {
140
+ return
141
+ }
138
142
}
139
143
140
144
if u .isBridge {
@@ -228,6 +232,16 @@ func clearCMD(_ string, u *User) {
228
232
u .term .Write ([]byte ("\033 [H\033 [2J" ))
229
233
}
230
234
235
+ // If rest is empty, run the clear command and return true.
236
+ // Otherwise, return false.
237
+ func clear_if_rest_empty (rest string , u * User ) bool {
238
+ if rest == "" {
239
+ clearCMD (rest , u )
240
+ return true
241
+ }
242
+ return false
243
+ }
244
+
231
245
func usersCMD (_ string , u * User ) {
232
246
u .room .broadcast ("" , printUsersInRoom (u .room ))
233
247
}
You can’t perform that action at this time.
0 commit comments