Made SendMessage optional, extended ServerMessageSender

This commit is contained in:
diamondburned (Forefront) 2020-05-22 13:50:30 -07:00
parent 668497aef0
commit 519066e136
2 changed files with 27 additions and 1 deletions

View File

@ -52,6 +52,11 @@ easily extend the API.
The identifier interface forces whatever interface that embeds this one to be
uniquely identifiable.
### Configurator
The configurator interface is a way for the frontend to display configuration
options that the backend has.
### Server
A server is any entity that is usually a channel or a guild.
@ -61,11 +66,21 @@ A server is any entity that is usually a channel or a guild.
- ServerList and/or ServerMessage
- ServerIcon (optional)
### ServerMessage
A server message is an entity that contains messages to be displayed. An example
would be channels in Discord and IRC.
#### Interfaces
- ServerMessageSender (optional): adds message sending capability.
- ServerMessageSendCompleter (optional): adds message completion capability.
### Messages
#### Interfaces
- MessageHeader
- MessageHeader: the minimum for a proper message.
- MessageCreate or MessageUpdate or MessageDelete
- MessageNonce (optional)
- MessageAuthorAvatar (optional)

View File

@ -141,10 +141,21 @@ type ServerMessage interface {
// LeaveServer indicates the backend to stop calling the controller over.
// This should be called before any other JoinServer() calls are made.
LeaveServer() error
}
// ServerMessageSender optionally extends ServerMessage to add message sending
// capability to the server.
type ServerMessageSender interface {
// SendMessage is called by the frontend to send a message to this channel.
SendMessage(SendableMessage) error
}
// ServerMessageSendCompleter optionally extends ServerMessageSender to add
// autocompletion into the message composer.
type ServerMessageSendCompleter interface {
CompleteMessage(words []string, wordIndex int) []string
}
// SendableMessage is the bare minimum interface of a sendable message, that is,
// a message that can be sent with SendMessage().
type SendableMessage interface {