Fixing up EchoBot for golint

This commit is contained in:
Sarah Jamie Lewis 2016-11-08 15:12:50 -08:00
parent 9d6592e1e4
commit 630efa186e
1 changed files with 10 additions and 5 deletions

View File

@ -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)
}