@@ -90,11 +90,20 @@ func (h *Host) isOp(conn sshd.Connection) bool {
9090
9191// Connect a specific Terminal to this host and its room.
9292func (h * Host ) Connect (term * sshd.Terminal ) {
93- term .SetEnterClear (true ) // We provide our own echo rendering
9493 id := NewIdentity (term .Conn )
9594 user := message .NewUserScreen (id , term )
9695 cfg := user .Config ()
97- cfg .Theme = & h .theme
96+
97+ apiMode := strings .ToLower (term .Term ()) == "bot"
98+
99+ if apiMode {
100+ cfg .Theme = message .MonoTheme
101+ cfg .Echo = false
102+ } else {
103+ term .SetEnterClear (true ) // We provide our own echo rendering
104+ cfg .Theme = & h .theme
105+ }
106+
98107 user .SetConfig (cfg )
99108
100109 // Load user config overrides from ENV
@@ -151,9 +160,11 @@ func (h *Host) Connect(term *sshd.Terminal) {
151160 }
152161
153162 // Successfully joined.
154- term .SetPrompt (GetPrompt (user ))
155- term .AutoCompleteCallback = h .AutoCompleteFunction (user )
156- user .SetHighlight (user .Name ())
163+ if ! apiMode {
164+ term .SetPrompt (GetPrompt (user ))
165+ term .AutoCompleteCallback = h .AutoCompleteFunction (user )
166+ user .SetHighlight (user .Name ())
167+ }
157168
158169 // Should the user be op'd on join?
159170 if h .isOp (term .Conn ) {
@@ -190,15 +201,22 @@ func (h *Host) Connect(term *sshd.Terminal) {
190201
191202 m := message .ParseInput (line , user )
192203
193- if m , ok := m .(* message.CommandMsg ); ok {
194- // Other messages render themselves by the room, commands we'll
195- // have to re-echo ourselves manually.
196- user .HandleMsg (m )
204+ if ! apiMode {
205+ if m , ok := m .(* message.CommandMsg ); ok {
206+ // Other messages render themselves by the room, commands we'll
207+ // have to re-echo ourselves manually.
208+ user .HandleMsg (m )
209+ }
197210 }
198211
199212 // FIXME: Any reason to use h.room.Send(m) instead?
200213 h .HandleMsg (m )
201214
215+ if apiMode {
216+ // Skip the remaining rendering workarounds
217+ continue
218+ }
219+
202220 cmd := m .Command ()
203221 if cmd == "/nick" || cmd == "/theme" {
204222 // Hijack /nick command to update terminal synchronously. Wouldn't
0 commit comments