mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-13 07:37:17 +03:00
main: Add TERM=bot handling for Host
This commit is contained in:
parent
2076980aea
commit
cce7defd5e
23
host.go
23
host.go
@ -90,11 +90,20 @@ func (h *Host) isOp(conn sshd.Connection) bool {
|
||||
|
||||
// Connect a specific Terminal to this host and its room.
|
||||
func (h *Host) Connect(term *sshd.Terminal) {
|
||||
term.SetEnterClear(true) // We provide our own echo rendering
|
||||
id := NewIdentity(term.Conn)
|
||||
user := message.NewUserScreen(id, term)
|
||||
cfg := user.Config()
|
||||
cfg.Theme = &h.theme
|
||||
|
||||
apiMode := strings.ToLower(term.Term()) == "bot"
|
||||
|
||||
if apiMode {
|
||||
cfg.Theme = message.MonoTheme
|
||||
cfg.Echo = false
|
||||
} else {
|
||||
term.SetEnterClear(true) // We provide our own echo rendering
|
||||
cfg.Theme = &h.theme
|
||||
}
|
||||
|
||||
user.SetConfig(cfg)
|
||||
|
||||
// Load user config overrides from ENV
|
||||
@ -190,10 +199,12 @@ func (h *Host) Connect(term *sshd.Terminal) {
|
||||
|
||||
m := message.ParseInput(line, user)
|
||||
|
||||
if m, ok := m.(*message.CommandMsg); ok {
|
||||
// Other messages render themselves by the room, commands we'll
|
||||
// have to re-echo ourselves manually.
|
||||
user.HandleMsg(m)
|
||||
if !apiMode {
|
||||
if m, ok := m.(*message.CommandMsg); ok {
|
||||
// Other messages render themselves by the room, commands we'll
|
||||
// have to re-echo ourselves manually.
|
||||
user.HandleMsg(m)
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: Any reason to use h.room.Send(m) instead?
|
||||
|
Loading…
x
Reference in New Issue
Block a user