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 }
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 }
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 }
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 }
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 }
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 }
func (m *Module) Load(client *irc.Client) error { client.CmdHook("privmsg", m.timeCmd) return nil }