From dd2fadd6c1f0aa91e13188718decccb4ec02bdb3 Mon Sep 17 00:00:00 2001 From: Chris Miller Date: Fri, 10 Jan 2020 00:52:12 +0000 Subject: [PATCH] Apply env vars SSHCHAT_TIMESTAMP and SSHCHAT_THEME --- host.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/host.go b/host.go index a5d12d9..f575229 100644 --- a/host.go +++ b/host.go @@ -96,6 +96,28 @@ func (h *Host) Connect(term *sshd.Terminal) { cfg := user.Config() cfg.Theme = &h.theme user.SetConfig(cfg) + + env := term.Env() + for _, e := range env { + switch e.Key { + case "SSHCHAT_TIMESTAMP": + if e.Value != "" && e.Value != "0" { + cmd := "/timestamp" + if e.Value != "1" { + cmd += " " + e.Value + } + if msg, ok := message.NewPublicMsg(cmd, user).ParseCommand(); ok { + h.Room.HandleMsg(msg) + } + } + case "SSHCHAT_THEME": + cmd := "/theme " + e.Value + if msg, ok := message.NewPublicMsg(cmd, user).ParseCommand(); ok { + h.Room.HandleMsg(msg) + } + } + } + go user.Consume() // Close term once user is closed.