implement Client.Action() and Client.Actionf()

This commit is contained in:
Liam Stanley 2016-11-13 09:00:39 -05:00
parent b8c530fd21
commit 46ded10c5a
2 changed files with 12 additions and 2 deletions

@ -5,7 +5,7 @@ import "time"
func (c *Client) registerHelpers() {
c.callbacks = make(map[string][]Callback)
if !c.Config.DisableHelpers {
if c.Config.DisableHelpers {
return
}

12
main.go

@ -13,7 +13,7 @@ import (
)
// TODO's:
// * needs ACTION (Me? Action?), NOTICE (Notice?), SendRaw?
// * NOTICE (Notice?), SendRaw?
// * RunCallbacks(Event)
// * track connection time (conntime? in state)
// * with conntime, find lag. Client.Lag() would be useful
@ -309,3 +309,13 @@ func (c *Client) Message(target, message string) {
func (c *Client) Messagef(target, format string, a ...interface{}) {
c.Message(target, fmt.Sprintf(format, a...))
}
// Action sends a PRIVMSG ACTION (/me) to target (either channel, service, or user)
func (c *Client) Action(target, message string) {
c.Send(&Event{Command: PRIVMSG, Params: []string{target}, Trailing: fmt.Sprintf("\001ACTION %s\001", message)})
}
// Actionf sends a formated PRIVMSG ACTION (/me) to target (either channel, service, or user)
func (c *Client) Actionf(target, format string, a ...interface{}) {
c.Action(target, fmt.Sprintf(format, a...))
}