本文整理匯總了Golang中github.com/nmeum/marvin/irc.Client.CmdHook方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.CmdHook方法的具體用法?Golang Client.CmdHook怎麽用?Golang Client.CmdHook使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nmeum/marvin/irc.Client
的用法示例。
在下文中一共展示了Client.CmdHook方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Load
func (m *Module) Load(client *irc.Client) error {
if len(m.URL) <= 0 {
return nil
}
duration, err := time.ParseDuration(m.Interval)
if err != nil {
return err
}
if err := m.updateHandler(client); err != nil {
return err
}
if m.api.API != apiVersion {
return errors.New("unsupported spaceapi version")
}
go func(c *irc.Client) {
for {
time.Sleep(duration)
m.updateHandler(c)
}
}(client)
client.CmdHook("privmsg", m.statusCmd)
return nil
}
示例2: Load
func (m *Module) Load(client *irc.Client) error {
regex, err := regexp.Compile(m.RegexStr)
if err != nil {
return err
}
m.regex = regex
client.CmdHook("privmsg", m.urlCmd)
return nil
}
示例3: Load
func (m *Module) Load(client *irc.Client) error {
if len(m.Password) <= 0 {
return nil
}
client.CmdHook("notice", func(c *irc.Client, msg irc.Message) error {
if msg.Sender.Name != m.NickServ || !strings.Contains(msg.Data, m.Keyword) {
return nil
}
return c.Write("PRIVMSG %s :identify %s",
m.NickServ, m.Password)
})
return nil
}
示例4: Load
func (m *Module) Load(client *irc.Client) error {
duration, err := time.ParseDuration(m.Timeout)
if err != nil {
return err
}
client.CmdHook("kick", func(c *irc.Client, msg irc.Message) error {
if msg.Data != client.Nickname {
return nil
}
time.Sleep(duration)
return c.Write("JOIN %s", strings.Fields(msg.Receiver)[0])
})
return nil
}
示例5: Load
func (m *Module) Load(client *irc.Client) error {
users := make(map[string]int)
client.CmdHook("privmsg", func(c *irc.Client, msg irc.Message) error {
splited := strings.Fields(msg.Data)
if len(splited) < 3 || splited[0] != "!remind" {
return nil
}
duration, err := time.ParseDuration(splited[1])
if err != nil {
return err
}
limit := time.Duration(m.TimeLimit) * time.Hour
if duration > limit {
return c.Write("NOTICE %s :%v hours exceeds the limit of %v hours",
msg.Receiver, duration.Hours(), limit.Hours())
}
if users[msg.Sender.Host] >= m.UserLimit {
return c.Write("NOTICE %s :You can only run %d reminders at a time",
msg.Receiver, m.UserLimit)
}
users[msg.Sender.Host]++
reminder := strings.Join(splited[2:], " ")
time.AfterFunc(duration, func() {
users[msg.Sender.Host]--
c.Write("PRIVMSG %s :Reminder: %s",
msg.Sender.Name, reminder)
})
return c.Write("NOTICE %s :Reminder setup for %s",
msg.Receiver, duration.String())
})
return nil
}
示例6: Load
func (m *Module) Load(client *irc.Client) error {
anaconda.SetConsumerKey(m.ConsumerKey)
anaconda.SetConsumerSecret(m.ConsumerSecret)
m.api = anaconda.NewTwitterApi(m.AccessToken, m.AccessTokenSecret)
client.CmdHook("privmsg", m.statCmd)
if !m.ReadOnly {
client.CmdHook("privmsg", m.tweetCmd)
client.CmdHook("privmsg", m.replyCmd)
client.CmdHook("privmsg", m.retweetCmd)
client.CmdHook("privmsg", m.favoriteCmd)
client.CmdHook("privmsg", m.directMsgCmd)
}
values := url.Values{}
values.Add("skip_status", "true")
user, err := m.api.GetSelf(values)
if err != nil {
return err
} else {
m.user = user
}
values = url.Values{}
values.Add("replies", "all")
values.Add("with", "user")
go func(c *irc.Client, v url.Values) {
for {
m.streamHandler(c, v)
}
}(client, values)
return nil
}
示例7: Load
func (m *Module) Load(client *irc.Client) error {
client.CmdHook("privmsg", m.timeCmd)
return nil
}