From 0ad0dd2989c51814266fa3ba2ffc82e5b4d609f5 Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Wed, 28 Aug 2013 16:38:54 +0100 Subject: [PATCH] Added ClientMode.Prefix() function --- client.go | 6 +----- rosella.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index a86cec7..52a88de 100644 --- a/client.go +++ b/client.go @@ -98,11 +98,7 @@ func (c *Client) joinChannel(channelName string) { nickKey := strings.ToLower(client.nick) if mode, exists := channel.modeMap[nickKey]; exists { - if mode.operator { - prefix = "@" - } else if mode.voice { - prefix = "+" - } + prefix = mode.Prefix() } nicks = append(nicks, fmt.Sprintf("%s%s", prefix, client.nick)) diff --git a/rosella.go b/rosella.go index e42c59f..c99ba25 100644 --- a/rosella.go +++ b/rosella.go @@ -65,6 +65,16 @@ type ClientMode struct { voice bool //Has voice } +func (m *ClientMode) Prefix() string { + if m.operator { + return "@" + } else if m.voice { + return "+" + } else { + return "" + } +} + type signalCode int const (