go-ircevent/irc_struct.go
Ant Zucaro f997fc841a Add a 'VerboseReadLoop' option.
Troubleshooting responses from the IRC server becomes easier when
you can actually see the raw responses. This change adds a
'VerboseReadLoop' member to the Connection struct. When set to
true, the raw messages sent from the server will be placed into
the standard log for review. This message is printed before
evaluating any callbacks.
2014-10-04 08:20:58 -04:00

67 lines
1.3 KiB
Go

// Copyright 2009 Thomas Jager <mail@jager.no> All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package irc
import (
"crypto/tls"
"log"
"net"
"sync"
"time"
)
type Connection struct {
sync.WaitGroup
Debug bool
Error chan error
Password string
UseTLS bool
TLSConfig *tls.Config
Version string
Timeout time.Duration
PingFreq time.Duration
KeepAlive time.Duration
socket net.Conn
pwrite chan string
end chan struct{}
nick string //The nickname we want.
nickcurrent string //The nickname we currently have.
user string
registered bool
server string
events map[string]map[string]func(*Event)
lastMessage time.Time
VerboseCallbackHandler bool
VerboseReadLoop bool
Log *log.Logger
stopped bool
}
// A struct to represent an event.
type Event struct {
Code string
Raw string
Nick string //<nick>
Host string //<nick>!<usr>@<host>
Source string //<host>
User string //<usr>
Arguments []string
}
// Retrieve the last message from Event arguments.
// This function leaves the arguments untouched and
// returns an empty string if there are none.
func (e *Event) Message() string {
if len(e.Arguments) == 0 {
return ""
}
return e.Arguments[len(e.Arguments)-1]
}