public async Task <IEnumerable <Notification> > RefreshTimeline(bool pullToRefresh) { IsLoading = true; IEnumerable <Notification> statuses; try { ArrayOptions options = new ArrayOptions(); if (pullToRefresh) { if (this.Any()) { options.SinceId = this.First().Id; } } else { if (_maxId > 0) { options.MaxId = _maxId; } } statuses = await _client.GetNotifications(options); } catch (Exception e) { // TODO: Show error Console.WriteLine(e); statuses = new List <Notification>(); } IsLoading = false; return(statuses); }
public async Task <IEnumerable <Status> > RefreshTimeline(bool pullToRefresh) { IsLoading = true; IEnumerable <Status> statuses; try { ArrayOptions options = new ArrayOptions(); if (pullToRefresh) { if (this.Any()) { options.SinceId = this.First().Id; } } else { if (_maxId > 0) { options.MaxId = _maxId; } } switch (_path) { case "home": statuses = await _client.GetHomeTimeline(options); break; case "public": statuses = await _client.GetPublicTimeline(options); break; case "local": statuses = await _client.GetPublicTimeline(options, true); break; case "account": statuses = await _client.GetAccountStatuses(_accountId, options); break; default: statuses = await _client.GetHomeTimeline(options); break; } } catch (Exception e) { // TODO: Show error Console.WriteLine(e); statuses = new List <Status>(); } IsLoading = false; return(statuses); }
public SerializationContext() { DateTimeOptions = new DateTimeOptions(); EnumOptions = new EnumOptions(); ArrayOptions = new ArrayOptions(); MapOptions = new MapOptions(); JsonOptions = new JsonOptions(); TypeHandlers = new TypeHandlers(this); }
protected override Task <MastodonList <Status> > FetchAsync(ArrayOptions options) => GetTimeline(options);
protected abstract Task <MastodonList <Status> > GetTimeline(ArrayOptions options);
protected override Task <MastodonList <Status> > GetTimeline(ArrayOptions options) => client.GetAccountStatuses(Id, options);
protected override Task <MastodonList <Status> > GetTimeline(ArrayOptions options) => client.GetPublicTimeline(options);
protected abstract Task <MastodonList <T> > FetchAsync(ArrayOptions options);
protected override Task <MastodonList <Notification> > FetchAsync(ArrayOptions options) => client.GetNotifications(options);
void QuakeCheck(string userName = "") { this.quakeCheckDateTime = DateTime.Now; var options = new ArrayOptions(); options.Limit = 1; try { var nervstatuses = this.client.GetAccountStatuses(this.earthquakeUserId, options).Result; // htmlタグ除去 var rejectHtmlTagReg = new Regex("<.*?>"); var content = rejectHtmlTagReg.Replace(nervstatuses[0].Content, string.Empty); // var url = nervstatuses[0].Url; var url = "https://unnerv.jp/"; var jisinReg = new Regex(@"((\d{4})年(\d{1,})月(\d{1,})日)(】)((\d{1,})時(\d{1,})分)(頃、)(.*)(?:を震源とする)(.*)(?:最大震度)(.*?)(?:を)(.*)(?:で観測して)", RegexOptions.IgnoreCase | RegexOptions.Singleline); var m = jisinReg.Match(content); var datestr = m.Groups[1].Value; var timestr = m.Groups[6].Value; var kansokuchi = m.Groups[13].Value; var shindo = m.Groups[12].Value; var shingen = m.Groups[10].Value; var year = int.Parse(m.Groups[2].Value); var month = int.Parse(m.Groups[3].Value); var day = int.Parse(m.Groups[4].Value); var hour = int.Parse(m.Groups[7].Value); var min = int.Parse(m.Groups[8].Value); var quakeTime = new DateTime(year, month, day, hour, min, 0); var elapsedTime = DateTime.Now - quakeTime; var tootText = string.Empty; if ((elapsedTime < new TimeSpan(0, 15, 0)) || (elapsedTime < new TimeSpan(0, 30, 0) && shindo != "1")) { tootText = $"{timestr}頃に{kansokuchi}で震度{shindo}の地震があったらしいよ。震源は{shingen}みたいだね。詳細はここに書いてあったよ。{url}"; } else if (shindo == "1") { tootText = $"私の胸は揺れなかった。。。"; } else if (elapsedTime < new TimeSpan(0, 30, 0)) { tootText = $"いつの話をしているの?直近の地震は{timestr}頃に{kansokuchi}で観測した震度{shindo}だよ?"; } else if (elapsedTime < new TimeSpan(1, 0, 0)) { tootText = $"いつの話をしているの?"; } else if (elapsedTime > new TimeSpan(1, 0, 0, 0)) { tootText = $"今日は揺れてないよ。"; } if (userName == "") { // 通常処理 this.client.PostStatus(tootText, Visibility.Public); } else { // ユーザ指定時処理 this.client.PostStatus($"@{userName} {tootText}", Visibility.Direct); } Console.WriteLine(tootText); } catch (Exception e) { Console.WriteLine(e.Message); } }
public ExportableAttribute(ArrayOptions options) { this.options = options; }