mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-15 00:20:37 +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.
|
// Connect a specific Terminal to this host and its room.
|
||||||
func (h *Host) Connect(term *sshd.Terminal) {
|
func (h *Host) Connect(term *sshd.Terminal) {
|
||||||
term.SetEnterClear(true) // We provide our own echo rendering
|
|
||||||
id := NewIdentity(term.Conn)
|
id := NewIdentity(term.Conn)
|
||||||
user := message.NewUserScreen(id, term)
|
user := message.NewUserScreen(id, term)
|
||||||
cfg := user.Config()
|
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)
|
user.SetConfig(cfg)
|
||||||
|
|
||||||
// Load user config overrides from ENV
|
// Load user config overrides from ENV
|
||||||
@ -190,10 +199,12 @@ func (h *Host) Connect(term *sshd.Terminal) {
|
|||||||
|
|
||||||
m := message.ParseInput(line, user)
|
m := message.ParseInput(line, user)
|
||||||
|
|
||||||
if m, ok := m.(*message.CommandMsg); ok {
|
if !apiMode {
|
||||||
// Other messages render themselves by the room, commands we'll
|
if m, ok := m.(*message.CommandMsg); ok {
|
||||||
// have to re-echo ourselves manually.
|
// Other messages render themselves by the room, commands we'll
|
||||||
user.HandleMsg(m)
|
// have to re-echo ourselves manually.
|
||||||
|
user.HandleMsg(m)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Any reason to use h.room.Send(m) instead?
|
// FIXME: Any reason to use h.room.Send(m) instead?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user