3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 07:29:31 +01:00

don't send prefix on server-originated string coded replies

This commit is contained in:
Jeremy Latt 2014-02-20 20:08:32 -08:00
parent 0ad05abf5f
commit e1c4c8e8cc
3 changed files with 11 additions and 13 deletions

View File

@ -175,7 +175,7 @@ func (client *Client) Touch() {
} }
func (client *Client) Idle() { func (client *Client) Idle() {
client.replies <- RplPing(client.server, client) client.replies <- RplPing(client)
if client.quitTimer == nil { if client.quitTimer == nil {
client.quitTimer = time.AfterFunc(QUIT_TIMEOUT, client.connectionTimeout) client.quitTimer = time.AfterFunc(QUIT_TIMEOUT, client.connectionTimeout)
@ -304,7 +304,7 @@ func (client *Client) Quit(message string) {
return return
} }
client.replies <- RplError(client.server, "connection closed") client.replies <- RplError("connection closed")
client.replies <- EOF client.replies <- EOF
client.hasQuit = true client.hasQuit = true

View File

@ -9,11 +9,9 @@ import (
func NewStringReply(source Identifier, code StringCode, func NewStringReply(source Identifier, code StringCode,
format string, args ...interface{}) string { format string, args ...interface{}) string {
var header string var header string
switch source.(type) { if source == nil {
case *Server:
// TODO only omit prefix for local server
header = fmt.Sprintf("%s ", code) header = fmt.Sprintf("%s ", code)
default: } else {
header = fmt.Sprintf(":%s %s ", source, code) header = fmt.Sprintf(":%s %s ", source, code)
} }
message := fmt.Sprintf(format, args...) message := fmt.Sprintf(format, args...)
@ -104,20 +102,20 @@ func RplTopicMsg(source Identifier, channel *Channel) string {
return NewStringReply(source, TOPIC, "%s :%s", channel, channel.topic) return NewStringReply(source, TOPIC, "%s :%s", channel, channel.topic)
} }
func RplPing(server *Server, target Identifier) string { func RplPing(target Identifier) string {
return NewStringReply(server, PING, ":%s", target.Nick()) return NewStringReply(nil, PING, ":%s", target.Nick())
} }
func RplPong(server *Server, client *Client) string { func RplPong(client *Client) string {
return NewStringReply(server, PONG, client.Nick()) return NewStringReply(nil, PONG, client.Nick())
} }
func RplQuit(client *Client, message string) string { func RplQuit(client *Client, message string) string {
return NewStringReply(client, QUIT, ":%s", message) return NewStringReply(client, QUIT, ":%s", message)
} }
func RplError(server *Server, message string) string { func RplError(message string) string {
return NewStringReply(server, ERROR, ":%s", message) return NewStringReply(nil, ERROR, ":%s", message)
} }
func RplInviteMsg(channel *Channel, inviter *Client) string { func RplInviteMsg(channel *Channel, inviter *Client) string {

View File

@ -351,7 +351,7 @@ func (m *PassCommand) HandleServer(s *Server) {
} }
func (m *PingCommand) HandleServer(s *Server) { func (m *PingCommand) HandleServer(s *Server) {
m.Client().replies <- RplPong(s, m.Client()) m.Client().replies <- RplPong(m.Client())
} }
func (m *PongCommand) HandleServer(s *Server) { func (m *PongCommand) HandleServer(s *Server) {