func (m *Module) tweetCmd(client *irc.Client, msg irc.Message) error { splited := strings.Fields(msg.Data) if len(splited) < 2 || splited[0] != "!tweet" || !client.Connected(msg.Receiver) { return nil } status := strings.Join(splited[1:], " ") return m.tweet(status, url.Values{}, client, msg) }
func (m *Module) directMsgCmd(client *irc.Client, msg irc.Message) error { splited := strings.Fields(msg.Data) if len(splited) < 3 || splited[0] != "!directmsg" || !client.Connected(msg.Receiver) { return nil } scname := splited[1] status := strings.Join(splited[2:], " ") if _, err := m.api.PostDMToScreenName(status, scname); err != nil { return client.Write("NOTICE %s :ERROR: %s", msg.Receiver, err.Error()) } return nil }
func (m *Module) replyCmd(client *irc.Client, msg irc.Message) error { splited := strings.Fields(msg.Data) if len(splited) < 3 || splited[0] != "!reply" || !client.Connected(msg.Receiver) { return nil } status := strings.Join(splited[2:], " ") if !strings.Contains(status, "@") { return client.Write("NOTICE %s :ERROR: %s", msg.Receiver, "A reply must contain an @mention") } values := url.Values{} values.Add("in_reply_to_status_id", splited[1]) return m.tweet(status, values, client, msg) }
func (m *Module) favoriteCmd(client *irc.Client, msg irc.Message) error { splited := strings.Fields(msg.Data) if len(splited) < 2 || splited[0] != "!favorite" || !client.Connected(msg.Receiver) { return nil } id, err := strconv.Atoi(splited[1]) if err != nil { return err } if _, err := m.api.Favorite(int64(id)); err != nil { return client.Write("NOTICE %s :ERROR: %s", msg.Receiver, err.Error()) } return nil }
func (m *Module) statCmd(client *irc.Client, msg irc.Message) error { splited := strings.Fields(msg.Data) if len(splited) < 2 || splited[0] != "!stat" || !client.Connected(msg.Receiver) { return nil } id, err := strconv.Atoi(splited[1]) if err != nil { return err } tweet, err := m.api.GetTweet(int64(id), url.Values{}) if err != nil { return err } return client.Write("NOTICE %s :Stats for tweet %d by %s: ↻ %d ★ %d", msg.Receiver, tweet.Id, tweet.User.ScreenName, tweet.RetweetCount, tweet.FavoriteCount) }