本文整理匯總了Golang中github.com/nmeum/marvin/irc.Client.Connected方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.Connected方法的具體用法?Golang Client.Connected怎麽用?Golang Client.Connected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nmeum/marvin/irc.Client
的用法示例。
在下文中一共展示了Client.Connected方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: tweetCmd
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)
}
示例2: directMsgCmd
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
}
示例3: replyCmd
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)
}
示例4: favoriteCmd
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
}
示例5: statCmd
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)
}