kunt

golang IRC bot
git clone git://git.2f30.org/kunt.git
Log | Files | Refs | LICENSE

commit 333c1c8ba96c788dee816981185f3dca0a85937c
parent 440f12923f6edd85f3a32907380b7a3b3f5b55fa
Author: sin <sin@2f30.org>
Date:   Thu May  2 18:02:04 +0100

add part command

Diffstat:
src/irc/irc.go | 13+++++++++++++
src/irc/message.go | 9+++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/irc/irc.go b/src/irc/irc.go @@ -112,6 +112,19 @@ func (i *IrcContext) JoinChannels() { } } +func (i *IrcContext) PartChannel(s string) int { + for c := 0; c < i.network.channum; c++ { + if i.network.channels[c].name == s { + if i.network.channels[c].joined { + i.Part(s) + i.network.channels[c].joined = false + return 0 + } + } + } + return -1 +} + // Connect to the server. Do not join any channels by default. func (i *IrcContext) Connect() error { service := i.network.serv + ":" + i.network.port diff --git a/src/irc/message.go b/src/irc/message.go @@ -43,6 +43,15 @@ func (i *IrcContext) Join(channel string) { i.outgoingMsg <- msg } +// Part a channel +func (i *IrcContext) Part(channel string) { + msg := IrcMessage{ + Command: "PART", + Args: []string{channel}, + } + i.outgoingMsg <- msg +} + // Send a PRIVMSG func (i *IrcContext) Privmsg(channel string, text string) { msg := IrcMessage{