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


Golang TwitterApi.BlockUserId方法代碼示例

本文整理匯總了Golang中github.com/ChimeraCoder/anaconda.TwitterApi.BlockUserId方法的典型用法代碼示例。如果您正苦於以下問題:Golang TwitterApi.BlockUserId方法的具體用法?Golang TwitterApi.BlockUserId怎麽用?Golang TwitterApi.BlockUserId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ChimeraCoder/anaconda.TwitterApi的用法示例。


在下文中一共展示了TwitterApi.BlockUserId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: blockUser

// Block a user, and tweet a notification of why they were blocked
func blockUser(tweet anaconda.Tweet, ruleName string, cfg *Config, api *anaconda.TwitterApi) {
	// Block the user from the main account
	user, err1 := api.BlockUserId(tweet.User.Id, nil)
	if err1 != nil {
		log.Fatalf("Failed to block user: %s", err1)
	}

	// Let them know via the notification account
	anaconda.SetConsumerKey(cfg.Auth2.ConsumerKey)
	anaconda.SetConsumerSecret(cfg.Auth2.ConsumerSecret)
	api2 := anaconda.NewTwitterApi(cfg.Auth2.AccessToken, cfg.Auth2.AccessTokenSecret)

	// TODO: Make this work...
	params := url.Values{}
	params.Set("InReplyToStatusID", tweet.IdStr)
	params.Set("InReplyToStatusIdStr", tweet.IdStr)

	tweet2, err2 := api2.PostTweet("@"+user.ScreenName+
		": Hi! You've been blocked by @"+cfg.Settings.MyScreenName+
		". Reason: "+cfg.Settings.ReasonsURL+"#"+ruleName, params)
	if err2 != nil {
		log.Fatalf("Failed to notify blocked user: %s", err2)
	}

	// Display tweet in terminal
	fmt.Println(">> " + tweet2.Text)

	// Restore API to main account auth settings
	anaconda.SetConsumerKey(cfg.Auth.ConsumerKey)
	anaconda.SetConsumerSecret(cfg.Auth.ConsumerSecret)
}
開發者ID:denny,項目名稱:MentionsManager,代碼行數:32,代碼來源:manager.go

示例2: blockUser

func blockUser(user User, api *anaconda.TwitterApi) (twitterUser anaconda.User, err error) {

	// userIDが0かuserIDの長さが10でないと気はscreenNameでブロックする
	if user.id == 0 || len(user.screenName) != 10 {
		// screen_name の時
		if twitterUser, err = api.BlockUser(user.screenName, nil); err == nil {
			return twitterUser, nil
		}
	} else {

		// Id の時
		if _, err := api.BlockUserId(user.id, nil); err == nil {
			return twitterUser, nil
		}
	}

	return
}
開發者ID:upamune,項目名稱:block,代碼行數:18,代碼來源:commands.go


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