go-ircevent/irc_struct.go

75 lines
1.6 KiB
Go
Raw Normal View History

2012-11-05 22:46:47 +00:00
// 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"
2012-11-05 22:46:47 +00:00
"log"
"net"
"sync"
"time"
2012-11-05 22:46:47 +00:00
)
type Connection struct {
sync.Mutex
sync.WaitGroup
2016-07-21 20:55:31 +00:00
Debug bool
Error chan error
Password string
UseTLS bool
UseSASL bool
SASLLogin string
SASLPassword string
SASLMech string
2017-08-18 15:56:08 +00:00
WebIRC string
2016-07-21 20:55:31 +00:00
TLSConfig *tls.Config
Version string
Timeout time.Duration
PingFreq time.Duration
KeepAlive time.Duration
Server string
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
events map[string]map[int]func(*Event)
2012-11-05 22:46:47 +00:00
QuitMessage string
lastMessage time.Time
2012-11-05 22:46:47 +00:00
VerboseCallbackHandler bool
Log *log.Logger
2012-11-05 22:46:47 +00:00
stopped bool
quit bool //User called Quit, do not reconnect.
2012-11-05 22:46:47 +00:00
}
2014-02-14 14:40:25 +00:00
// A struct to represent an event.
2012-11-05 22:46:47 +00:00
type Event struct {
Code string
Raw string
Nick string //<nick>
Host string //<nick>!<usr>@<host>
Source string //<host>
User string //<usr>
Arguments []string
Connection *Connection
2012-11-05 22:46:47 +00:00
}
// Retrieve the last message from Event arguments.
// This function leaves the arguments untouched and
2014-02-14 16:10:06 +00:00
// 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]
}