mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-13 15:47:17 +03:00
chat: Better comments
This commit is contained in:
parent
a1b891aae2
commit
40f6957e93
@ -13,30 +13,28 @@ import (
|
||||
"github.com/shazow/ssh-chat/set"
|
||||
)
|
||||
|
||||
// The error returned when an invalid command is issued.
|
||||
// ErrInvalidCommand is the error returned when an invalid command is issued.
|
||||
var ErrInvalidCommand = errors.New("invalid command")
|
||||
|
||||
// The error returned when a command is given without an owner.
|
||||
// ErrNoOwner is the error returned when a command is given without an owner.
|
||||
var ErrNoOwner = errors.New("command without owner")
|
||||
|
||||
// The error returned when a command is performed without the necessary number
|
||||
// of arguments.
|
||||
// ErrMissingArg is the error returned when a command is performed without the necessary
|
||||
// number of arguments.
|
||||
var ErrMissingArg = errors.New("missing argument")
|
||||
|
||||
// The error returned when a command is added without a prefix.
|
||||
// ErrMissingPrefix is the error returned when a command is added without a prefix.
|
||||
var ErrMissingPrefix = errors.New("command missing prefix")
|
||||
|
||||
// Command is a definition of a handler for a command.
|
||||
type Command struct {
|
||||
// The command's key, such as /foo
|
||||
Prefix string
|
||||
// Extra help regarding arguments
|
||||
PrefixHelp string
|
||||
// If omitted, command is hidden from /help
|
||||
Help string
|
||||
Prefix string // The command's key, such as /foo
|
||||
PrefixHelp string // Extra help regarding arguments
|
||||
Help string // help text, if omitted, command is hidden from /help
|
||||
Op bool // does the command require Op permissions?
|
||||
|
||||
// Handler for the command
|
||||
Handler func(*Room, message.CommandMsg) error
|
||||
// Command requires Op permissions
|
||||
Op bool
|
||||
}
|
||||
|
||||
// Commands is a registry of available commands.
|
||||
|
@ -5,6 +5,7 @@ import stdlog "log"
|
||||
|
||||
var logger *stdlog.Logger
|
||||
|
||||
// SetLogger changes the logger used for logging inside the package
|
||||
func SetLogger(w io.Writer) {
|
||||
flags := stdlog.Flags()
|
||||
prefix := "[chat] "
|
||||
|
@ -14,12 +14,12 @@ import (
|
||||
const historyLen = 20
|
||||
const roomBuffer = 10
|
||||
|
||||
// The error returned when a message is sent to a room that is already
|
||||
// ErrRoomClosed is the error returned when a message is sent to a room that is already
|
||||
// closed.
|
||||
var ErrRoomClosed = errors.New("room closed")
|
||||
|
||||
// The error returned when a user attempts to join with an invalid name, such
|
||||
// as empty string.
|
||||
// ErrInvalidName is the error returned when a user attempts to join with an invalid name,
|
||||
// such as empty string.
|
||||
var ErrInvalidName = errors.New("invalid name")
|
||||
|
||||
// Member is a User with per-Room metadata attached to it.
|
||||
@ -200,6 +200,7 @@ func (r *Room) Member(u *message.User) (*Member, bool) {
|
||||
return m, true
|
||||
}
|
||||
|
||||
// MemberByID Gets a member by an id / name
|
||||
func (r *Room) MemberByID(id string) (*Member, bool) {
|
||||
m, err := r.Members.Get(id)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user