Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var KarmaBest = &SyncTrigger{ Cond: func(g *Bot, msg *irc.Message) bool { return msg.Command == irc.PRIVMSG && len(msg.Params) == 2 && msg.Params[1] == "!karma best" }, Act: func(g *Bot, msg *irc.Message) bool { var karma []data.Karma g.db.Model(&data.Karma{}).Order("value desc").Limit(5).Where(&data.Karma{ Location: mirrorMsg(g, msg), }).Find(&karma) for _, k := range karma { g.msgChan <- &irc.Message{ Command: irc.PRIVMSG, Params: []string{mirrorMsg(g, msg), fmt.Sprintf("%d: %s", k.Value, k.Object)}, } } return false }, meta: &data.TriggerMeta{ Disabled: false, Priority: 0, Name: "karmaBest", }, }
View Source
var KarmaWorst = &SyncTrigger{ Cond: func(g *Bot, msg *irc.Message) bool { return msg.Command == irc.PRIVMSG && len(msg.Params) == 2 && msg.Params[1] == "!karma worst" }, Act: func(g *Bot, msg *irc.Message) bool { var karma []data.Karma g.db.Model(&data.Karma{}).Order("value asc").Limit(5).Where(&data.Karma{ Location: mirrorMsg(g, msg), }).Find(&karma) for _, k := range karma { g.msgChan <- &irc.Message{ Command: irc.PRIVMSG, Params: []string{mirrorMsg(g, msg), fmt.Sprintf("%d: %s", k.Value, k.Object)}, } } return false }, meta: &data.TriggerMeta{ Disabled: false, Priority: 0, Name: "karmaWorst", }, }
Functions ¶
This section is empty.
Types ¶
type ComposedTrigger ¶
type ComposedTrigger struct {
// contains filtered or unexported fields
}
func (*ComposedTrigger) Action ¶
func (t *ComposedTrigger) Action(b *Bot, msg *irc.Message) (shouldContinue bool)
func (*ComposedTrigger) Condition ¶
func (t *ComposedTrigger) Condition(b *Bot, msg *irc.Message) (shouldApply bool)
func (*ComposedTrigger) GetMeta ¶
func (t *ComposedTrigger) GetMeta() *data.TriggerMeta
func (*ComposedTrigger) Meta ¶
func (t *ComposedTrigger) Meta(m *data.TriggerMeta)
type SyncTrigger ¶
type SyncTrigger struct { // Returns true if this trigger applies to the passed in message Cond func(*Bot, *irc.Message) (shouldApply bool) // The action to perform if Cond is true // return true if processing should continue Act func(*Bot, *irc.Message) (shouldContinue bool) // contains filtered or unexported fields }
pattern stolen from https://github.com/whyrusleeping/hellabot/blob/master/hellabot.go
func (*SyncTrigger) Action ¶
func (t *SyncTrigger) Action(b *Bot, msg *irc.Message) (shouldContinue bool)
func (*SyncTrigger) Condition ¶
func (t *SyncTrigger) Condition(b *Bot, msg *irc.Message) (shouldApply bool)
func (*SyncTrigger) GetMeta ¶
func (t *SyncTrigger) GetMeta() *data.TriggerMeta
func (*SyncTrigger) Meta ¶
func (t *SyncTrigger) Meta(m *data.TriggerMeta)
Click to show internal directories.
Click to hide internal directories.