mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-12 23:27:17 +03:00
refactor: Move extraneous User interfaces from chat to host
This commit is contained in:
parent
7f2b8e4689
commit
cd5686e20e
@ -1,8 +1,6 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/shazow/ssh-chat/chat/message"
|
||||
"github.com/shazow/ssh-chat/set"
|
||||
)
|
||||
@ -16,16 +14,10 @@ type roomMember struct {
|
||||
type Member interface {
|
||||
message.Author
|
||||
|
||||
SetName(string)
|
||||
|
||||
Config() message.UserConfig
|
||||
SetConfig(message.UserConfig)
|
||||
|
||||
Send(message.Message) error
|
||||
|
||||
Joined() time.Time
|
||||
ReplyTo() message.Author
|
||||
SetReplyTo(message.Author)
|
||||
Prompt() string
|
||||
SetHighlight(string) error
|
||||
SetName(string)
|
||||
}
|
||||
|
16
client.go
16
client.go
@ -2,13 +2,15 @@ package sshchat
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/shazow/ssh-chat/chat"
|
||||
"github.com/shazow/ssh-chat/chat/message"
|
||||
"github.com/shazow/ssh-chat/sshd"
|
||||
)
|
||||
|
||||
type client struct {
|
||||
chat.Member
|
||||
UserMember
|
||||
sync.Mutex
|
||||
conns []sshd.Connection
|
||||
}
|
||||
@ -25,9 +27,19 @@ func (cl *client) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type User interface {
|
||||
type UserMember interface {
|
||||
chat.Member
|
||||
|
||||
Joined() time.Time
|
||||
Prompt() string
|
||||
ReplyTo() message.Author
|
||||
SetHighlight(string) error
|
||||
SetReplyTo(message.Author)
|
||||
}
|
||||
|
||||
type User interface {
|
||||
UserMember
|
||||
|
||||
Connections() []sshd.Connection
|
||||
Close() error
|
||||
}
|
||||
|
6
host.go
6
host.go
@ -77,8 +77,8 @@ func (h *Host) Connect(term *sshd.Terminal) {
|
||||
requestedName := term.Conn.Name()
|
||||
screen := message.BufferedScreen(requestedName, term)
|
||||
user := &client{
|
||||
Member: screen,
|
||||
conns: []sshd.Connection{term.Conn},
|
||||
UserMember: screen,
|
||||
conns: []sshd.Connection{term.Conn},
|
||||
}
|
||||
|
||||
h.mu.Lock()
|
||||
@ -316,7 +316,7 @@ func (h *Host) InitCommands(c *chat.Commands) {
|
||||
return errors.New("must specify message")
|
||||
}
|
||||
|
||||
target := msg.From().(chat.Member).ReplyTo()
|
||||
target := msg.From().(UserMember).ReplyTo()
|
||||
if target == nil {
|
||||
return errors.New("no message to reply to")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user