public virtual void BlockUser(BlockUserOptions options, Action<TwitterUser, TwitterResponse> action)
		{
			var user_id = options.UserId;
			var screen_name = options.ScreenName;
			var include_entities = options.IncludeEntities;
			var skip_status = options.SkipStatus;
			
			WithHammock(WebMethod.Post, action, "blocks/create", FormatAsString, "?user_id=", user_id, "&screen_name=", screen_name, "&include_entities=", include_entities, "&skip_status=", skip_status);
		}
		public virtual Task<TwitterResponse<TwitterUser>> BlockUserAsync(BlockUserOptions options)
		{
			var user_id = options.UserId;
			var screen_name = options.ScreenName;
			var include_entities = options.IncludeEntities;
			var skip_status = options.SkipStatus;
				
			
			return ExecuteRequest<TwitterUser>(HttpMethod.Post, "blocks/create", FormatAsString, "?user_id=", user_id, "&screen_name=", screen_name, "&include_entities=", include_entities, "&skip_status=", skip_status);
		}
		public virtual IAsyncResult BeginBlockUser(BlockUserOptions options)
		{
			var user_id = options.UserId;
			var screen_name = options.ScreenName;
			var include_entities = options.IncludeEntities;
			var skip_status = options.SkipStatus;
				

			return BeginWithHammock<TwitterUser>(WebMethod.Post, "blocks/create", FormatAsString, "?user_id=", user_id, "&screen_name=", screen_name, "&include_entities=", include_entities, "&skip_status=", skip_status);
		}
Beispiel #4
0
        /// <summary>
        /// Blocks/unblocks a twitter user
        /// </summary>
        private void BlockUser(string command)
        {
            if (command.Split(' ')[1].Length != 2 && command.Split(' ')[1].StartsWith("@") == false)
            {
                ScreenDraw.ShowMessage("Wrong syntax. Use /block [id] or /block @[name]");
            }
            else
            {
                string screenName = "";
                if (command.Split(' ')[1].StartsWith("@"))
                {
                    screenName = command.Split(' ')[1].Remove(0, 1);
                }
                else
                {
                    try
                    {
                        long tweetID = Convert.ToInt64(TweetIdentification.GetTweetID(command.Split(' ')[1]).InReplyToStatusId);
                        InteractiveTweet tweet = TweetIdentification.FindTweet(tweetID);
                        screenName = tweet.AuthorScreenName;
                    }
                    catch (KeyNotFoundException exIn)
                    {
                        ScreenDraw.ShowMessage(exIn.Message);
                    }
                }

                if (GetUpdates.IsBlocked(screenName))
                {
                    UnblockUserOptions unblockOpts = new UnblockUserOptions();
                    unblockOpts.ScreenName = screenName;
                    User.Account.UnblockUser(unblockOpts);
                    if (User.Account.Response.Error == null)
                    {
                        ScreenDraw.ShowMessage("Successfully unblocked @" + screenName);
                    }
                    else
                    {
                        ScreenDraw.ShowMessage(User.Account.Response.Error.Code + ": " + User.Account.Response.Error.Message);
                    }
                }
                else
                {
                    BlockUserOptions blockOpts = new BlockUserOptions();
                    blockOpts.ScreenName = screenName;
                    User.Account.BlockUser(blockOpts);
                    if (User.Account.Response.Error == null)
                    {
                        ScreenDraw.ShowMessage("Successfully blocked @" + screenName);
                    }
                    else
                    {
                        ScreenDraw.ShowMessage(User.Account.Response.Error.Code + ": " + User.Account.Response.Error.Message);
                    }
                }
            }
        }