nmdc-ircfrontend/typedefs.go
2016-05-03 18:47:24 +12:00

103 lines
1.5 KiB
Go

package main
import (
"regexp"
)
const (
VERSION = "1.0.0"
APP_DESCRIPTION = "nmdc-ircfrontend v" + VERSION
BLESSED_CHANNEL = "#chat" // must be lowercase
BLESSED_CHANNEL_MODE = "n" // means that you have to be in the channel to chat, but that's it
NICKS_PER_PROTOMSG = 128 //The capacity sets the max number of nicks to send per message
CLIENT_READ_BUFFSIZE = 512
CLIENT_READ_TIMEOUT_SEC = 3
)
var (
nickRegexp = regexp.MustCompile(`^[a-zA-Z\[\]_^{|}][a-zA-Z0-9\[\]_^{|}]*$`)
channelRegexp = regexp.MustCompile(`^#[a-zA-Z0-9_\-]+$`)
)
type eventType int
const (
disconnected eventType = iota
command
)
type Event struct {
client *Client
input string
event eventType
}
type Channel struct {
clientMap map[string]*Client
modeMap map[string]*ClientMode
}
type ClientMode struct {
operator bool //Channel operator
}
func (m *ClientMode) Prefix() string {
if m.operator {
return "@"
} else {
return ""
}
}
func (m *ClientMode) String() string {
if m.operator {
return "o"
} else {
return ""
}
}
type signalCode int
const (
signalStop signalCode = iota
)
type replyCode int
const (
rplWelcome replyCode = iota
rplJoin
rplPart
rplTopic
rplNoTopic
rplNames
rplEndOfNames
rplNickChange
rplKill
rplMsg
rplList
rplListEnd
rplOper
rplChannelModeIs
rplKick
rplInfo
rplVersion
rplMOTDStart
rplMOTD
rplEndOfMOTD
rplPong
errMoreArgs
errNoNick
errInvalidNick
errNickInUse
errAlreadyReg
errNoSuchNick
errUnknownCommand
errNotReg
errPassword
errNoPriv
errCannotSend
)