Exemplo n.º 1
0
        /// <summary>
        /// BOT初期化
        /// * 設定読み込み
        /// * タイマー設定
        /// </summary>
        /// <param name="output">ログ出力先</param>
        public KamatteBot(logOutput output = null)
        {
            LogOutput = output;

            Settings = Properties.Settings.Default.Kamatte;
            if (Settings == null)
            {
                Settings = new KamatteSettings();
                Settings.WaitTime = 5;
                Settings.GlobalFilter = "";
                Settings.Targets = new List<TargetUser>();
                var t = new TargetUser();
                t.Id = 0;
                t.Name = "null";
                t.Filter = "*";
                Settings.Targets.Add(t);
            }
            Log(Settings.ToString());

            watchingList = new DictionaryQueue<decimal, TwitterStatus>();

            /* Set timer */
            countClearTimer = TimerUtil.DailyTimer(CountClearTask);
        }
Exemplo n.º 2
0
        /// <summary>
        /// ツッコミ投稿
        /// </summary>
        /// <param name="s">ツッコミ対象status</param>
        private void Kamatte(TwitterStatus s)
        {
            var t = Settings.IncrementKamatteCount(s.User.Id);
            var sb = new StringBuilder("誰かかまってやれよ! ");
            if (t == null)
            {
                t = new TargetUser();
                t.Id = s.User.Id;
                t.Name = s.User.ScreenName;
                t.DailyKamatteCount = 1;
                t.TotalKamatteCount = 1;
                t.Filter = "(?!)";
                Settings.Targets.Add(t);
            }
            if (t != null)
            {
                sb.Append("(本日").Append(t.DailyKamatteCount).Append("回目, 累計").Append(t.TotalKamatteCount).Append("回) ");
            }
            sb.Append("RT ").Append(s.User.ScreenName).Append(": ").Append(s.Text.Replace("@", "(at)"));

            var r = Twitter.GetInstance().StatusUpdate(sb.Length > 140 ? sb.ToString(0, 139) + "…" : sb.ToString());
            if (r.Result.Equals(RequestResult.Success))
            {
                Log("Tweet kamatte!: @" + s.User.ScreenName + ", Count: " + t.DailyKamatteCount + "/" + t.TotalKamatteCount);
            }
            else
            {
                Log("Tweet error: " + r.ErrorMessage);
            }
        }