add Kick and MultiKick commands
This commit is contained in:
		
							parent
							
								
									b49099e075
								
							
						
					
					
						commit
						ad73608a87
					
				
							
								
								
									
										24
									
								
								irc.go
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								irc.go
									
									
									
									
									
								
							@ -20,6 +20,7 @@ package irc
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bufio"
 | 
						"bufio"
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
	"crypto/tls"
 | 
						"crypto/tls"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
@ -245,6 +246,29 @@ func (irc *Connection) Privmsgf(target, format string, a ...interface{}) {
 | 
				
			|||||||
	irc.Privmsg(target, fmt.Sprintf(format, a...))
 | 
						irc.Privmsg(target, fmt.Sprintf(format, a...))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Kick <user> from <channel> with <msg>. For no message, pass empty string ("")
 | 
				
			||||||
 | 
					func (irc *Connection) Kick(user, channel, msg string) {
 | 
				
			||||||
 | 
						var cmd bytes.Buffer
 | 
				
			||||||
 | 
						cmd.WriteString(fmt.Sprintf("KICK %s %s", channel, user))
 | 
				
			||||||
 | 
						if msg != "" {
 | 
				
			||||||
 | 
							cmd.WriteString(fmt.Sprintf(" :%s", msg))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						cmd.WriteString("\r\n")
 | 
				
			||||||
 | 
						irc.pwrite <- cmd.String()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Kick all <users> from <channel> with <msg>. For no message, pass
 | 
				
			||||||
 | 
					// empty string ("")
 | 
				
			||||||
 | 
					func (irc *Connection) MultiKick(users []string, channel string, msg string) {
 | 
				
			||||||
 | 
						var cmd bytes.Buffer
 | 
				
			||||||
 | 
						cmd.WriteString(fmt.Sprintf("KICK %s %s", channel, strings.Join(users, " ")))
 | 
				
			||||||
 | 
						if msg != "" {
 | 
				
			||||||
 | 
							cmd.WriteString(fmt.Sprintf(" :%s", msg))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						cmd.WriteString("\r\n")
 | 
				
			||||||
 | 
						irc.pwrite <- cmd.String()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Send raw string.
 | 
					// Send raw string.
 | 
				
			||||||
func (irc *Connection) SendRaw(message string) {
 | 
					func (irc *Connection) SendRaw(message string) {
 | 
				
			||||||
	irc.pwrite <- message + "\r\n"
 | 
						irc.pwrite <- message + "\r\n"
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user