private void Streaming_OnNotification(object sender, StreamNotificationEventArgs e)
 {
     this.Notificated?.Invoke(this, new ObjectFunctionUpdateEventArgs <MastodonNotification>
     {
         Object = e.Notification.ToMastodonNotification(),
     });
 }
Exemple #2
0
        // 各種関数
        void AdminCommand(string content, StreamNotificationEventArgs e)
        {
            Console.WriteLine("<<--  Admin Command START.  -->>");
            Console.WriteLine($"Receive: {content}");
            Console.WriteLine("  ----------------------------  ");
            if (Regex.IsMatch(content, @"^.*(admincmd)$"))
            {
                // 死活確認
                var tootText = $"@{e.Notification.Account.UserName} I'm up.";
                this.client.PostStatus(tootText, Visibility.Direct, e.Notification.Status.Id);
                Console.WriteLine($"Toot: {tootText}");
            }
            else if (Regex.IsMatch(content, @"^.*(admincmd) (restart)$"))
            {
                // サービス再起動
                Console.WriteLine("アプリケーションを再起動します。");
                this.ServiceRestart();
            }
            else if (Regex.IsMatch(content, @"^.*(admincmd) (startdate)$"))
            {
                // サービス開始時刻
                var tootText = $"@{e.Notification.Account.UserName} {this.serviceStartedTime}";
                this.client.PostStatus(tootText, Visibility.Direct, e.Notification.Status.Id);
                Console.WriteLine($"Toot: {tootText}");
            }
            else if (Regex.IsMatch(content, @"^.*(admincmd) (yure)$"))
            {
                // 地震情報
                this.QuakeCheck();
            }
            else if (Regex.IsMatch(content, @"^.*(admincmd) (ch_nickname) (.*?) (.*?)$"))
            {
                try
                {
                    var setNickNameReg = new Regex(@"^.*(admincmd) (ch_nickname) (.*?) (.*?)$", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    var m = setNickNameReg.Match(content);

                    var userName = m.Groups[3].Value;
                    var nickName = m.Groups[4].Value;

                    var data = this.userList.GetUserDataWithUserName(userName);
                    data.NickName = nickName;
                    this.userList.SetUserDataWithUserName(data);
                    this.client.PostStatus($"@{e.Notification.Account.UserName} じゃあこれからは{userName}さんのこと{nickName}って呼ぶね!", Visibility.Direct);
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }
            else if (Regex.IsMatch(content, @"^.*(admincmd) (test_notify)$"))
            {
                this.AlertToFlows(content);
            }
            Console.WriteLine("<<--  Admin Command STOP.  -->>");
        }
Exemple #3
0
        void UserNotificationBranch(StreamNotificationEventArgs e)
        {
            // htmlタグ除去
            var rejectHtmlTagReg = new Regex("<.*?>");
            var content          = rejectHtmlTagReg.Replace(e.Notification.Status.Content, "");

            if (Regex.IsMatch(content, RegexStringSet.AdminCommandExecPattern) && e.Notification.Account.Id == long.Parse(ConfigurationManager.AppSettings["adminId"]))
            {
                this.AdminCommand(content, e);
            }
            else if (Regex.IsMatch(content, RegexStringSet.DirectQuakeCheckPattern))
            {
                this.QuakeCheck(e.Notification.Account.UserName);
            }
            else if (Regex.IsMatch(content, RegexStringSet.SetNickName) && e.Notification.Status.Visibility == Visibility.Direct)
            {
                this.SetNickName(content, e.Notification.Account.UserName);
            }
            else if (Regex.IsMatch(content, RegexStringSet.KiribanPattern) && e.Notification.Account.Id == long.Parse(ConfigurationManager.AppSettings["lucky_number_botId"]))
            {
                this.client.PostStatus("キリ番だ!やったー!", Visibility.Public);
            }
        }
Exemple #4
0
 private void Streaming_OnNotification(object sender, StreamNotificationEventArgs e) => Add(e.Notification);