Add a few more commands that might end up being useful

This commit is contained in:
Alex Bramley 2009-12-19 22:15:11 +00:00
parent 17e5216144
commit cc35817517
1 changed files with 32 additions and 2 deletions

View File

@ -38,6 +38,15 @@ func (conn *Conn) Part(channel string, message ...) {
conn.out <- "PART "+channel+msg conn.out <- "PART "+channel+msg
} }
// Kick() sends a KICK command to remove a nick from a channel
func (conn *Conn) Kick(channel, nick string, message ...) {
msg := getStringMsg(message)
if msg != "" {
msg = " :" + msg
}
conn.out <- "KICK "+channel+" "+nick+msg
}
// Quit() sends a QUIT command to the server with an optional quit message // Quit() sends a QUIT command to the server with an optional quit message
func (conn *Conn) Quit(message ...) { func (conn *Conn) Quit(message ...) {
msg := getStringMsg(message) msg := getStringMsg(message)
@ -96,8 +105,8 @@ func (conn *Conn) Topic(channel string, topic ...) {
conn.out <- "TOPIC "+channel+t conn.out <- "TOPIC "+channel+t
} }
// send a MODE command to the server. This one can get complicated if we try // Mode() sends a MODE command to the server. This one can get complicated if
// to be too clever, so it's deliberately simple: // we try to be too clever, so it's deliberately simple:
// Mode(t) retrieves the user or channel modes for target t // Mode(t) retrieves the user or channel modes for target t
// Mode(t, "modestring") sets user or channel modes for target t, where... // Mode(t, "modestring") sets user or channel modes for target t, where...
// modestring == e.g. "+o <nick>" or "+ntk <key>" or "-is" // modestring == e.g. "+o <nick>" or "+ntk <key>" or "-is"
@ -111,6 +120,27 @@ func (conn *Conn) Mode(t string, modestring ...) {
conn.out <- "MODE "+t+mode conn.out <- "MODE "+t+mode
} }
// Away() sends an AWAY command to the server
// Away() resets away status
// Away(message) sets away with the given message
func (conn *Conn) Away(message ...) {
msg := getStringMsg(message)
if msg != "" {
msg = " :"+msg
}
conn.out <- "AWAY"+msg
}
// Invite() sends an INVITE command to the server
func (conn *Conn) Invite(nick, channel string) {
conn.out <- "INVITE "+nick+" "+channel
}
// Oper() sends an OPER command to the server
func (conn *Conn) Oper(user, pass string) {
conn.out <- "OPER "+user+" "+pass
}
func getStringMsg(a ...) (msg string) { func getStringMsg(a ...) (msg string) {
// dealing with functions with a variable parameter list is nasteeh :-( // dealing with functions with a variable parameter list is nasteeh :-(
// the below stolen and munged from fmt/print.go func getString() // the below stolen and munged from fmt/print.go func getString()