private void pipe_DataIn(object sender, DuplexPipe.PipeReadEventArgs e) { owner.InvokeSafe(() => { switch (e.Key) { case "vol": if (int.TryParse(e.Data, out int volume) && volume != Config.VideoPlayerVolume) { Config.VideoPlayerVolume = volume; Config.Save(); } break; case "download": if (currentInstance != null) { owner.AnalyticsFile.DownloadedVideos.Trigger(); TwitterUtils.DownloadVideo(currentInstance.Url, currentInstance.Username); } break; case "rip": currentInstance?.Dispose(); currentInstance = null; isClosing = false; TriggerProcessExitEventUnsafe(); break; } }); }
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { if (!TwitterUtils.IsTweetDeckWebsite(frame) || browser.IsLoading) { lastHighlightedTweetAuthors = StringUtils.EmptyArray; lastHighlightedTweetImageList = StringUtils.EmptyArray; ContextInfo = default(KeyValuePair <string, string>); } else { lastHighlightedTweetAuthors = TweetDeckBridge.LastHighlightedTweetAuthorsArray; lastHighlightedTweetImageList = TweetDeckBridge.LastHighlightedTweetImagesArray; } bool hasTweetImage = IsImage; bool hasTweetVideo = IsVideo; string TextOpen(string name) => "Open " + name + " in browser"; string TextCopy(string name) => "Copy " + name + " address"; string TextSave(string name) => "Save " + name + " as..."; if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal) && !hasTweetImage && !hasTweetVideo) { if (TwitterUtils.RegexAccount.IsMatch(parameters.UnfilteredLinkUrl)) { model.AddItem(MenuOpenLinkUrl, TextOpen("account")); model.AddItem(MenuCopyLinkUrl, TextCopy("account")); model.AddItem(MenuCopyUsername, "Copy account username"); } else { model.AddItem(MenuOpenLinkUrl, TextOpen("link")); model.AddItem(MenuCopyLinkUrl, TextCopy("link")); } model.AddSeparator(); } if (hasTweetVideo) { model.AddItem(MenuOpenMediaUrl, TextOpen("video")); model.AddItem(MenuCopyMediaUrl, TextCopy("video")); model.AddItem(MenuSaveMedia, TextSave("video")); model.AddSeparator(); } else if ((parameters.TypeFlags.HasFlag(ContextMenuType.Media) && parameters.HasImageContents) || hasTweetImage) { model.AddItem(MenuViewImage, "View image in photo viewer"); model.AddItem(MenuOpenMediaUrl, TextOpen("image")); model.AddItem(MenuCopyMediaUrl, TextCopy("image")); model.AddItem(MenuSaveMedia, TextSave("image")); if (lastHighlightedTweetImageList.Length > 1) { model.AddItem(MenuSaveTweetImages, TextSave("all images")); } model.AddSeparator(); } }
public static TwitterReverseGeocodeResponse Parse(JsonObject obj) { if (obj == null) { return(null); } JsonObject query = obj.GetObject("query"); JsonObject result = obj.GetObject("result"); if (query == null) { throw new JsonParseException("Object \"query\" not found."); } if (result == null) { throw new JsonParseException("Object \"result\" not found."); } JsonObject parameters = query.GetObject("params"); if (parameters == null) { throw new JsonParseException("Object \"params\" not found."); } return(new TwitterReverseGeocodeResponse { JsonObject = obj, Granularity = TwitterUtils.ParseGranularity(parameters.GetString("granularity")), Coordinates = parameters.GetObject("coordinates", TwitterCoordinates.Parse), Url = query.GetString("url"), Type = query.GetString("type"), Places = result.GetArray("places", TwitterPlace.Parse) }); }
private void currentPipe_DataIn(object sender, DuplexPipe.PipeReadEventArgs e) { owner.InvokeSafe(() => { switch (e.Key) { case "vol": if (int.TryParse(e.Data, out int volume) && volume != Program.UserConfig.VideoPlayerVolume) { Program.UserConfig.VideoPlayerVolume = volume; Program.UserConfig.Save(); } break; case "download": TwitterUtils.DownloadVideo(lastUrl, lastUsername); break; case "rip": currentPipe.Dispose(); currentPipe = null; currentProcess.Dispose(); currentProcess = null; isClosing = false; TriggerProcessExitEventUnsafe(); break; } }); }
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) { if (e.Frame.IsMain && TwitterUtils.IsTweetDeckWebsite(e.Frame)) { ScriptLoader.ExecuteFile(e.Frame, "update.js"); Check(false); } }
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) { IFrame frame = e.Frame; if (frame.IsMain && TwitterUtils.IsTweetDeckWebsite(frame)) { Ready?.Invoke(this, new PluginDispatchEventArgs(executor)); } }
public static string Update(TraceWriter log) { string result = "Daily update complete, nothing unusual to report.."; try { List <Company> companies = Utils.DataRepository.GetCompaniesFromDb(log); foreach (Company company in companies) { if (!String.IsNullOrEmpty(company.Symbol)) { DailyUpdate update = new DailyUpdate() { Name = company.Name, Symbol = company.Symbol, Date = DateTime.Now }; //update.Id = company.Name + "_" + update.Date.ToString("yyyyMMdd"); //update.Id = update.Id.Replace(" ", "_"); TweetSummary tweets = TwitterUtils.GetTweetSummary(company.Name, log); update.TweetCount = tweets.TweetCount; update.TweetLikes = tweets.TweetLikes; update.TweetRetweets = tweets.TweetRetweets; update.StockPrice = ServiceProxies.GetStockPrice(company.Symbol, "", log); GitHub ghub = ServiceProxies.GetGitHubStars(company.Name); if (ghub != null) { update.GitHubStars = ghub.Stars; update.GitHubWatchers = ghub.Watches; } List <News> news = ServiceProxies.SearchNews(company.Name, log); update.NewsStories = news.Count; DataRepository.AddDailyUpdate(update); // Sleep to not overload free APIs System.Threading.Thread.Sleep(12000); } } } catch (Exception ex) { log.Error(ex.Message, ex); result = "DailyUpdater Error: " + ex.ToString(); } return(result); }
//----------------------------------------------------------------------------------------------------------------- // After return from web-site back to game send Facebook/Twitter request to check if player likes/follows that site. // Note: Maybe better 'OnApplicationFocus' isn't called on iOS so we were forced to use 'OnApplicationPause' // which is called on both platforms. //----------------------------------------------------------------------------------------------------------------- void OnApplicationPause(bool pause) { // Debug.Log( "CAPA : GuiScreenBank : OnApplicationPause( " + Pause + " )" ); // not unpaused if (pause) { return; } // not visiting yet unrewarded site if ((m_VisitingSite == null) || (m_VisitingSite.m_Rewarded == true)) { return; } // // waiting for result of attempt to login Twitter/Facebook... // if ( m_WaitForLogin > 0.0f ) // { // // at this point we returned to app from login-dialog but still waiting for the result --> // m_WaitForLogin = Mathf.Min( 15.0f, m_WaitForLogin ); // --> "reduce" waiting time to "reasonable" value // // // Debug.Log( "CAPA : GuiScreenBank : OnApplicationPause : Still Waiting( " + m_WaitForLogin + " )" ); // } // else // done so check if user is liking/following corresponding site... if (m_LoggedIn) { m_LoggedIn = false; string msg = TextDatabase.instance[TextID_CheckingStatus]; Notification.Show(string.Empty, msg, false); if (m_VisitingSite.m_FBSite) { // Debug.Log( "CAPA : GuiScreenBank : OnApplicationPause : Checking 'like' status..." ); FacebookPlugin.Instance.GetUserLike(m_VisitingSite.m_ID, this.OnUserLikeResult); } else { // Debug.Log( "CAPA : GuiScreenBank : OnApplicationPause : Checking 'follow' status..." ); TwitterUtils.DoesUserFollow(m_VisitingSite.m_ID, this.OnStatusCheckResult); } } }
public void TestImageQualityLink() { Assert.AreEqual("https://pbs.twimg.com/profile_images/123", TwitterUtils.GetMediaLink("https://pbs.twimg.com/profile_images/123", TwitterUtils.ImageQuality.Default)); Assert.AreEqual("https://pbs.twimg.com/profile_images/123", TwitterUtils.GetMediaLink("https://pbs.twimg.com/profile_images/123", TwitterUtils.ImageQuality.Orig)); Assert.AreEqual("https://pbs.twimg.com/profile_images/123.jpg", TwitterUtils.GetMediaLink("https://pbs.twimg.com/profile_images/123.jpg", TwitterUtils.ImageQuality.Default)); Assert.AreEqual("https://pbs.twimg.com/profile_images/123.jpg", TwitterUtils.GetMediaLink("https://pbs.twimg.com/profile_images/123.jpg", TwitterUtils.ImageQuality.Orig)); Assert.AreEqual("https://pbs.twimg.com/media/123.jpg", TwitterUtils.GetMediaLink("https://pbs.twimg.com/media/123.jpg", TwitterUtils.ImageQuality.Default)); Assert.AreEqual("https://pbs.twimg.com/media/123.jpg:orig", TwitterUtils.GetMediaLink("https://pbs.twimg.com/media/123.jpg", TwitterUtils.ImageQuality.Orig)); Assert.AreEqual("https://pbs.twimg.com/media/123.jpg:small", TwitterUtils.GetMediaLink("https://pbs.twimg.com/media/123.jpg:small", TwitterUtils.ImageQuality.Default)); Assert.AreEqual("https://pbs.twimg.com/media/123.jpg:orig", TwitterUtils.GetMediaLink("https://pbs.twimg.com/media/123.jpg:small", TwitterUtils.ImageQuality.Orig)); Assert.AreEqual("https://pbs.twimg.com/media/123.jpg:large", TwitterUtils.GetMediaLink("https://pbs.twimg.com/media/123.jpg:large", TwitterUtils.ImageQuality.Default)); Assert.AreEqual("https://pbs.twimg.com/media/123.jpg:orig", TwitterUtils.GetMediaLink("https://pbs.twimg.com/media/123.jpg:large", TwitterUtils.ImageQuality.Orig)); }
// PUBLIC METHODS public void SetData(int rank, int points) { //bool isMajorRank = PlayerPersistantInfo.IsMajorRank(rank); GUIBase_MultiSprite sprite = GuiBaseUtils.GetControl <GUIBase_MultiSprite>(Layout, PLAYERRANKPIC); sprite.State = string.Format("Rank_{0}", Mathf.Min(rank, sprite.Count - 1).ToString("D2")); GUIBase_Label label = GuiBaseUtils.GetControl <GUIBase_Label>(Layout, POINTS_LABEL); var animation = MFGuiManager.AnimateWidget(label, 0, points); if (animation != null) { animation.Duration = m_CountDownDuration; animation.AudioClip = m_CountDownSound; } #if (!UNITY_EDITOR) && (UNITY_ANDROID || UNITY_IPHONE) // set visibility of info text Layout.GetWidget(WOULDPOSTIT_NOTIFY).Show(true, true); string postMessage = string.Format(TextDatabase.instance[01150011], CloudUser.instance.nickName, rank); // register delegate for facebook button m_FacebookButton.Widget.Show(true, true); m_FacebookButton.RegisterTouchDelegate(() => { m_FacebookButton.SetDisabled(true); StartCoroutine(sendMessage(rank.ToString())); }); m_TwitterButton.Widget.Show(true, true); m_TwitterButton.RegisterTouchDelegate(() => { m_TwitterButton.SetDisabled(true); TwitterUtils.PostMessage(postMessage, (success) => { if (m_TwitterButton.Widget.Visible == true) { m_TwitterButton.SetDisabled(!success); } }); }); #else m_FacebookButton.Widget.Show(false, true); m_TwitterButton.Widget.Show(false, true); #endif }
public void Register(IWebBrowser browser, PluginEnvironment environment, Control sync, bool asMainBrowser = false) { browser.FrameLoadEnd += (sender, args) => { IFrame frame = args.Frame; if (frame.IsMain && TwitterUtils.IsTweetDeckWebsite(frame)) { ExecutePlugins(frame, environment, sync); } }; browser.RegisterAsyncJsObject("$TDP", bridge); if (asMainBrowser) { mainBrowser = browser; } }
protected TwitterUser(JObject obj) : base(obj) { Id = obj.GetInt64("id"); IdStr = obj.GetString("id_str"); Name = obj.GetString("name"); ScreenName = obj.GetString("screen_name"); Location = obj.GetString("location"); Url = obj.GetString("url"); Description = obj.GetString("description"); IsProtected = obj.GetBoolean("protected"); FollowersCount = obj.GetInt32("followers_count"); FriendsCount = obj.GetInt32("friends_count"); ListedCount = obj.GetInt32("listed_count"); CreatedAt = TwitterUtils.ParseDateTime(obj.GetString("created_at")); FavouritesCount = obj.GetInt32("favourites_count"); UtcOffset = obj.HasValue("utc_offset") ? obj.GetInt32("utc_offset") : (int?)null; TimeZone = obj.GetString("time_zone"); IsGeoEnabled = obj.GetBoolean("geo_enabled"); IsVerified = obj.GetBoolean("verified"); StatusesCount = obj.GetInt32("statuses_count"); Language = obj.GetString("lang"); ContributorsEnabled = obj.GetBoolean("contributors_enabled"); IsTranslator = obj.GetBoolean("is_translator"); FollowRequestSent = obj.HasValue("follow_request_sent") && obj.GetBoolean("follow_request_sent"); Status = obj.GetObject("status", TwitterStatusMessage.Parse); Entities = obj.GetObject("entities", TwitterUserEntities.Parse); HasDefaultProfile = obj.GetBoolean("default_profile"); HasDefaultProfileImage = obj.GetBoolean("default_profile_image"); ProfileBackgroundColor = obj.GetString("profile_background_color"); ProfileBackgroundImageUrl = obj.GetString("profile_background_image_url"); ProfileBackgroundImageUrlHttps = obj.GetString("profile_background_image_url_https"); ProfileBackgroundTile = obj.GetBoolean("profile_background_tile"); ProfileBannerUrl = obj.GetString("profile_banner_url"); ProfileImageUrl = obj.GetString("profile_image_url"); ProfileImageUrlHttps = obj.GetString("profile_image_url_https"); ProfileLinkColor = obj.GetString("profile_link_color"); ProfileSidebarBorderColor = obj.GetString("profile_sidebar_border_color"); ProfileSidebarFillColor = obj.GetString("profile_sidebar_fill_color"); ProfileTextColor = obj.GetString("profile_text_color"); ProfileUseBackgroundImage = obj.GetBoolean("profile_use_background_image"); }
//----------------------------------------------------------------------------------------------------------------- // Opens given Facebook/Twitter site. //----------------------------------------------------------------------------------------------------------------- void VisitSite(SiteData site) { // Debug.Log( "CAPA" ); // Debug.Log( "CAPA : GuiScreenBank : VisitSite( " + site.m_URL + " )" ); m_LoggedIn = true; m_WaitForLogin = 0.0f; m_VisitingSite = site; if (site.m_FBSite) // Facebook { if ((site.m_Rewarded == false) && (FacebookPlugin.Instance.CurrentUser == null)) { // Debug.Log( "CAPA : GuiScreenBank : VisitSite : Login to Facebook..." ); m_LoggedIn = false; m_WaitForLogin = float.MaxValue; FacebookPlugin.Instance.Login("user_likes", OnFacebookLoginComplete); } } else // Twitter { if ((site.m_Rewarded == false) && (TwitterWrapper.IsLoggedIn() == false)) { // Debug.Log( "CAPA : GuiScreenBank : VisitSite : Login to Twitter..." ); m_LoggedIn = false; m_WaitForLogin = float.MaxValue; TwitterUtils.LogIn(this.OnLoginResult); } } StartCoroutine(WaitForLogin()); }
/// <summary> /// Gets a user from the specified <var>JsonObject</var>. /// </summary> /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param> public static TwitterUser Parse(JsonObject obj) { // Error checking if (obj == null) { return(null); } if (obj.HasValue("error")) { throw TwitterException.Parse(obj.GetArray("error")); } TwitterUser user = new TwitterUser(obj); #region Basic properties user.Id = obj.GetInt64("id"); user.IdStr = obj.GetString("id_str"); user.Name = obj.GetString("name"); user.ScreenName = obj.GetString("screen_name"); user.Location = obj.GetString("location"); user.Url = obj.GetString("url"); user.Description = obj.GetString("description"); user.IsProtected = obj.GetBoolean("protected"); user.FollowersCount = obj.GetInt32("followers_count"); user.FriendsCount = obj.GetInt32("friends_count"); user.ListedCount = obj.GetInt32("listed_count"); user.CreatedAt = TwitterUtils.ParseDateTime(obj.GetString("created_at")); user.FavouritesCount = obj.GetInt32("favourites_count"); if (obj.HasValue("utc_offset")) { user.UtcOffset = obj.GetInt32("utc_offset"); } user.TimeZone = obj.GetString("time_zone"); user.IsGeoEnabled = obj.GetBoolean("geo_enabled"); user.IsVerified = obj.GetBoolean("verified"); user.StatusesCount = obj.GetInt32("statuses_count"); user.Language = obj.GetString("lang"); user.ContributorsEnabled = obj.GetBoolean("contributors_enabled"); user.IsTranslator = obj.GetBoolean("is_translator"); user.FollowRequestSent = obj.HasValue("follow_request_sent") && obj.GetBoolean("follow_request_sent"); user.Status = obj.GetObject("status", TwitterStatusMessage.Parse); user.Entities = obj.GetObject("entities", TwitterUserEntities.Parse); #endregion #region Profile properties user.HasDefaultProfile = obj.GetBoolean("default_profile"); user.HasDefaultProfileImage = obj.GetBoolean("default_profile_image"); user.ProfileBackgroundColor = obj.GetString("profile_background_color"); user.ProfileBackgroundImageUrl = obj.GetString("profile_background_image_url"); user.ProfileBackgroundImageUrlHttps = obj.GetString("profile_background_image_url_https"); user.ProfileBackgroundTile = obj.GetBoolean("profile_background_tile"); user.ProfileBannerUrl = obj.GetString("profile_banner_url"); user.ProfileImageUrl = obj.GetString("profile_image_url"); user.ProfileImageUrlHttps = obj.GetString("profile_image_url_https"); user.ProfileLinkColor = obj.GetString("profile_link_color"); user.ProfileSidebarBorderColor = obj.GetString("profile_sidebar_border_color"); user.ProfileSidebarFillColor = obj.GetString("profile_sidebar_fill_color"); user.ProfileTextColor = obj.GetString("profile_text_color"); user.ProfileUseBackgroundImage = obj.GetBoolean("profile_use_background_image"); #endregion return(user); }
public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { model.Remove(CefMenuCommand.Back); model.Remove(CefMenuCommand.Forward); model.Remove(CefMenuCommand.Print); model.Remove(CefMenuCommand.ViewSource); RemoveSeparatorIfLast(model); if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection)) { if (parameters.TypeFlags.HasFlag(ContextMenuType.Editable)) { model.AddSeparator(); model.AddItem(MenuInputApplyROT13, "Apply ROT13"); } model.AddSeparator(); } base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model); lastHighlightedTweetUrl = TweetDeckBridge.LastHighlightedTweetUrl; lastHighlightedQuoteUrl = TweetDeckBridge.LastHighlightedQuoteUrl; if (!TwitterUtils.IsTweetDeckWebsite(frame) || browser.IsLoading) { lastHighlightedTweetUrl = string.Empty; lastHighlightedQuoteUrl = string.Empty; } if (!string.IsNullOrEmpty(lastHighlightedTweetUrl) && (parameters.TypeFlags & (ContextMenuType.Editable | ContextMenuType.Selection)) == 0) { model.AddItem(MenuOpenTweetUrl, "Open tweet in browser"); model.AddItem(MenuCopyTweetUrl, "Copy tweet address"); model.AddItem(MenuScreenshotTweet, "Screenshot tweet to clipboard"); if (!string.IsNullOrEmpty(lastHighlightedQuoteUrl)) { model.AddSeparator(); model.AddItem(MenuOpenQuotedTweetUrl, "Open quoted tweet in browser"); model.AddItem(MenuCopyQuotedTweetUrl, "Copy quoted tweet address"); } model.AddSeparator(); } if ((parameters.TypeFlags & (ContextMenuType.Editable | ContextMenuType.Selection)) == 0) { AddSeparator(model); IMenuModel globalMenu = model.Count == 0 ? model : model.AddSubMenu(MenuGlobal, Program.BrandName); globalMenu.AddItem(CefMenuCommand.Reload, TitleReloadBrowser); globalMenu.AddCheckItem(MenuMute, TitleMuteNotifications); globalMenu.SetChecked(MenuMute, Program.UserConfig.MuteNotifications); globalMenu.AddSeparator(); globalMenu.AddItem(MenuSettings, TitleSettings); globalMenu.AddItem(MenuPlugins, TitlePlugins); globalMenu.AddItem(MenuAbout, TitleAboutProgram); if (HasDevTools) { globalMenu.AddSeparator(); AddDebugMenuItems(globalMenu); } } RemoveSeparatorIfLast(model); form.InvokeAsyncSafe(() => form.TriggerAnalyticsEvent(AnalyticsFile.Event.BrowserContextMenu)); }
private IEnumerator PostResults_Coroutine(bool facebook, RoundFinalResult result) { // hide "social networks" widgets (will be hidden on posted screen-shots)... GUIBase_Widget socNetsRoot = Layout.GetWidget("SocialNetworks", true); socNetsRoot.ShowImmediate(false, true); // take & post screen-shot (with message)... yield return(new WaitForEndOfFrame()); int idx; int textIndex = result.Place; #if (FB_LOGIN_REVIEW) textIndex = 1; #endif if (result.GameType == E_MPGameType.DeathMatch) { idx = TextID_RankingsDM[textIndex]; } else { idx = TextID_RankingsZC[textIndex]; } string name = CloudUser.instance.primaryKey; if (FacebookPlugin.Instance.CurrentUser != null && !string.IsNullOrEmpty(FacebookPlugin.Instance.CurrentUser.Name)) { name = FacebookPlugin.Instance.CurrentUser.Name; } if (facebook == true) { byte[] screenshot = takeScreenshot(); if (screenshot != null) { yield return(StartCoroutine(FacebookPlugin.Instance.Init())); string requestedScope = "publish_actions"; if (FacebookPlugin.Instance.IsLoggedIn() == false || FacebookPlugin.Instance.HasPermittedScope(requestedScope) == false) { yield return(StartCoroutine(FacebookPlugin.Instance.Login(requestedScope))); } if (FacebookPlugin.Instance.IsLoggedIn() == true && FacebookPlugin.Instance.HasPermittedScope(requestedScope) == true) { yield return(StartCoroutine(FacebookPlugin.Instance.PostImage(string.Empty, screenshot))); } } else { Debug.LogWarning("Could not capture screenshot!"); } } else { #if (UNITY_ANDROID || UNITY_IPHONE) string msg = string.Format(TextDatabase.instance[idx], name, result.MapName); TwitterUtils.PostScreenshot(msg, OnPostResult); #endif } // show "social networks" widgets again... yield return(new WaitForSeconds(1.0f)); #if (UNITY_ANDROID || UNITY_IPHONE) socNetsRoot.ShowImmediate(Layout.Visible, true); #endif }
/// <summary> /// Gets a status message (tweet) from the specified <var>JsonObject</var>. /// </summary> /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param> public static TwitterStatusMessage Parse(JsonObject obj) { // Error checking if (obj == null) { return(null); } if (obj.HasValue("error")) { throw TwitterException.Parse(obj.GetArray("error")); } if (obj.HasValue("errors")) { throw TwitterException.Parse(obj.GetArray("errors")); } TwitterStatusMessage msg = new TwitterStatusMessage(obj) { Id = obj.GetInt64("id"), Text = obj.GetString("text"), Source = obj.GetString("source"), IsTruncated = obj.GetBoolean("truncated") }; // Twitter has some strange date formats msg.CreatedAt = TwitterUtils.ParseDateTimeUtc(obj.GetString("created_at")); // Parse the reply information if (obj.HasValue("in_reply_to_status_id")) { msg.InReplyTo = new TwitterReplyTo { StatusId = obj.GetInt64("in_reply_to_status_id"), StatusIdStr = obj.GetString("in_reply_to_status_id_str"), UserId = obj.GetInt64("in_reply_to_user_id"), UserIdStr = obj.GetString("in_reply_to_user_id_str"), ScreenName = obj.GetString("in_reply_to_screen_name") }; } msg.RetweetCount = obj.GetInt32("retweet_count"); msg.FavoriteCount = obj.GetInt32("favorite_count"); // Related to the authenticating user msg.HasFavorited = obj.GetBoolean("favorited"); msg.HasRetweeted = obj.GetBoolean("retweeted"); // Parse the entities (if any) msg.Entities = obj.GetObject("entities", TwitterStatusMessageEntities.Parse); // For some weird reason Twitter flips the coordinates by writing longitude before latitude // See: https://dev.twitter.com/docs/platform-objects/tweets#obj-coordinates) msg.Coordinates = TwitterCoordinates.Parse(obj.GetObject("coordinates")); // See: https://dev.twitter.com/docs/platform-objects/tweets#obj-contributors /*if (tweet.contributors != null) { * List<TwitterContributor> contributors = new List<TwitterContributor>(); * foreach (dynamic contributor in tweet.contributors) { * contributors.Add(new TwitterContributor { * UserId = contributor.id, * ScreenName = contributor.screen_name * }); * } * msg.Contributors = contributors.ToArray(); * }*/ msg.User = obj.GetObject("user", TwitterUser.Parse); msg.Place = obj.GetObject("place", TwitterPlace.Parse); msg.IsPossiblyOffensive = obj.GetBoolean("possibly_sensitive"); msg.Language = obj.GetString("lang"); return(msg); }
public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { bool isSelecting = parameters.TypeFlags.HasFlag(ContextMenuType.Selection); bool isEditing = parameters.TypeFlags.HasFlag(ContextMenuType.Editable); model.Remove(CefMenuCommand.Back); model.Remove(CefMenuCommand.Forward); model.Remove(CefMenuCommand.Print); model.Remove(CefMenuCommand.ViewSource); RemoveSeparatorIfLast(model); if (isSelecting) { if (isEditing) { model.AddSeparator(); model.AddItem(MenuWriteApplyROT13, "Apply ROT13"); } model.AddSeparator(); } base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model); if (isSelecting && !isEditing && TwitterUtils.IsTweetDeckWebsite(frame)) { InsertSelectionSearchItem(model, MenuSearchInColumn, "Search in a column"); } if (Context.Types.HasFlag(ContextInfo.ContextType.Chirp) && !isSelecting && !isEditing) { model.AddItem(MenuOpenTweetUrl, "Open tweet in browser"); model.AddItem(MenuCopyTweetUrl, "Copy tweet address"); model.AddItem(MenuScreenshotTweet, "Screenshot tweet to clipboard"); if (!string.IsNullOrEmpty(Context.Chirp.QuoteUrl)) { model.AddSeparator(); model.AddItem(MenuOpenQuotedTweetUrl, "Open quoted tweet in browser"); model.AddItem(MenuCopyQuotedTweetUrl, "Copy quoted tweet address"); } model.AddSeparator(); } if (!isSelecting && !isEditing) { AddSeparator(model); IMenuModel globalMenu = model.Count == 0 ? model : model.AddSubMenu(MenuGlobal, Program.BrandName); globalMenu.AddItem(CefMenuCommand.Reload, TitleReloadBrowser); globalMenu.AddCheckItem(MenuMute, TitleMuteNotifications); globalMenu.SetChecked(MenuMute, Config.MuteNotifications); globalMenu.AddSeparator(); globalMenu.AddItem(MenuSettings, TitleSettings); globalMenu.AddItem(MenuPlugins, TitlePlugins); globalMenu.AddItem(MenuAbout, TitleAboutProgram); AddDebugMenuItems(globalMenu); } RemoveSeparatorIfLast(model); form.InvokeAsyncSafe(form.AnalyticsFile.BrowserContextMenus.Trigger); }
public virtual bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { Control control = browserControl.AsControl(); switch (commandId) { case MenuOpenLinkUrl: OpenBrowser(control, Context.LinkUrl); break; case MenuCopyLinkUrl: SetClipboardText(control, Context.UnsafeLinkUrl); break; case MenuCopyUsername: { string url = Context.UnsafeLinkUrl; Match match = TwitterUtils.RegexAccount.Match(url); SetClipboardText(control, match.Success ? match.Groups[1].Value : url); control.InvokeAsyncSafe(analytics.AnalyticsFile.CopiedUsernames.Trigger); break; } case MenuOpenMediaUrl: OpenBrowser(control, TwitterUtils.GetMediaLink(Context.MediaUrl, ImageQuality)); break; case MenuCopyMediaUrl: SetClipboardText(control, TwitterUtils.GetMediaLink(Context.MediaUrl, ImageQuality)); break; case MenuViewImage: { string url = Context.MediaUrl; control.InvokeAsyncSafe(() => { TwitterUtils.ViewImage(url, ImageQuality); analytics.AnalyticsFile.ViewedImages.Trigger(); }); break; } case MenuSaveMedia: { bool isVideo = Context.Types.HasFlag(ContextInfo.ContextType.Video); string url = Context.MediaUrl; string username = Context.Chirp.Authors.LastOrDefault(); control.InvokeAsyncSafe(() => { if (isVideo) { TwitterUtils.DownloadVideo(url, username); analytics.AnalyticsFile.DownloadedVideos.Trigger(); } else { TwitterUtils.DownloadImage(url, username, ImageQuality); analytics.AnalyticsFile.DownloadedImages.Trigger(); } }); break; } case MenuSaveTweetImages: { string[] urls = Context.Chirp.Images; string username = Context.Chirp.Authors.LastOrDefault(); control.InvokeAsyncSafe(() => { TwitterUtils.DownloadImages(urls, username, ImageQuality); analytics.AnalyticsFile.DownloadedImages.Trigger(); }); break; } case MenuReadApplyROT13: string selection = parameters.SelectionText; control.InvokeAsyncSafe(() => FormMessage.Information("ROT13", StringUtils.ConvertRot13(selection), FormMessage.OK)); control.InvokeAsyncSafe(analytics.AnalyticsFile.UsedROT13.Trigger); return(true); case MenuSearchInBrowser: string query = parameters.SelectionText; control.InvokeAsyncSafe(() => BrowserUtils.OpenExternalSearch(query)); DeselectAll(frame); break; case MenuOpenDevTools: browserControl.ShowDevTools(); break; } return(false); }
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model) { if (!TwitterUtils.IsTweetDeckWebsite(frame) || browser.IsLoading) { Context = TweetDeckBridge.ContextInfo.Reset(); } else { Context = TweetDeckBridge.ContextInfo.Create(parameters); } if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection) && !parameters.TypeFlags.HasFlag(ContextMenuType.Editable)) { model.AddItem(MenuSearchInBrowser, "Search in browser"); model.AddSeparator(); model.AddItem(MenuReadApplyROT13, "Apply ROT13"); model.AddSeparator(); } string TextOpen(string name) => "Open " + name + " in browser"; string TextCopy(string name) => "Copy " + name + " address"; string TextSave(string name) => "Save " + name + " as..."; if (Context.Types.HasFlag(ContextInfo.ContextType.Link) && !Context.UnsafeLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)) { if (TwitterUtils.RegexAccount.IsMatch(Context.UnsafeLinkUrl)) { model.AddItem(MenuOpenLinkUrl, TextOpen("account")); model.AddItem(MenuCopyLinkUrl, TextCopy("account")); model.AddItem(MenuCopyUsername, "Copy account username"); } else { model.AddItem(MenuOpenLinkUrl, TextOpen("link")); model.AddItem(MenuCopyLinkUrl, TextCopy("link")); } model.AddSeparator(); } if (Context.Types.HasFlag(ContextInfo.ContextType.Video)) { model.AddItem(MenuOpenMediaUrl, TextOpen("video")); model.AddItem(MenuCopyMediaUrl, TextCopy("video")); model.AddItem(MenuSaveMedia, TextSave("video")); model.AddSeparator(); } else if (Context.Types.HasFlag(ContextInfo.ContextType.Image) && Context.MediaUrl != TweetNotification.AppLogo.Url) { model.AddItem(MenuViewImage, "View image in photo viewer"); model.AddItem(MenuOpenMediaUrl, TextOpen("image")); model.AddItem(MenuCopyMediaUrl, TextCopy("image")); model.AddItem(MenuSaveMedia, TextSave("image")); if (Context.Chirp.Images.Length > 1) { model.AddItem(MenuSaveTweetImages, TextSave("all images")); } model.AddSeparator(); } }
public TweetViewModel(int count) { Tweets = TwitterUtils.GetTweets(count); }
public virtual bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { switch (commandId) { case MenuOpenLinkUrl: OpenBrowser(browserControl.AsControl(), IsLink ? ContextInfo.Value : parameters.LinkUrl); break; case MenuCopyLinkUrl: SetClipboardText(browserControl.AsControl(), IsLink ? ContextInfo.Value : parameters.UnfilteredLinkUrl); break; case MenuCopyUsername: Match match = TwitterUtils.RegexAccount.Match(parameters.UnfilteredLinkUrl); SetClipboardText(browserControl.AsControl(), match.Success ? match.Groups[1].Value : parameters.UnfilteredLinkUrl); break; case MenuOpenMediaUrl: OpenBrowser(browserControl.AsControl(), TwitterUtils.GetMediaLink(GetMediaLink(parameters), ImageQuality)); break; case MenuCopyMediaUrl: SetClipboardText(browserControl.AsControl(), TwitterUtils.GetMediaLink(GetMediaLink(parameters), ImageQuality)); break; case MenuViewImage: string url = GetMediaLink(parameters); string file = Path.Combine(BrowserCache.CacheFolder, TwitterUtils.GetImageFileName(url)); void ViewFile() { string ext = Path.GetExtension(file); if (TwitterUtils.ValidImageExtensions.Contains(ext)) { WindowsUtils.OpenAssociatedProgram(file); } else { FormMessage.Error("Image Download", "Invalid file extension " + ext, FormMessage.OK); } } if (File.Exists(file)) { ViewFile(); } else { BrowserUtils.DownloadFileAsync(TwitterUtils.GetMediaLink(url, ImageQuality), file, ViewFile, ex => { FormMessage.Error("Image Download", "An error occurred while downloading the image: " + ex.Message, FormMessage.OK); }); } break; case MenuSaveMedia: if (IsVideo) { TwitterUtils.DownloadVideo(GetMediaLink(parameters), lastHighlightedTweetAuthors.LastOrDefault()); } else { TwitterUtils.DownloadImage(GetMediaLink(parameters), lastHighlightedTweetAuthors.LastOrDefault(), ImageQuality); } break; case MenuSaveTweetImages: TwitterUtils.DownloadImages(lastHighlightedTweetImageList, lastHighlightedTweetAuthors.LastOrDefault(), ImageQuality); break; case MenuOpenDevTools: browserControl.ShowDevTools(); break; } return(false); }