當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.Connected方法代碼示例

本文整理匯總了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)
}
開發者ID:feuerrot,項目名稱:marvin,代碼行數:9,代碼來源:twitter.go

示例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
}
開發者ID:feuerrot,項目名稱:marvin,代碼行數:16,代碼來源:twitter.go

示例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)
}
開發者ID:feuerrot,項目名稱:marvin,代碼行數:17,代碼來源:twitter.go

示例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
}
開發者ID:feuerrot,項目名稱:marvin,代碼行數:18,代碼來源:twitter.go

示例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)
}
開發者ID:feuerrot,項目名稱:marvin,代碼行數:19,代碼來源:twitter.go


注:本文中的github.com/nmeum/marvin/irc.Client.Connected方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。