Ejemplo n.º 1
0
 /// <summary>
 /// Replies to the specified status.
 /// </summary>
 /// <param name="replyTo">A status that replies to.</param>
 /// <param name="status">A new status text.</param>
 public void Reply(TwitterStatus replyTo, string status)
 {
     var option = new StatusUpdateOptions()
     {
         InReplyToStatusId = replyTo.Id
     };
     Post(string.Format("@{0} {1}", replyTo.User.ScreenName, status), option);
 }
Ejemplo n.º 2
0
        public static void UpdateAndDelete()
        {
            OAuthTokens tokens = Configuration.GetTokens();

            StatusUpdateOptions options = new StatusUpdateOptions();

            TwitterStatus newStatus = TwitterStatus.Update(tokens, "Performing Twitterizer testing ...", options).ResponseObject;
            Assert.That(newStatus.Id > 0);

            TwitterStatus deletedStatus = newStatus.Delete(tokens).ResponseObject;
            Assert.That(newStatus.Id == deletedStatus.Id);
        }
Ejemplo n.º 3
0
        public void UpdateAndDelete()
        {
            OAuthTokens tokens = Configuration.GetTokens();

            StatusUpdateOptions options = new StatusUpdateOptions();

            var newStatus = TwitterStatus.Update(tokens, "Performing Twitterizer testing ...", options);
            Assert.IsNotNull(newStatus.ResponseObject, newStatus.ErrorMessage);
            Assert.IsTrue(newStatus.ResponseObject.Id > 0);

            var deletedStatus = newStatus.ResponseObject.Delete(tokens);
            Assert.IsNotNull(deletedStatus.ResponseObject, deletedStatus.ErrorMessage);
            Assert.IsTrue(newStatus.ResponseObject.Id == deletedStatus.ResponseObject.Id);
        }
Ejemplo n.º 4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (!(TextBox1.Text == "" || TextBox1.Text == null))
            {
                OAuthTokens token = new OAuthTokens();
                token.AccessToken = Session["tokenS"].ToString();
                token.AccessTokenSecret = Session["Atoken"].ToString();
                token.ConsumerKey = clid;
                token.ConsumerSecret = clsec;
                lat = double.Parse(HiddenField1.Value);
                lng = double.Parse(HiddenField2.Value);
                StatusUpdateOptions sou = new StatusUpdateOptions();
                sou.Latitude = lat;
                sou.Longitude = lng;
                TwitterPlaceLookupOptions tplo = new TwitterPlaceLookupOptions();
                tplo.MaxResults = 1;

                TwitterResponse<TwitterPlaceCollection> tc = TwitterPlace.Lookup(lat, lng, tplo);
                if (tc.Result == RequestResult.Success)
                {
                    foreach (var s in tc.ResponseObject)
                    {
                        sou.PlaceId = s.Id;
                    }
                }
                TwitterResponse<TwitterStatus> tweetstatus = TwitterStatus.Update(token, TextBox1.Text, sou);
                if (tweetstatus.Result == RequestResult.Success)
                {
                    Label6.Text = "Your message was posted successfully";

                }
                else
                {
                    Label6.Text = "Something went Wrong, Your Tweet wasn't Updated";
                }
            }
            else
            {
            }
        }
        catch
        {
            Label6.Text = "Tweet Update Failed, Please Try Again";
        }
    }
Ejemplo n.º 5
0
 public string tweet(string message)
 {
     TwitterResponse<TwitterStatus> tweetResponse = null;
     StatusUpdateOptions opt = new StatusUpdateOptions();
     opt.APIBaseAddress = "http://api.twitter.com/1.1/";
     try
     {
         tweetResponse = TwitterStatus.Update(tokens, message, opt);
     }
     catch {}
     if (tweetResponse == null)
     {
         return "";
     }
     else
     {
         return tweetResponse.Content;
     }
 }
