Example #1
0
        /// <summary>
        /// ログ出力先を指定して <b>CheckCalendar</b> を初期化する
        /// </summary>
        /// <param name="output">ログ出力デリゲート</param>
        public CheckCalendar(logOutput output)
        {
            LogOutput = output;
            TargetCalendar = new Dictionary<string, string>(3);
            TargetCalendar.Add(
                // ubi-lab
                "https://www.google.com/calendar/ical/o9maiadqkkharfiulir7t7b02o%40group.calendar.google.com/private-86ed854da9c66146539f063f73018231/basic.ics",
                "学会や出張など");
            TargetCalendar.Add(
                // ubi-meeting
                "https://www.google.com/calendar/ical/0igfeooghukogkuv32k0tinp58%40group.calendar.google.com/private-f839f24192ba67940b02dad0e3ce3a22/basic.ics",
                "ミーティング");
            TargetCalendar.Add(
                // ubi-event
                "https://www.google.com/calendar/ical/ubi-license%40is.naist.jp/private-b105373c049e97ad17f71606354d047b/basic.ics",
                "研究室内イベント");
            TargetCalendar.Add(
                // ito-lab meeting
                "https://www.google.com/calendar/ical/ito-license%40is.naist.jp/private-d465374335b22e44df3c0a58e9aa4d4c/basic.ics",
                "伊藤研ミーティング");

            calTimer = new List<System.Threading.Timer>();
            Hour = 7;
            run(new object());
        }
Example #2
0
        /// <summary>
        /// 1つ目のカメラでカメラ初期化
        /// </summary>
        /// <param name="output"></param>
        public Camera(logOutput output = null)
        {
            LogOutput = output;

            // カメラの用意
            cap = Cv.CreateCameraCapture(0);
            Log(cap.CaptureType + ", " + cap.FrameWidth + "x" + cap.FrameHeight + ", " + cap.Mode);

            Cv.SetCaptureProperty(cap, CaptureProperty.FrameWidth, WIDTH);
            Cv.SetCaptureProperty(cap, CaptureProperty.FrameHeight, HEIGHT);

            // 検出器の用意
            cvHCC = Cv.Load<CvHaarClassifierCascade>("haarcascade_profileface.xml");
            stor = Cv.CreateMemStorage(0);
        }
Example #3
0
        /// <summary>
        /// Twitterストリームを初期化
        /// </summary>
        /// <param name="output">ログ出力用Delegate</param>
        private Twitter(logOutput output = null)
        {
            LogOutput = output;

            if (
                string.IsNullOrWhiteSpace(Properties.Settings.Default.consumerKey) ||
                string.IsNullOrWhiteSpace(Properties.Settings.Default.consumerSecret) ||
                string.IsNullOrWhiteSpace(Properties.Settings.Default.accessToken) ||
                string.IsNullOrWhiteSpace(Properties.Settings.Default.accessTokenSecret)
                )
            {
                OAuthForm f = new OAuthForm();
                if (f.ShowDialog() == System.Windows.Forms.DialogResult.Abort)
                {
                    System.Windows.Forms.Application.Exit();
                    Environment.Exit(0);
                }
                Properties.Settings.Default.Reload();
            }

            token = new OAuthTokens
            {
                ConsumerKey = Properties.Settings.Default.consumerKey,
                ConsumerSecret = Properties.Settings.Default.consumerSecret,
                AccessToken = Properties.Settings.Default.accessToken,
                AccessTokenSecret = Properties.Settings.Default.accessTokenSecret
            };

            ustream = new TwitterStream(token, "labMonitor", null);

            var k = Properties.Settings.Default.Kamatte;
            var opt = new StreamOptions();
            if (k != null)
            {
                opt.Follow = k.GetTargetIdArray();
                opt.Track = k.GetTargetNameArray();
                pstream = new TwitterStream(token, "labMonitorPublic", opt);
            }
        }
Example #4
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);
        }
Example #5
0
 /// <summary>
 /// ログ出力先を指定して <b>WeatherPost</b> のインスタンスを初期化する
 /// </summary>
 /// <param name="output">ログ出力デリゲート</param>
 public WeatherPost(logOutput output = null)
 {
     LogOutput = output;
     Hour = 7;
 }
Example #6
0
        /// <see cref="LabMonitoring.ITweetHandler"/>
        public void HandleStatus(TwitterStatus target, logOutput log)
        {
            if (target.InReplyToStatusId != null)
            {
                /* Receive a reply message */
                if (target.User.Id == target.InReplyToUserId)
                {
                    /* Self reply message */
                    if (watchingList.ContainsKey((decimal)target.InReplyToStatusId))
                    {
                        Log("Receive a self reply message: [" + target.Id + "] @" + target.User.ScreenName + " " + target.Text + " to " + target.InReplyToStatusId);
                        Kamatte(target);
                        watchingList.Remove((decimal)target.InReplyToStatusId);
                    }
                }
                else
                {
                    /* Other's tweet */
                    /* A message sent from othe to target */
                    if (watchingList.ContainsKey((decimal)target.InReplyToStatusId))
                    {
                        Log("Receive a message sent from other to target: [" + target.Id + "] @" + target.User.ScreenName + " " + target.Text + " to " + target.InReplyToStatusId);
                        watchingList.Remove((decimal)target.InReplyToStatusId);
                    }
                }
            }
            else
            {
                /* Global target */
                if (Regex.IsMatch(target.Text, Settings.GlobalFilter))
                {
                    if (AddStatusToWatchingList(target))
                    {
                        Log("Receive a global filter tweet: [" + target.Id + "] @" + target.User.ScreenName + " " + target.Text);
                    }
                    return;
                }

                /* Recieve a nomal message */
                if (Settings.GetTargetIdArray().Contains(target.User.Id.ToString()) && target.RetweetedStatus == null)
                {
                    /* Target's tweet */
                    var t = Settings.GetTargetUserFromId(target.User.Id);
                    string f = null;
                    if (t != null)
                    {
                        f = t.Filter;
                    }
                    if (string.IsNullOrEmpty(f))
                    {
                        f = ".*";
                    }

                    if (Regex.IsMatch(target.Text, "(ぼっち|ボッチ)飯"))
                    {
                        Kamatte(target);
                        return;
                    }
                    if (!Regex.IsMatch(target.Text, f, RegexOptions.IgnoreCase)) return;
                    if (Regex.IsMatch(target.Source, ">ikejun<")) return;

                    if (AddStatusToWatchingList(target))
                    {
                        Log("Receive a target tweet: [" + target.Id + "] @" + target.User.ScreenName + " " + target.Text);
                    }
                }
            }
        }
Example #7
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public Form1()
 {
     InitializeComponent();
     output = new logOutput(_output);
     curLog = new currentLog(_curLog);
 }
Example #8
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);
            }
        }