Compare commits
4 Commits
da5c38eb2f
...
f24feb2002
Author | SHA1 | Date |
---|---|---|
diamondburned | f24feb2002 | |
diamondburned | f8c644fa7e | |
diamondburned | c7d4473c23 | |
diamondburned | 174496bdf9 |
19
cchat.go
19
cchat.go
|
@ -523,7 +523,9 @@ type MessageHeader interface {
|
|||
// behaves similarly to MessageCreate, except all fields are optional. The
|
||||
// frontend is responsible for checking which field is not empty and check it.
|
||||
type MessageUpdate interface {
|
||||
MessageCreate
|
||||
MessageHeader
|
||||
|
||||
Content() text.Rich
|
||||
}
|
||||
|
||||
// MessagesContainer is a view implementation that displays a list of messages
|
||||
|
@ -588,7 +590,7 @@ type Namer interface {
|
|||
// implement ServerMessage also don't need to implement ServerNickname. By
|
||||
// default, the session name should be used.
|
||||
type Nicknamer interface {
|
||||
Nickname(context.Context, LabelContainer) (stop func(), err error)
|
||||
Namer
|
||||
}
|
||||
|
||||
// Noncer adds nonce support. A nonce is defined in this context as a unique
|
||||
|
@ -731,9 +733,9 @@ type ServersContainer interface {
|
|||
SetServers([]Server)
|
||||
}
|
||||
|
||||
// A service is a complete service that's capable of multiple sessions. It has
|
||||
// to implement the Authenticate() method, which returns multiple
|
||||
// implementations of Authenticator.
|
||||
// Service is a complete service that's capable of multiple sessions. It has to
|
||||
// implement the Authenticate() method, which returns multiple implementations
|
||||
// of Authenticator.
|
||||
//
|
||||
// A service can implement SessionRestorer, which would indicate the frontend
|
||||
// that it can restore past sessions. Sessions are saved using the SessionSaver
|
||||
|
@ -745,6 +747,13 @@ type ServersContainer interface {
|
|||
// configurations must be optional, as frontends may not implement a
|
||||
// configurator UI.
|
||||
type Service interface {
|
||||
// Identifier returns the unique identifier for the service. There is no
|
||||
// enforced representation, but services are recommended to follow the Reverse
|
||||
// Domain Name Notation for consistency. An example of that would be:
|
||||
//
|
||||
// com.github.diamondburned.cchat-discord
|
||||
// com.github.username.service
|
||||
Identifier
|
||||
// Namer returns the name of the service.
|
||||
Namer
|
||||
|
||||
|
|
Binary file not shown.
|
@ -651,7 +651,7 @@ var Main = Packages{
|
|||
},
|
||||
}, {
|
||||
Comment: Comment{`
|
||||
A service is a complete service that's capable of multiple
|
||||
Service is a complete service that's capable of multiple
|
||||
sessions. It has to implement the Authenticate() method, which
|
||||
returns multiple implementations of Authenticator.
|
||||
|
||||
|
@ -668,6 +668,17 @@ var Main = Packages{
|
|||
`},
|
||||
Name: "Service",
|
||||
Embeds: []EmbeddedInterface{{
|
||||
Comment: Comment{`
|
||||
Identifier returns the unique identifier for the service. There
|
||||
is no enforced representation, but services are recommended to
|
||||
follow the Reverse Domain Name Notation for consistency. An
|
||||
example of that would be:
|
||||
|
||||
com.github.diamondburned.cchat-discord
|
||||
com.github.username.service
|
||||
`},
|
||||
InterfaceName: "Identifier",
|
||||
}, {
|
||||
Comment: Comment{`
|
||||
Namer returns the name of the service.
|
||||
`},
|
||||
|
@ -1200,14 +1211,8 @@ var Main = Packages{
|
|||
implement ServerNickname. By default, the session name should be
|
||||
used.
|
||||
`},
|
||||
Name: "Nicknamer",
|
||||
Methods: []Method{
|
||||
ContainerMethod{
|
||||
method: method{Name: "Nickname"},
|
||||
HasContext: true,
|
||||
ContainerType: "LabelContainer",
|
||||
},
|
||||
},
|
||||
Name: "Nicknamer",
|
||||
Embeds: []EmbeddedInterface{{InterfaceName: "Namer"}},
|
||||
}, {
|
||||
Comment: Comment{`
|
||||
Backlogger adds message history capabilities into a message
|
||||
|
@ -1597,12 +1602,20 @@ var Main = Packages{
|
|||
}, {
|
||||
Comment: Comment{`
|
||||
MessageUpdate is the interface for a message update (or edit)
|
||||
event. It behaves similarly to MessageCreate, except all fields
|
||||
are optional. The frontend is responsible for checking which
|
||||
field is not empty and check it.
|
||||
event. It is only responsible for updating a message's content.
|
||||
The author's name should be updated using MessageCreate's
|
||||
Author.
|
||||
`},
|
||||
Name: "MessageUpdate",
|
||||
Embeds: []EmbeddedInterface{{InterfaceName: "MessageCreate"}},
|
||||
Embeds: []EmbeddedInterface{{InterfaceName: "MessageHeader"}},
|
||||
Methods: []Method{
|
||||
GetterMethod{
|
||||
method: method{Name: "Content"},
|
||||
Returns: []NamedType{{
|
||||
Type: MakeQual("text", "Rich"),
|
||||
}},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
Comment: Comment{`
|
||||
MessageDelete is the interface for a message delete event.
|
||||
|
|
|
@ -11,7 +11,9 @@ func SolidColor(rgb uint32) uint32 {
|
|||
return (rgb << 8) | 0xFF
|
||||
}
|
||||
|
||||
// IsEmpty returns true if the given rich segment's content is empty.
|
||||
// IsEmpty returns true if the given rich segment's content is empty. Note that
|
||||
// a rich text is not necessarily empty if the content is empty, because there
|
||||
// may be images within the segments.
|
||||
func (r Rich) IsEmpty() bool {
|
||||
return r.Content == ""
|
||||
return r.Content == "" && len(r.Segments) == 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue