SendRaw
SendPong uses SendRaw before the rest will be implemented to use it Kill New function to terminate event loop
This commit is contained in:
parent
d459efef38
commit
0e434f1c2d
14
irc.go
14
irc.go
@ -43,11 +43,16 @@ func cleanInput(msg string) string {
|
||||
return ret
|
||||
}
|
||||
|
||||
//SendRaw sends a string as a raw irc message
|
||||
func (c *Connection) SendRaw(msg string) error {
|
||||
_, err := c.Sock.Write([]byte(msg))
|
||||
return err
|
||||
}
|
||||
|
||||
//SendPong replies to the received PING
|
||||
func (c *Connection) SendPong(ping string) {
|
||||
pong := strings.Replace(ping, "PING", "PONG", 1)
|
||||
c.Sock.Write([]byte(fmt.Sprintf("%s\n", pong)))
|
||||
log.Println("pong sent")
|
||||
c.SendRaw(pong + "\n")
|
||||
}
|
||||
|
||||
//SendPrivmsg sends a privmsg to channel/target
|
||||
@ -114,6 +119,11 @@ func (c *Connection) GetNicks(channel string) []string {
|
||||
return c.userList[channel]
|
||||
}
|
||||
|
||||
//Kill terminates the event loop of connection
|
||||
func (c *Connection) Kill() {
|
||||
c.Sock.Close()
|
||||
}
|
||||
|
||||
//NewConnection creates and connects an Connection
|
||||
func NewConnection(server, nick, user string, pass *string, chans []string) *Connection {
|
||||
irc := &Connection{channels: chans, userList: map[string][]string{}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user