Documentation ¶
Index ¶
- Constants
- Variables
- func SetLogger(w io.Writer)
- type AnnounceMsg
- type Color0
- type Color256
- type CommandMsg
- type EmoteMsg
- type History
- type Identifier
- type Message
- type MessageFrom
- type MessageTo
- type Msg
- type Palette
- type PrivateMsg
- type PublicMsg
- type SimpleID
- type Style
- type SystemMsg
- type Theme
- type User
- func (u *User) Close()
- func (u *User) Config() UserConfig
- func (u *User) Consume()
- func (u *User) ConsumeOne() Message
- func (u *User) HandleMsg(m Message) error
- func (u *User) HasMessages() bool
- func (u *User) ReplyTo() *User
- func (u *User) Send(m Message) error
- func (u *User) SetConfig(cfg UserConfig)
- func (u *User) SetHighlight(s string) error
- func (u *User) SetID(id string)
- func (u *User) SetReplyTo(user *User)
- type UserConfig
Constants ¶
const ( // Reset resets the color Reset = "\033[0m" // Bold makes the following text bold Bold = "\033[1m" // Dim dims the following text Dim = "\033[2m" // Italic makes the following text italic Italic = "\033[3m" // Underline underlines the following text Underline = "\033[4m" // Blink blinks the following text Blink = "\033[5m" // Invert inverts the following text Invert = "\033[7m" // Newline Newline = "\r\n" // BEL Bel = "\007" )
Variables ¶
var ErrUserClosed = errors.New("user closed")
var Themes []Theme
List of initialzied themes
Functions ¶
Types ¶
type AnnounceMsg ¶
type AnnounceMsg struct {
Msg
}
AnnounceMsg is a message sent from the server to everyone, like a join or leave event.
func NewAnnounceMsg ¶
func NewAnnounceMsg(body string) *AnnounceMsg
func (AnnounceMsg) Render ¶
func (m AnnounceMsg) Render(t *Theme) string
func (AnnounceMsg) String ¶
func (m AnnounceMsg) String() string
type Color256 ¶
type Color256 uint8
256 color type, for terminals who support it
type CommandMsg ¶
type CommandMsg struct { PublicMsg // contains filtered or unexported fields }
func (CommandMsg) Args ¶
func (m CommandMsg) Args() []string
func (CommandMsg) Body ¶
func (m CommandMsg) Body() string
func (CommandMsg) Command ¶
func (m CommandMsg) Command() string
type EmoteMsg ¶
type EmoteMsg struct { Msg // contains filtered or unexported fields }
EmoteMsg is a /me message sent to the room. It specifically does not extend PublicMsg because it doesn't implement MessageFrom to allow the sender to see the emote.
func NewEmoteMsg ¶
type History ¶
History contains the history entries
func NewHistory ¶
NewHistory constructs a new history of the given size
type Identifier ¶
Identifier is an interface that can uniquely identify itself.
type Message ¶
type Message interface { Render(*Theme) string String() string Command() string Timestamp() time.Time }
Message is an interface for messages.
func ParseInput ¶
type MessageFrom ¶
type Msg ¶
type Msg struct {
// contains filtered or unexported fields
}
Msg is a base type for other message types.
type Palette ¶
type Palette struct {
// contains filtered or unexported fields
}
Container for a collection of colors
func Color256Palette ¶
type PrivateMsg ¶
type PrivateMsg struct { PublicMsg // contains filtered or unexported fields }
PrivateMsg is a message sent to another user, not shown to anyone else.
func NewPrivateMsg ¶
func NewPrivateMsg(body string, from *User, to *User) PrivateMsg
func (PrivateMsg) Render ¶
func (m PrivateMsg) Render(t *Theme) string
func (PrivateMsg) String ¶
func (m PrivateMsg) String() string
func (PrivateMsg) To ¶
func (m PrivateMsg) To() *User
type PublicMsg ¶
type PublicMsg struct { Msg // contains filtered or unexported fields }
PublicMsg is any message from a user sent to the room.
func NewPublicMsg ¶
func (PublicMsg) ParseCommand ¶
func (m PublicMsg) ParseCommand() (*CommandMsg, bool)
func (PublicMsg) RenderFor ¶
func (m PublicMsg) RenderFor(cfg UserConfig) string
type SimpleID ¶
type SimpleID string
SimpleID is a simple Identifier implementation used for testing.
type SystemMsg ¶
type SystemMsg struct { Msg // contains filtered or unexported fields }
SystemMsg is a response sent from the server directly to a user, not shown to anyone else. Usually in response to something, like /help.
func NewSystemMsg ¶
type Theme ¶
type Theme struct {
// contains filtered or unexported fields
}
Collection of settings for chat
var DefaultTheme *Theme
Default theme to use
type User ¶
type User struct { Identifier Ignored *set.Set // contains filtered or unexported fields }
User definition, implemented set Item interface and io.Writer
func NewUser ¶
func NewUser(identity Identifier) *User
func NewUserScreen ¶
func NewUserScreen(identity Identifier, screen io.WriteCloser) *User
func (*User) Config ¶
func (u *User) Config() UserConfig
func (*User) Consume ¶
func (u *User) Consume()
Consume message buffer into the handler. Will block, should be called in a goroutine.
func (*User) ConsumeOne ¶
Consume one message and stop, mostly for testing
func (*User) HasMessages ¶
Check if there are pending messages, used for testing
func (*User) SetConfig ¶
func (u *User) SetConfig(cfg UserConfig)
func (*User) SetHighlight ¶
SetHighlight sets the highlighting regular expression to match string.
func (*User) SetReplyTo ¶
SetReplyTo sets the last user to message this user.
type UserConfig ¶
Container for per-user configurations.
var DefaultUserConfig UserConfig
Default user configuration to use