mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-06-08 11:22:10 +03:00
Apply env vars SSHCHAT_TIMESTAMP and SSHCHAT_THEME
This commit is contained in:
parent
c0a2f32bd4
commit
dd2fadd6c1
22
host.go
22
host.go
@ -96,6 +96,28 @@ func (h *Host) Connect(term *sshd.Terminal) {
|
|||||||
cfg := user.Config()
|
cfg := user.Config()
|
||||||
cfg.Theme = &h.theme
|
cfg.Theme = &h.theme
|
||||||
user.SetConfig(cfg)
|
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()
|
go user.Consume()
|
||||||
|
|
||||||
// Close term once user is closed.
|
// Close term once user is closed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user