Merge pull request #15 from iownall555/master

Update the Example IRC-Go Client to Function with the New Tag Handling System
This commit is contained in:
Daniel Oaks 2019-04-29 11:05:18 +10:00 committed by GitHub
commit 0f771dff99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 9 deletions

@ -5,11 +5,10 @@ package gircclient
import ( import (
"github.com/goshuirc/irc-go/ircfmt" "github.com/goshuirc/irc-go/ircfmt"
"github.com/goshuirc/irc-go/ircmsg"
) )
// Msg sends a message to the given target. // Msg sends a message to the given target.
func (sc *ServerConnection) Msg(tags *map[string]ircmsg.TagValue, target string, message string, escaped bool) { func (sc *ServerConnection) Msg(tags map[string]string, target string, message string, escaped bool) {
if escaped { if escaped {
message = ircfmt.Unescape(message) message = ircfmt.Unescape(message)
} }
@ -17,7 +16,7 @@ func (sc *ServerConnection) Msg(tags *map[string]ircmsg.TagValue, target string,
} }
// Notice sends a notice to the given target. // Notice sends a notice to the given target.
func (sc *ServerConnection) Notice(tags *map[string]ircmsg.TagValue, target string, message string, escaped bool) { func (sc *ServerConnection) Notice(tags map[string]string, target string, message string, escaped bool) {
if escaped { if escaped {
message = ircfmt.Unescape(message) message = ircfmt.Unescape(message)
} }

@ -156,7 +156,7 @@ func (sc *ServerConnection) ProcessIncomingLine(line string) {
info := eventmgr.NewInfoMap() info := eventmgr.NewInfoMap()
info["server"] = sc info["server"] = sc
info["direction"] = "in" info["direction"] = "in"
info["tags"] = message.Tags info["tags"] = message.AllTags()
info["prefix"] = message.Prefix info["prefix"] = message.Prefix
info["command"] = cmd info["command"] = cmd
info["params"] = message.Params info["params"] = message.Params
@ -236,7 +236,7 @@ func (sc *ServerConnection) Casefold(message string) (string, error) {
// Send sends an IRC message to the server. If the message cannot be converted // Send sends an IRC message to the server. If the message cannot be converted
// to a raw IRC line, an error is returned. // to a raw IRC line, an error is returned.
func (sc *ServerConnection) Send(tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) error { func (sc *ServerConnection) Send(tags map[string]string, prefix string, command string, params ...string) error {
msg := ircmsg.MakeMessage(tags, prefix, command, params...) msg := ircmsg.MakeMessage(tags, prefix, command, params...)
line, err := msg.Line() line, err := msg.Line()
if err != nil { if err != nil {
@ -251,11 +251,11 @@ func (sc *ServerConnection) Send(tags *map[string]ircmsg.TagValue, prefix string
info["data"] = line info["data"] = line
sc.dispatchRawOut(info) sc.dispatchRawOut(info)
var outTags map[string]ircmsg.TagValue var outTags map[string]string
if tags == nil { if tags == nil {
outTags = *ircmsg.MakeTags() outTags = map[string]string{}
} else { } else {
outTags = *tags outTags = tags
} }
// dispatch real event // dispatch real event

@ -122,7 +122,7 @@ func TestTLSConnection(t *testing.T) {
testServerConnection(t, reactor, client, listener) testServerConnection(t, reactor, client, listener)
} }
func sendMessage(conn net.Conn, tags *map[string]ircmsg.TagValue, prefix string, command string, params ...string) { func sendMessage(conn net.Conn, tags map[string]string, prefix string, command string, params ...string) {
ircmsg := ircmsg.MakeMessage(tags, prefix, command, params...) ircmsg := ircmsg.MakeMessage(tags, prefix, command, params...)
line, err := ircmsg.Line() line, err := ircmsg.Line()
if err != nil { if err != nil {