Skip to content

Commit 011c9ae

Browse files
authored
Merge pull request #244 from Arkaeriit/dont-display-clear
`clear` command is not displayed to other users.
2 parents f157ce7 + 548995f commit 011c9ae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

commands.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ func runCommands(line string, u *User) {
135135
case "mute":
136136
muteCMD(strings.TrimSpace(strings.TrimPrefix(line, "mute")), u)
137137
return
138+
case "clear":
139+
if clear_if_rest_empty(strings.TrimSpace(strings.TrimPrefix(line, "clear")), u) {
140+
return
141+
}
138142
}
139143

140144
if u.isBridge {
@@ -228,6 +232,16 @@ func clearCMD(_ string, u *User) {
228232
u.term.Write([]byte("\033[H\033[2J"))
229233
}
230234

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+
231245
func usersCMD(_ string, u *User) {
232246
u.room.broadcast("", printUsersInRoom(u.room))
233247
}

0 commit comments

Comments
 (0)