mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-14 07:59:31 +01:00
use server.name and server.nameString, name for checking and getting nice comparison, nameString for reply outputs
This commit is contained in:
parent
7b13858f8c
commit
2a519c8061
@ -96,23 +96,23 @@ func capHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
// client.server needs to be here to workaround a parsing bug in weechat 1.4
|
// client.server needs to be here to workaround a parsing bug in weechat 1.4
|
||||||
// and let it connect to the server (otherwise it doesn't respond to the CAP
|
// and let it connect to the server (otherwise it doesn't respond to the CAP
|
||||||
// message with anything and just hangs on connection)
|
// message with anything and just hangs on connection)
|
||||||
client.Send(nil, server.name, "CAP", client.nickString, subCommand, SupportedCapabilities.String())
|
client.Send(nil, server.nameString, "CAP", client.nickString, subCommand, SupportedCapabilities.String())
|
||||||
|
|
||||||
case "LIST":
|
case "LIST":
|
||||||
client.Send(nil, server.name, "CAP", client.nickString, subCommand, client.capabilities.String())
|
client.Send(nil, server.nameString, "CAP", client.nickString, subCommand, client.capabilities.String())
|
||||||
|
|
||||||
case "REQ":
|
case "REQ":
|
||||||
// make sure all capabilities actually exist
|
// make sure all capabilities actually exist
|
||||||
for capability := range capabilities {
|
for capability := range capabilities {
|
||||||
if !SupportedCapabilities[capability] {
|
if !SupportedCapabilities[capability] {
|
||||||
client.Send(nil, server.name, "CAP", client.nickString, subCommand, capString)
|
client.Send(nil, server.nameString, "CAP", client.nickString, subCommand, capString)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for capability := range capabilities {
|
for capability := range capabilities {
|
||||||
client.capabilities[capability] = true
|
client.capabilities[capability] = true
|
||||||
}
|
}
|
||||||
client.Send(nil, server.name, "CAP", client.nickString, subCommand, capString)
|
client.Send(nil, server.nameString, "CAP", client.nickString, subCommand, capString)
|
||||||
|
|
||||||
case "END":
|
case "END":
|
||||||
if !client.registered {
|
if !client.registered {
|
||||||
@ -121,7 +121,7 @@ func capHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
client.Send(nil, server.name, ERR_INVALIDCAPCMD, client.nickString, subCommand, "Invalid CAP subcommand")
|
client.Send(nil, server.nameString, ERR_INVALIDCAPCMD, client.nickString, subCommand, "Invalid CAP subcommand")
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func (channel *Channel) IsEmpty() bool {
|
|||||||
func (channel *Channel) Names(client *Client) {
|
func (channel *Channel) Names(client *Client) {
|
||||||
currentNicks := channel.Nicks(client)
|
currentNicks := channel.Nicks(client)
|
||||||
// assemble and send replies
|
// assemble and send replies
|
||||||
maxNamLen := 480 - len(client.server.name) - len(client.nickString)
|
maxNamLen := 480 - len(client.server.nameString) - len(client.nickString)
|
||||||
var buffer string
|
var buffer string
|
||||||
for _, nick := range currentNicks {
|
for _, nick := range currentNicks {
|
||||||
if buffer == "" {
|
if buffer == "" {
|
||||||
@ -66,7 +66,7 @@ func (channel *Channel) Names(client *Client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(buffer)+1+len(nick) > maxNamLen {
|
if len(buffer)+1+len(nick) > maxNamLen {
|
||||||
client.Send(nil, client.server.name, RPL_NAMREPLY, "=", channel.nameString, buffer)
|
client.Send(nil, client.server.nameString, RPL_NAMREPLY, "=", channel.nameString, buffer)
|
||||||
buffer = nick
|
buffer = nick
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -75,8 +75,8 @@ func (channel *Channel) Names(client *Client) {
|
|||||||
buffer += nick
|
buffer += nick
|
||||||
}
|
}
|
||||||
|
|
||||||
client.Send(nil, client.server.name, RPL_NAMREPLY, "=", channel.nameString, buffer)
|
client.Send(nil, client.server.nameString, RPL_NAMREPLY, "=", channel.nameString, buffer)
|
||||||
client.Send(nil, client.server.name, RPL_ENDOFNAMES, channel.nameString, "End of NAMES list")
|
client.Send(nil, client.server.nameString, RPL_ENDOFNAMES, channel.nameString, "End of NAMES list")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) ClientIsOperator(client *Client) bool {
|
func (channel *Channel) ClientIsOperator(client *Client) bool {
|
||||||
@ -177,25 +177,25 @@ func (channel *Channel) Join(client *Client, key string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if channel.IsFull() {
|
if channel.IsFull() {
|
||||||
client.Send(nil, client.server.name, ERR_CHANNELISFULL, channel.nameString, "Cannot join channel (+l)")
|
client.Send(nil, client.server.nameString, ERR_CHANNELISFULL, channel.nameString, "Cannot join channel (+l)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !channel.CheckKey(key) {
|
if !channel.CheckKey(key) {
|
||||||
client.Send(nil, client.server.name, ERR_BADCHANNELKEY, channel.nameString, "Cannot join channel (+k)")
|
client.Send(nil, client.server.nameString, ERR_BADCHANNELKEY, channel.nameString, "Cannot join channel (+k)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
isInvited := channel.lists[InviteMask].Match(client.UserHost())
|
isInvited := channel.lists[InviteMask].Match(client.UserHost())
|
||||||
if channel.flags[InviteOnly] && !isInvited {
|
if channel.flags[InviteOnly] && !isInvited {
|
||||||
client.Send(nil, client.server.name, ERR_INVITEONLYCHAN, channel.nameString, "Cannot join channel (+i)")
|
client.Send(nil, client.server.nameString, ERR_INVITEONLYCHAN, channel.nameString, "Cannot join channel (+i)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if channel.lists[BanMask].Match(client.UserHost()) &&
|
if channel.lists[BanMask].Match(client.UserHost()) &&
|
||||||
!isInvited &&
|
!isInvited &&
|
||||||
!channel.lists[ExceptMask].Match(client.UserHost()) {
|
!channel.lists[ExceptMask].Match(client.UserHost()) {
|
||||||
client.Send(nil, client.server.name, ERR_BANNEDFROMCHAN, channel.nameString, "Cannot join channel (+b)")
|
client.Send(nil, client.server.nameString, ERR_BANNEDFROMCHAN, channel.nameString, "Cannot join channel (+b)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ func (channel *Channel) Join(client *Client, key string) {
|
|||||||
|
|
||||||
func (channel *Channel) Part(client *Client, message string) {
|
func (channel *Channel) Part(client *Client, message string) {
|
||||||
if !channel.members.Has(client) {
|
if !channel.members.Has(client) {
|
||||||
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
client.Send(nil, client.server.nameString, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ func (channel *Channel) Part(client *Client, message string) {
|
|||||||
|
|
||||||
func (channel *Channel) GetTopic(client *Client) {
|
func (channel *Channel) GetTopic(client *Client) {
|
||||||
if !channel.members.Has(client) {
|
if !channel.members.Has(client) {
|
||||||
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
client.Send(nil, client.server.nameString, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,17 +243,17 @@ func (channel *Channel) GetTopic(client *Client) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
client.Send(nil, client.server.name, RPL_TOPIC, channel.nameString, channel.topic)
|
client.Send(nil, client.server.nameString, RPL_TOPIC, channel.nameString, channel.topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) SetTopic(client *Client, topic string) {
|
func (channel *Channel) SetTopic(client *Client, topic string) {
|
||||||
if !(client.flags[Operator] || channel.members.Has(client)) {
|
if !(client.flags[Operator] || channel.members.Has(client)) {
|
||||||
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
client.Send(nil, client.server.nameString, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if channel.flags[OpOnlyTopic] && !channel.ClientIsOperator(client) {
|
if channel.flags[OpOnlyTopic] && !channel.ClientIsOperator(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
client.Send(nil, client.server.nameString, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ func (channel *Channel) CanSpeak(client *Client) bool {
|
|||||||
|
|
||||||
func (channel *Channel) PrivMsg(client *Client, message string) {
|
func (channel *Channel) PrivMsg(client *Client, message string) {
|
||||||
if !channel.CanSpeak(client) {
|
if !channel.CanSpeak(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.nameString, "Cannot send to channel")
|
client.Send(nil, client.server.nameString, ERR_CANNOTSENDTOCHAN, channel.nameString, "Cannot send to channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for member := range channel.members {
|
for member := range channel.members {
|
||||||
@ -299,7 +299,7 @@ func (channel *Channel) PrivMsg(client *Client, message string) {
|
|||||||
func (channel *Channel) applyModeFlag(client *Client, mode ChannelMode,
|
func (channel *Channel) applyModeFlag(client *Client, mode ChannelMode,
|
||||||
op ModeOp) bool {
|
op ModeOp) bool {
|
||||||
if !channel.ClientIsOperator(client) {
|
if !channel.ClientIsOperator(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
client.Send(nil, client.server.nameString, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,13 +324,13 @@ func (channel *Channel) applyModeFlag(client *Client, mode ChannelMode,
|
|||||||
func (channel *Channel) applyModeMember(client *Client, mode ChannelMode,
|
func (channel *Channel) applyModeMember(client *Client, mode ChannelMode,
|
||||||
op ModeOp, nick string) bool {
|
op ModeOp, nick string) bool {
|
||||||
if !channel.ClientIsOperator(client) {
|
if !channel.ClientIsOperator(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
client.Send(nil, client.server.nameString, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if nick == "" {
|
if nick == "" {
|
||||||
//TODO(dan): shouldn't this be handled before it reaches this function?
|
//TODO(dan): shouldn't this be handled before it reaches this function?
|
||||||
client.Send(nil, client.server.name, ERR_NEEDMOREPARAMS, "MODE", "Not enough parameters")
|
client.Send(nil, client.server.nameString, ERR_NEEDMOREPARAMS, "MODE", "Not enough parameters")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,12 +338,12 @@ func (channel *Channel) applyModeMember(client *Client, mode ChannelMode,
|
|||||||
if target == nil {
|
if target == nil {
|
||||||
//TODO(dan): investigate using NOSUCHNICK and NOSUCHCHANNEL specifically as that other IRCd (insp?) does,
|
//TODO(dan): investigate using NOSUCHNICK and NOSUCHCHANNEL specifically as that other IRCd (insp?) does,
|
||||||
// since I think that would make sense
|
// since I think that would make sense
|
||||||
client.Send(nil, client.server.name, ERR_NOSUCHNICK, nick, "No such nick/channel")
|
client.Send(nil, client.server.nameString, ERR_NOSUCHNICK, nick, "No such nick/channel")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if !channel.members.Has(target) {
|
if !channel.members.Has(target) {
|
||||||
client.Send(nil, client.server.name, ERR_USERNOTINCHANNEL, client.nickString, channel.nameString, "They aren't on that channel")
|
client.Send(nil, client.server.nameString, ERR_USERNOTINCHANNEL, client.nickString, channel.nameString, "They aren't on that channel")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +389,7 @@ func (channel *Channel) applyModeMask(client *Client, mode ChannelMode, op ModeO
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !channel.ClientIsOperator(client) {
|
if !channel.ClientIsOperator(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
client.Send(nil, client.server.nameString, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,14 +415,14 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
|
|||||||
|
|
||||||
case Key:
|
case Key:
|
||||||
if !channel.ClientIsOperator(client) {
|
if !channel.ClientIsOperator(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
client.Send(nil, client.server.nameString, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
switch change.op {
|
switch change.op {
|
||||||
case Add:
|
case Add:
|
||||||
if change.arg == "" {
|
if change.arg == "" {
|
||||||
client.Send(nil, client.server.name, ERR_NEEDMOREPARAMS, "MODE", "Not enough parameters")
|
client.Send(nil, client.server.nameString, ERR_NEEDMOREPARAMS, "MODE", "Not enough parameters")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
key := change.arg
|
key := change.arg
|
||||||
@ -441,7 +441,7 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
|
|||||||
case UserLimit:
|
case UserLimit:
|
||||||
limit, err := strconv.ParseUint(change.arg, 10, 64)
|
limit, err := strconv.ParseUint(change.arg, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
client.Send(nil, client.server.name, ERR_NEEDMOREPARAMS, "MODE", "Not enough parameters")
|
client.Send(nil, client.server.nameString, ERR_NEEDMOREPARAMS, "MODE", "Not enough parameters")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (limit == 0) || (limit == channel.userLimit) {
|
if (limit == 0) || (limit == channel.userLimit) {
|
||||||
@ -477,7 +477,7 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
|
|||||||
if change.op == Remove && name.ToLower() == client.nick.ToLower() {
|
if change.op == Remove && name.ToLower() == client.nick.ToLower() {
|
||||||
// success!
|
// success!
|
||||||
} else {
|
} else {
|
||||||
client.Send(nil, client.server.name, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
client.Send(nil, client.server.nameString, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,14 +485,14 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
|
|||||||
return channel.applyModeMember(client, change.mode, change.op, name.String())
|
return channel.applyModeMember(client, change.mode, change.op, name.String())
|
||||||
|
|
||||||
default:
|
default:
|
||||||
client.Send(nil, client.server.name, ERR_UNKNOWNMODE, change.mode.String(), fmt.Sprintf(":is an unknown mode char to me for %s", channel))
|
client.Send(nil, client.server.nameString, ERR_UNKNOWNMODE, change.mode.String(), fmt.Sprintf(":is an unknown mode char to me for %s", channel))
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) {
|
func (channel *Channel) Mode(client *Client, changes ChannelModeChanges) {
|
||||||
if len(changes) == 0 {
|
if len(changes) == 0 {
|
||||||
client.Send(nil, client.server.name, RPL_CHANNELMODEIS, channel.nameString, channel.ModeString(client))
|
client.Send(nil, client.server.nameString, RPL_CHANNELMODEIS, channel.nameString, channel.ModeString(client))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,7 +534,7 @@ func (channel *Channel) Persist() (err error) {
|
|||||||
|
|
||||||
func (channel *Channel) Notice(client *Client, message string) {
|
func (channel *Channel) Notice(client *Client, message string) {
|
||||||
if !channel.CanSpeak(client) {
|
if !channel.CanSpeak(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.nameString, "Cannot send to channel")
|
client.Send(nil, client.server.nameString, ERR_CANNOTSENDTOCHAN, channel.nameString, "Cannot send to channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for member := range channel.members {
|
for member := range channel.members {
|
||||||
@ -556,15 +556,15 @@ func (channel *Channel) Quit(client *Client) {
|
|||||||
|
|
||||||
func (channel *Channel) Kick(client *Client, target *Client, comment string) {
|
func (channel *Channel) Kick(client *Client, target *Client, comment string) {
|
||||||
if !(client.flags[Operator] || channel.members.Has(client)) {
|
if !(client.flags[Operator] || channel.members.Has(client)) {
|
||||||
client.Send(nil, client.server.name, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
client.Send(nil, client.server.nameString, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !channel.ClientIsOperator(client) {
|
if !channel.ClientIsOperator(client) {
|
||||||
client.Send(nil, client.server.name, ERR_CANNOTSENDTOCHAN, channel.nameString, "Cannot send to channel")
|
client.Send(nil, client.server.nameString, ERR_CANNOTSENDTOCHAN, channel.nameString, "Cannot send to channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !channel.members.Has(target) {
|
if !channel.members.Has(target) {
|
||||||
client.Send(nil, client.server.name, ERR_USERNOTINCHANNEL, client.nickString, channel.nameString, "They aren't on that channel")
|
client.Send(nil, client.server.nameString, ERR_USERNOTINCHANNEL, client.nickString, channel.nameString, "They aren't on that channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,12 +576,12 @@ func (channel *Channel) Kick(client *Client, target *Client, comment string) {
|
|||||||
|
|
||||||
func (channel *Channel) Invite(invitee *Client, inviter *Client) {
|
func (channel *Channel) Invite(invitee *Client, inviter *Client) {
|
||||||
if channel.flags[InviteOnly] && !channel.ClientIsOperator(inviter) {
|
if channel.flags[InviteOnly] && !channel.ClientIsOperator(inviter) {
|
||||||
inviter.Send(nil, inviter.server.name, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
inviter.Send(nil, inviter.server.nameString, ERR_CHANOPRIVSNEEDED, channel.nameString, "You're not a channel operator")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !channel.members.Has(inviter) {
|
if !channel.members.Has(inviter) {
|
||||||
inviter.Send(nil, inviter.server.name, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
inviter.Send(nil, inviter.server.nameString, ERR_NOTONCHANNEL, channel.nameString, "You're not on that channel")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,10 +592,10 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO(dan): should inviter.server.name here be inviter.nickMaskString ?
|
//TODO(dan): should inviter.server.nameString here be inviter.nickMaskString ?
|
||||||
inviter.Send(nil, inviter.server.name, RPL_INVITING, invitee.nickString, channel.nameString)
|
inviter.Send(nil, inviter.server.nameString, RPL_INVITING, invitee.nickString, channel.nameString)
|
||||||
invitee.Send(nil, inviter.nickMaskString, "INVITE", invitee.nickString, channel.nameString)
|
invitee.Send(nil, inviter.nickMaskString, "INVITE", invitee.nickString, channel.nameString)
|
||||||
if invitee.flags[Away] {
|
if invitee.flags[Away] {
|
||||||
inviter.Send(nil, inviter.server.name, RPL_AWAY, invitee.nickString, invitee.awayMessage)
|
inviter.Send(nil, inviter.server.nameString, RPL_AWAY, invitee.nickString, invitee.awayMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ type Client struct {
|
|||||||
idleTimer *time.Timer
|
idleTimer *time.Timer
|
||||||
nick Name
|
nick Name
|
||||||
nickString string // cache for nick string since it's used with most numerics
|
nickString string // cache for nick string since it's used with most numerics
|
||||||
nickMaskString string // cache for nickmask string since it's used with every reply
|
nickMaskString string // cache for nickmask string since it's used with lots of replies
|
||||||
quitTimer *time.Timer
|
quitTimer *time.Timer
|
||||||
realname Text
|
realname Text
|
||||||
registered bool
|
registered bool
|
||||||
@ -313,5 +313,5 @@ func (client *Client) Send(tags *map[string]ircmsg.TagValue, prefix string, comm
|
|||||||
|
|
||||||
// Notice sends the client a notice from the server.
|
// Notice sends the client a notice from the server.
|
||||||
func (client *Client) Notice(text string) {
|
func (client *Client) Notice(text string) {
|
||||||
client.Send(nil, client.server.name, "NOTICE", client.nickString, text)
|
client.Send(nil, client.server.nameString, "NOTICE", client.nickString, text)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ func (cmd *Command) Run(server *Server, client *Client, msg ircmsg.IrcMessage) b
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if len(msg.Params) < cmd.minParams {
|
if len(msg.Params) < cmd.minParams {
|
||||||
client.Send(nil, server.name, ERR_NEEDMOREPARAMS, client.nickString, msg.Command, "Not enough parameters")
|
client.Send(nil, server.nameString, ERR_NEEDMOREPARAMS, client.nickString, msg.Command, "Not enough parameters")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
exiting := cmd.handler(server, client, msg)
|
exiting := cmd.handler(server, client, msg)
|
||||||
|
@ -31,7 +31,8 @@ type Server struct {
|
|||||||
db *sql.DB
|
db *sql.DB
|
||||||
idle chan *Client
|
idle chan *Client
|
||||||
motdLines []string
|
motdLines []string
|
||||||
name string
|
name Name
|
||||||
|
nameString string // cache for server name string since it's used with almost every reply
|
||||||
newConns chan net.Conn
|
newConns chan net.Conn
|
||||||
operators map[Name][]byte
|
operators map[Name][]byte
|
||||||
password []byte
|
password []byte
|
||||||
@ -56,6 +57,7 @@ func NewServer(config *Config) *Server {
|
|||||||
db: OpenDB(config.Server.Database),
|
db: OpenDB(config.Server.Database),
|
||||||
idle: make(chan *Client),
|
idle: make(chan *Client),
|
||||||
name: NewName(config.Server.Name),
|
name: NewName(config.Server.Name),
|
||||||
|
nameString: NewName(config.Server.Name).String(),
|
||||||
newConns: make(chan net.Conn),
|
newConns: make(chan net.Conn),
|
||||||
operators: config.Operators(),
|
operators: config.Operators(),
|
||||||
signals: make(chan os.Signal, len(SERVER_SIGNALS)),
|
signals: make(chan os.Signal, len(SERVER_SIGNALS)),
|
||||||
|
Loading…
Reference in New Issue
Block a user