Skip to content

Commit

Permalink
clear command is not displayed to other users.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkaeriit committed Sep 20, 2024
1 parent 226f630 commit 548995f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ func runCommands(line string, u *User) {
case "mute":
muteCMD(strings.TrimSpace(strings.TrimPrefix(line, "mute")), u)
return
case "clear":
if clear_if_rest_empty(strings.TrimSpace(strings.TrimPrefix(line, "clear")), u) {
return
}
}

if u.isBridge {
Expand Down Expand Up @@ -232,6 +236,16 @@ func clearCMD(_ string, u *User) {
u.term.Write([]byte("\033[H\033[2J"))
}

// If rest is empty, run the clear command and return true.
// Otherwise, return false.
func clear_if_rest_empty(rest string, u *User) bool {
if rest == "" {
clearCMD(rest, u)
return true
}
return false
}

func usersCMD(_ string, u *User) {
u.room.broadcast("", printUsersInRoom(u.room))
}
Expand Down

0 comments on commit 548995f

Please sign in to comment.