Ejemplo n.º 6
0
        public void Tweet(string tweet)
        {
            string pattern = @"(?:(?<=\s)|^)#(\w*[A-Za-z_\-]+\w*)";

            Match match = Regex.Match(tweet, pattern);

            if (match.Success)
            {
                tweet = Program.EscapeStringValue(tweet);
                var options = new StatusUpdateOptions() { APIBaseAddress = "https://api.twitter.com/1.1/" };
                Console.WriteLine("Sending tweet: {0}", tweet);
                var response = TwitterStatus.Update(tokens, tweet, options);
                if (response.ErrorMessage != "Unable to parse JSON")
                {
                    Console.WriteLine(response.ErrorMessage);
                }
                else
                {
                    Console.WriteLine("Tweet sent");
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// UpdateWithMediaのラッパ
        /// </summary>
        /// <param name="text">本文</param>
        /// <param name="b">メディア</param>
        /// <param name="opt">オプション</param>
        /// <returns>投稿結果</returns>
        public TwitterResponse<TwitterStatus> StatusUpdateWithMedia(string text, byte[] b, StatusUpdateOptions opt = null)
        {
            DebugLog("Status update with media: " + text);
#if DEBUG
            System.Console.WriteLine("[DEBUG] Update status with media: " + text);
            return new TwitterResponse<TwitterStatus>() { Result = RequestResult.Success };
#else
            var ret = TwitterStatus.UpdateWithMedia(token, text, b, opt);
            if (!ret.Result.Equals(RequestResult.Success))
            {
                DebugLog(string.Format("Twitter update failed: [{0}] {1}", ret.Result, ret.ErrorMessage));
            }
            return ret;
#endif
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The text.</param>
 /// <param name="options">The options.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="function">The function.</param>
 /// <returns></returns>
 public static IAsyncResult Update(OAuthTokens tokens, string text, StatusUpdateOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterStatus>> function)
 {
     return AsyncUtility.ExecuteAsyncMethod(tokens, text, options, timeout, TwitterStatus.Update, function);
 }
Ejemplo n.º 9
0
        public static bool StatusUpdate(String tweet)
        {
            StatusUpdateOptions SUoption = new StatusUpdateOptions();
            SUoption.Proxy = proxy;

            TwitterResponse<TwitterStatus> userResponse = TwitterStatus.Update(tokens, tweet, SUoption);
            if (userResponse.Result == RequestResult.Success)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 10
0
            public void unfavorite(decimal Id)
            {
                StatusUpdateOptions options = new StatusUpdateOptions();

                Twitterizer.TwitterResponse<TwitterStatus> response = Twitterizer.TwitterFavorite.Delete(privOAuth.GetOAuthToken(), Id);
                if (!(response.Result == RequestResult.Success))
                {
                    //throw new Exception("unfav failed: " + response.ErrorMessage);
                    System.Windows.Forms.MessageBox.Show("error: " + response.ErrorMessage, "error, unfav failed", System.Windows.Forms.MessageBoxButtons.OK);
                }
            }
Ejemplo n.º 11
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="fileData">The file to upload, as a byte array.</param>
 /// <param name="options">The options. Leave null for defaults.</param>
 /// <returns>
 /// A <see cref="Status"/> object of the newly created status.
 /// </returns>
 public static async Task <TwitterResponse <Status> > UpdateWithMediaAsync(string text, byte[] fileData, OAuthTokens tokens, StatusUpdateOptions options = null)
 {
     return(await Core.CommandPerformer.PerformAction(new Commands.UpdateWithMediaCommand(tokens, text, fileData, options)));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The text.</param>
 /// <param name="options">The options.</param>
 /// <param name="timeout">The timeout.</param>
 /// <param name="function">The function.</param>
 /// <returns></returns>
 public static IAsyncResult Update(OAuthTokens tokens, string text, StatusUpdateOptions options, TimeSpan timeout, Action <TwitterAsyncResponse <TwitterStatus> > function)
 {
     return(AsyncUtility.ExecuteAsyncMethod(tokens, text, options, timeout, TwitterStatus.Update, function));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="fileLocation">The file location.</param>
 /// <param name="options">The options.</param>
 /// <returns>
 /// A <see cref="TwitterStatus"/> object of the newly created status.
 /// </returns>
 public static TwitterResponse<TwitterStatus> UpdateWithMedia(OAuthTokens tokens, string text, string fileLocation, StatusUpdateOptions options = null)
 {
     return UpdateWithMedia(tokens, text, System.IO.File.ReadAllBytes(fileLocation), options);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="options">The options. Leave null for defaults.</param>
 /// <returns>
 /// A <see cref="Status"/> object of the newly created status.
 /// </returns>
 public static async Task <TwitterResponse <Status> > UpdateAsync(string text, OAuthTokens tokens, StatusUpdateOptions options = null)
 {
     return(await Core.CommandPerformer.PerformAction(new Commands.UpdateStatusCommand(tokens, text, options)));
 }
Ejemplo n.º 15
0
		/// <summary>
		/// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
		/// </summary>
		/// <param name="tokens">The tokens.</param>
		/// <param name="text">The status text.</param>
		/// <param name="fileData">The file to upload, as a byte array.</param>
		/// <param name="options">The options.</param>
		/// <returns>
		/// A <see cref="TwitterStatus"/> object of the newly created status.
		/// </returns>
		public static TwitterResponse<TwitterStatus> UpdateWithMedia(OAuthTokens tokens, string text, byte[] fileData, StatusUpdateOptions options = null)
		{
            return CommandPerformer.PerformAction(new Commands.UpdateWithMediaCommand(tokens, text, fileData, options));
		}
Ejemplo n.º 16
0
        /// <summary>
        /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="text">The text.</param>
        /// <param name="options">The options.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The function.</param>
        /// <returns></returns>
        public static IAsyncResult Update(OAuthTokens tokens, string text, StatusUpdateOptions options, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterStatus>> function)
        {
            Func<OAuthTokens, string, StatusUpdateOptions, TwitterResponse<TwitterStatus>> methodToCall = TwitterStatus.Update;

            return methodToCall.BeginInvoke(
                tokens,
                text,
                options,
                result =>
                {
                    result.AsyncWaitHandle.WaitOne(timeout);
                    try
                    {
                        function(methodToCall.EndInvoke(result).ToAsyncResponse());
                    }
                    catch (Exception ex)
                    {
                        function(new TwitterAsyncResponse<TwitterStatus>() { Result = RequestResult.Unknown, ExceptionThrown = ex });
                    }
                },
                null);
        }
Ejemplo n.º 17
0
 private void PostUpdate(string text)
 {
     var options = new StatusUpdateOptions() {
         Proxy = f_WebProxy
     };
     var res = TwitterStatus.Update(f_OAuthTokens, text, options);
     CheckRequestStatus(res);
     f_FriendsTimelineEvent.Set();
 }
        private string tweetToTwitter(string shortUrl, string stream_url)
        {
            OAuthTokens accesstoken = new OAuthTokens()
            {
                AccessToken = Convert.ToString(Session["AccessToken"]),

                AccessTokenSecret = Convert.ToString(Session["AccessTokenSecret"]),

                ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"],

                ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"],
            };

            String messageToPost = string.Empty;

            if (!string.IsNullOrEmpty(TwitterMsg.Text.Trim()))
                messageToPost += TwitterMsg.Text.Trim() + System.Environment.NewLine;

            messageToPost += BitlyApi.GetShortUrl(stream_url) + System.Environment.NewLine;

            messageToPost += "Trackname:" + TrackNameText.Text.Trim() + System.Environment.NewLine;

            messageToPost += "Trackprotect ID:" + shortUrl;

            try
            {
                StatusUpdateOptions so = new StatusUpdateOptions();

                so.APIBaseAddress = "http://api.twitter.com/1.1/";

                TwitterResponse<TwitterStatus> status = TwitterStatus.Update(accesstoken, messageToPost, so);

                if (status.Result == RequestResult.Success)
                    return status.ToString();
                else
                    return "Error";
            }
            catch
            {
                return "Error";
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="options">The options.</param>
 /// <returns>
 /// A <see cref="TwitterStatus"/> object of the newly created status.
 /// </returns>
 public static TwitterResponse<TwitterStatus> Update(OAuthTokens tokens, string text, StatusUpdateOptions options)
 {
     return CommandPerformer<TwitterStatus>.PerformAction(new Commands.UpdateStatusCommand(tokens, text, options));
 }
Ejemplo n.º 20
0
 public void Reply(decimal Id, string tweet)
 {
     StatusUpdateOptions options = new StatusUpdateOptions();
     options.InReplyToStatusId = Id;
     Twitterizer.TwitterResponse<TwitterStatus> response = Twitterizer.TwitterStatus.Update(privOAuth.GetOAuthToken(), tweet,options);
     if (!(response.Result == RequestResult.Success))
     {
         //throw new Exception("reply failed: " + response.ErrorMessage);
         System.Windows.Forms.MessageBox.Show("error: " + response.ErrorMessage, "error", System.Windows.Forms.MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="fileData">The file to upload, as a byte array.</param>
 /// <param name="options">The options.</param>
 /// <returns>
 /// A <see cref="TwitterStatus"/> object of the newly created status.
 /// </returns>
 public static TwitterResponse <TwitterStatus> UpdateWithMedia(OAuthTokens tokens, string text, byte[] fileData, StatusUpdateOptions options = null)
 {
     return(CommandPerformer.PerformAction(new Commands.UpdateWithMediaCommand(tokens, text, fileData, options)));
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Posts the new status with the specified options.
 /// </summary>
 /// <param name="status">A new status text.</param>
 /// <param name="option">An option for updating status.</param>
 void Post(string status, StatusUpdateOptions option)
 {
     if (option == null)
         TwitterStatus.Update(token, status);
     else
         TwitterStatus.Update(token, status, option);
 }
Ejemplo n.º 23
0
        /// <see cref="LabMonitoring.ITweetHandler"/>
        public void HandleStatus(TwitterStatus target, logOutput log)
        {
            if (!target.Text.StartsWith("@frahabot")) return;
            if (!target.Text.Contains("カメラ")) return;

            Log("Recieve command tweet: @" + target.User.ScreenName + ": " + target.Text);

            StatusUpdateOptions opt = new StatusUpdateOptions();
            opt.InReplyToStatusId = target.Id;
            opt.UseSSL = true;
            /*opt.Latitude = 34.731557;
            opt.Longitude = 135.734187;
            opt.PlacePin = true;*/

            var res = Twitter.GetInstance().StatusUpdateWithMedia("@" + target.User.ScreenName + " 今はこんな状況です", this.Capture(), opt);
            if (res.Result.Equals(RequestResult.Success))
            {
                Log("tweet complete");
            }
            else
            {
                Log(res.Result.ToString());
                Log(res.ErrorMessage);
                Log(res.Content);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Updates the twitter status, and includes media (typically an image) in that update.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="text">The text.</param>
        /// <param name="fileLocation">The file location.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The function.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public static IAsyncResult UpdateWithMedia(OAuthTokens tokens, string text, string fileLocation, TimeSpan timeout, Action <TwitterAsyncResponse <TwitterStatus> > function, StatusUpdateOptions options = null)
        {
            Func <OAuthTokens, string, string, StatusUpdateOptions, TwitterResponse <TwitterStatus> > methodToCall = TwitterStatus.UpdateWithMedia;

            return(methodToCall.BeginInvoke(
                       tokens,
                       text,
                       fileLocation,
                       options,
                       result => AsyncUtility.ThreeParamsCallback(result, timeout, methodToCall, function),
                       null));
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="options">The options. Leave null for defaults.</param>
 /// <returns>
 /// A <see cref="TwitterStatus"/> object of the newly created status.
 /// </returns>
 public static async Task<TwitterResponse<TwitterStatus>> UpdateAsync(string text, OAuthTokens tokens, StatusUpdateOptions options = null)
 {
     return await Core.CommandPerformer.PerformAction(new Commands.UpdateStatusCommand(tokens, text, options));
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="options">The options.</param>
 /// <returns>
 /// A <see cref="TwitterStatus"/> object of the newly created status.
 /// </returns>
 public static TwitterResponse <TwitterStatus> Update(OAuthTokens tokens, string text, StatusUpdateOptions options)
 {
     return(CommandPerformer.PerformAction(new Commands.UpdateStatusCommand(tokens, text, options)));
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="fileData">The file to upload, as a byte array.</param>
 /// <param name="options">The options. Leave null for defaults.</param>
 /// <returns>
 /// A <see cref="TwitterStatus"/> object of the newly created status.
 /// </returns>
 public static async Task<TwitterResponse<TwitterStatus>> UpdateWithMediaAsync(string text, byte[] fileData, OAuthTokens tokens, StatusUpdateOptions options = null)
 {
     return await Core.CommandPerformer.PerformAction(new Commands.UpdateWithMediaCommand(tokens, text, fileData, options));
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
 /// </summary>
 /// <param name="tokens">The tokens.</param>
 /// <param name="text">The status text.</param>
 /// <param name="fileLocation">The file location.</param>
 /// <param name="options">The options.</param>
 /// <returns>
 /// A <see cref="TwitterStatus"/> object of the newly created status.
 /// </returns>
 public static TwitterResponse <TwitterStatus> UpdateWithMedia(OAuthTokens tokens, string text, string fileLocation, StatusUpdateOptions options = null)
 {
     return(UpdateWithMedia(tokens, text, System.IO.File.ReadAllBytes(fileLocation), options));
 }
Ejemplo n.º 29
0
 private void PostUpdate(string text)
 {
     var options = new StatusUpdateOptions() {
         Proxy = f_WebProxy
     };
     var res = TwitterStatus.Update(f_OAuthTokens, text, options);
     if (res.RequestStatus.Status != RequestResult.Success) {
         throw new ApplicationException(
             res.RequestStatus.ErrorDetails.ErrorMessage
         );
     }
     f_FriendsTimelineEvent.Set();
 }
Ejemplo n.º 30
0
 internal TwitterStatus ReplyToTweet(decimal replyTweetId, string message)
 {
     Console.WriteLine("Replying to Tweet {0} with message {1}", replyTweetId, message);
     StatusUpdateOptions opts = new StatusUpdateOptions();
     opts.InReplyToStatusId = replyTweetId;
     TwitterResponse<TwitterStatus> response = TwitterStatus.Update(tokens, message, opts);
     return HandleTwitterResponse(response);
 }
Ejemplo n.º 31
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            buttonUpdate.Enabled = false;
              textTweet.Enabled = false;
              checkMedia.Enabled = false;

              string strTweet = textTweet.Text.Replace("\r", "");

              if (strTweet[0] == 'D') {
            string[] astrDMParts = strTweet.Split(new char[] { ' ' }, 3);
            if (astrDMParts.Length == 3 && astrDMParts[0] == "D") {
              TwitterDirectMessageAsync.Send(Global.requestToken, astrDMParts[1], astrDMParts[2], null, TimeSpan.FromSeconds(30), (TwitterAsyncResponse<TwitterDirectMessage> ee) => {
            if (ee.ResponseObject == null) {
              TweetFailure(ee.Content);
              return;
            }

            // NOTE: This is not required, as it comes in with streaming. I don't know why. Seriously, what?
            //InsertDMIn(ee.ResponseObject, ColumnType.DirectMessages);

            this.Invoke(new Action(delegate
            {
              textTweet.Enabled = true;
              textTweet.Text = "";
              textTweet.Focus();

              buttonUpdate.Enabled = true;
            }));
              });
              return;
            }
              }

              StatusUpdateOptions sup = new StatusUpdateOptions();
              sup.InReplyToStatusId = tw_idInReplyTo;

              if (tw_strMediaFilename != "") {
            TwitterStatusAsync.UpdateWithMedia(Global.requestToken, strTweet, tw_strMediaFilename, TimeSpan.FromSeconds(30), UpdateResponse, sup);
              } else {
            TwitterStatusAsync.Update(Global.requestToken, strTweet, sup, TimeSpan.FromSeconds(30), UpdateResponse);
              }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Updates the twitter status, and includes media (typically an image) in that update.
        /// </summary>
        /// <param name="tokens">The tokens.</param>
        /// <param name="text">The text.</param>
        /// <param name="fileLocation">The file location.</param>
        /// <param name="timeout">The timeout.</param>
        /// <param name="function">The function.</param>
        /// <param name="options">The options.</param>
        /// <returns></returns>
        public static IAsyncResult UpdateWithMedia(OAuthTokens tokens, string text, string fileLocation, TimeSpan timeout, Action<TwitterAsyncResponse<TwitterStatus>> function, StatusUpdateOptions options = null)
        {
            Func<OAuthTokens, string, string, StatusUpdateOptions, TwitterResponse<TwitterStatus>> methodToCall = TwitterStatus.UpdateWithMedia;

            return methodToCall.BeginInvoke(
                tokens,
                text,
                fileLocation,
                options,
                result => AsyncUtility.ThreeParamsCallback(result, timeout, methodToCall, function),
                null);
        }
Ejemplo n.º 33
0
        private void ProcessNewStatus(TwitterStatus status)
        {
            // First, make sure this isn't a status we published, or one which isn't directed at us:
            if (status.User.ScreenName == TwitterUsername || status.InReplyToScreenName != TwitterUsername)
            {
                return;
            }

            StatusUpdateOptions options = new StatusUpdateOptions();
            options.InReplyToStatusId = status.Id;
            options.Latitude = 47.6231005;
            options.Longitude = -122.1645082;

            string response = "@" + status.User.ScreenName + " ";

            // Next, see if they're authorized:
            if (Followers != null && !Followers.ResponseObject.Contains(status.User.Id))
            {
                response += UnauthorizedResponses.OrderBy(x => Fish.Next()).ElementAt(0);
                return;
            }else{
                // Next, figure out what sort of command we're looking at:
                var searchString = status.Text.ToUpper();
                if (OpenCommands.Any(s => searchString.Contains(s)))
                {
                    // Everything looks good!

                    // Send the OK to unlock the door:
                    if (OnUnlock != null)
                    {
                        OnUnlock(ServiceName, status.User.ScreenName);
                    }

                    // Update the status:
                    response += OpenResponses.OrderBy(x => Fish.Next()).ElementAt(0);
                }
                else
                {
                    // We don't know that command:
                    response += UnknownCommandResponses.OrderBy(x => Fish.Next()).ElementAt(0);
                }
            }

            response += " Also, here's a random integer: " + Fish.Next(int.MinValue, int.MaxValue);

            var resp = TwitterStatus.Update(Tokens, response, options);
            if (resp.Result != RequestResult.Success)
            {
                MainForm.Instance.logControl.Add("Error posting tweet: " + resp.ErrorMessage, LogEntryType.Error);
            }
        }