Skip to content

Commit

Permalink
Added double prompt fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xackery committed Jan 27, 2020
1 parent f3035db commit 87339c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
VERSION := v0.0.16
VERSION := v0.0.17
NAME := talkeq

.PHONY: build-all
build-all: sanitize
@echo "Preparing talkeq v${VERSION}"
@echo "Preparing talkeq ${VERSION}"
@rm -rf bin/*
@-mkdir -p bin/
@echo "Building Linux"
Expand Down
17 changes: 16 additions & 1 deletion telnet/telnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (t *Telnet) loop(ctx context.Context) {
if strings.Contains(msg, k) {
channelID = v
pattern = k
break
}
}

Expand All @@ -209,11 +210,25 @@ func (t *Telnet) loop(ctx context.Context) {
}

//prompt clearing
if strings.Index(msg, ">") > 0 &&
if strings.Contains(msg, ">") &&
strings.Index(msg, ">") < strings.Index(msg, " ") {
msg = msg[strings.Index(msg, ">")+1:]
}

//there's a double user> prompt issue that happens some times, this helps remedy it
if strings.Contains(msg, ">") &&
strings.Index(msg, ">") < strings.Index(msg, pattern) {
msg = msg[strings.Index(msg, ">")+1:]
}

//there's a double user> prompt issue that happens some times, this also helps remedy it
//removed, may be overkill
//for strings.Contains(msg, "\b") {
// msg = msg[strings.Index(msg, "\b")+1:]
//}
//just strip any \b text
msg = strings.ReplaceAll(msg, "\b", "")

if msg[0:1] == "*" { //ignore echo backs
log.Debug().Str("msg", msg).Msg("ignored (* = echo back)")
continue
Expand Down

0 comments on commit 87339c8

Please sign in to comment.