Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clear command is not displayed to other users. #244

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading