exported callbacks
This commit is contained in:
parent
c57e7a4b12
commit
b98f2cf7f1
30
irc.go
30
irc.go
@ -13,11 +13,11 @@ import (
|
|||||||
//Connection holds the callbacks for the client
|
//Connection holds the callbacks for the client
|
||||||
type Connection struct {
|
type Connection struct {
|
||||||
Sock net.Conn
|
Sock net.Conn
|
||||||
privmsgCallback func(string, string, string)
|
PrivmsgCallback func(string, string, string)
|
||||||
joinCallback func(string, string)
|
JoinCallback func(string, string)
|
||||||
quitCallback func(string, string)
|
QuitCallback func(string, string)
|
||||||
partCallback func(string, string, string)
|
PartCallback func(string, string, string)
|
||||||
numericCallback func(string, int, string)
|
NumericCallback func(string, int, string)
|
||||||
joined bool
|
joined bool
|
||||||
channels []string
|
channels []string
|
||||||
}
|
}
|
||||||
@ -113,9 +113,9 @@ func (c *Connection) parseMessage(line string) {
|
|||||||
c.joined = true
|
c.joined = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.numericCallback != nil {
|
if c.NumericCallback != nil {
|
||||||
code, _ := strconv.Atoi(cmd)
|
code, _ := strconv.Atoi(cmd)
|
||||||
c.numericCallback(from, code, args)
|
c.NumericCallback(from, code, args)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
t := strings.SplitN(args, ":", 2)
|
t := strings.SplitN(args, ":", 2)
|
||||||
@ -127,20 +127,20 @@ func (c *Connection) parseMessage(line string) {
|
|||||||
|
|
||||||
switch strings.ToLower(cmd) {
|
switch strings.ToLower(cmd) {
|
||||||
case "privmsg":
|
case "privmsg":
|
||||||
if c.privmsgCallback != nil {
|
if c.PrivmsgCallback != nil {
|
||||||
c.privmsgCallback(target, from, msg)
|
c.PrivmsgCallback(target, from, msg)
|
||||||
}
|
}
|
||||||
case "join":
|
case "join":
|
||||||
if c.joinCallback != nil {
|
if c.JoinCallback != nil {
|
||||||
c.joinCallback(from, target)
|
c.JoinCallback(from, target)
|
||||||
}
|
}
|
||||||
case "quit":
|
case "quit":
|
||||||
if c.quitCallback != nil {
|
if c.QuitCallback != nil {
|
||||||
c.quitCallback(from, msg)
|
c.QuitCallback(from, msg)
|
||||||
}
|
}
|
||||||
case "part":
|
case "part":
|
||||||
if c.partCallback != nil {
|
if c.PartCallback != nil {
|
||||||
c.partCallback(from, target, msg)
|
c.PartCallback(from, target, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user