From 630efa186e661c46a535aa8fc0c96ad668a353fb Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 8 Nov 2016 15:12:50 -0800 Subject: [PATCH] Fixing up EchoBot for golint --- examples/echobot/main.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/echobot/main.go b/examples/echobot/main.go index 6234d90..604af11 100644 --- a/examples/echobot/main.go +++ b/examples/echobot/main.go @@ -5,24 +5,29 @@ import ( "log" ) +// EchoBotService is an example service which simply echoes back what a client +// sends it. type EchoBotService struct { goricochet.StandardRicochetService } -// Always Accept Contact Requests -func (ts *EchoBotService) IsKnownContact(hostname string) bool { +// IsKnownContact is configured to always accept Contact Requests +func (ebs *EchoBotService) IsKnownContact(hostname string) bool { return true } -func (ts *EchoBotService) OnContactRequest(oc *goricochet.OpenConnection, channelID int32, nick string, message string) { +// OnContactRequest - we always accept new contact request. +func (ebs *EchoBotService) OnContactRequest(oc *goricochet.OpenConnection, channelID int32, nick string, message string) { ts.StandardRicochetService.OnContactRequest(oc, channelID, nick, message) oc.AckContactRequestOnResponse(channelID, "Accepted") oc.CloseChannel(channelID) } -func (ebs *EchoBotService) OnChatMessage(oc *goricochet.OpenConnection, channelID int32, messageId int32, message string) { +// OnChatMessage we acknowledge the message, grab the message content and send it back - opening +// a new channel if necessary. +func (ebs *EchoBotService) OnChatMessage(oc *goricochet.OpenConnection, channelID int32, messageID int32, message string) { log.Printf("Received Message from %s: %s", oc.OtherHostname, message) - oc.AckChatMessage(channelID, messageId) + oc.AckChatMessage(channelID, messageID) if oc.GetChannelType(6) == "none" { oc.OpenChatChannel(6) }