Merge branch 'master' of github.com:thoj/go-ircevent into fuzz
This commit is contained in:
commit
6c849e1147
23
irc.go
23
irc.go
@ -268,6 +268,29 @@ func (irc *Connection) Privmsgf(target, format string, a ...interface{}) {
|
||||
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.
|
||||
func (irc *Connection) SendRaw(message string) {
|
||||
irc.pwrite <- message + "\r\n"
|
||||
|
@ -80,8 +80,11 @@ func (irc *Connection) RunCallbacks(event *Event) {
|
||||
if event.Code == "PRIVMSG" && len(msg) > 2 && msg[0] == '\x01' {
|
||||
event.Code = "CTCP" //Unknown CTCP
|
||||
|
||||
if i := strings.LastIndex(msg, "\x01"); i > -1 {
|
||||
if i := strings.LastIndex(msg, "\x01"); i > 0 {
|
||||
msg = msg[1:i]
|
||||
} else {
|
||||
irc.Log.Printf("Invalid CTCP Message: %s\n", strconv.Quote(msg))
|
||||
return
|
||||
}
|
||||
|
||||
if msg == "VERSION" {
|
||||
@ -216,3 +219,7 @@ func (irc *Connection) setupCallbacks() {
|
||||
irc.nickcurrent = e.Arguments[0]
|
||||
})
|
||||
}
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user