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