Пример #1
0
        private void Auth()
        {
            mGroupBox.Text = "認証中です。";

            Twitter tw = new Twitter();
            if (tw.xAuth(mID.Text, mPassword.Text))
            {
                Close();
            }
            else
            {
                mGroupBox.Text = "認証に失敗しました。";
            }
        }
Пример #2
0
        static void Main()
        {
            // 多重起動回避 ----------------------------------
            if (Process.GetProcessesByName(
                 Process.GetCurrentProcess().ProcessName).Length > 1)
            {
                MessageBox.Show("すでに起動しています!", "豆ライブ");
                Application.Exit() ;
                return;
            }

            //------------------------------------------------
            // 設定ファイルのアップグレード
            if (!Properties.Settings.Default.call_upgrade)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.call_upgrade = true;
                Properties.Settings.Default.Save();
            }

            //------------------------------------------------
            // Twitterの認証をxAuthに移行
            if (Properties.Settings.Default.tw_passwd.Length != 0 &&
                Properties.Settings.Default.tw_user.Length != 0)
            {
                Twitter tw = new Twitter();
                tw.xAuth(Properties.Settings.Default.tw_user,Properties.Settings.Default.tw_passwd);
            }

            //------------------------------------------------
            // Updater更新
            if (File.Exists("Updater-new.exe"))
            {
                File.Delete("Updater.exe");
                File.Move("Updater-new.exe", "Updater.exe");
            }

            //------------------------------------------------
            // 画面色数チェック
             			int bpp = Screen.PrimaryScreen.BitsPerPixel;
            if( bpp != 32 ) {
                MessageBox.Show("画面の色数が32ビットで無いため、正常に動作しない可能性があります","豆ライブ");
            }

            int len = Screen.AllScreens.Length;
            if ( len > 1 ) {
                if (Screen.AllScreens[len-1].BitsPerPixel != 32)
                {
                    MessageBox.Show("サブ画面の色数が32ビットで無いため、正常に動作しない可能性があります", "豆ライブ");
                }
            }

            //------------------------------------------------
            // コマンドラインから放送ID取得
            string[] args = Environment.GetCommandLineArgs();
            bool auto_connect = false;
            if (args.Count() >= 2)
            {
                string uri = "";
                if (args[1].StartsWith("lv"))
                    uri = args[1];
                else if (args[1].StartsWith("http://"))
                {
                    int idx = args[1].IndexOf("lv");
                    uri = args[1].Substring(idx);
                }
                if (uri.Length >= 0)
                {
                    Properties.Settings.Default.last_lv = uri;
                    auto_connect = true;
                }
            }
            //------------------------------------------------
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 form = new Form1();
            form.mAutoConnect = auto_connect;
            Application.Run(form);
        }
Пример #3
0
        //-------------------------------------------------------------------------
        // Twitter投稿用
        //-------------------------------------------------------------------------
        private void TwitterPoster(bool iStart)
        {
            string token = Properties.Settings.Default.tw_token;

            if (token.Length == 0 )
                return;

            Thread th = new Thread(delegate()
            {
                using (Twitter tw = new Twitter())
                {
                    bool start = iStart;

                    string msg = (start) ? Properties.Settings.Default.tw_start : Properties.Settings.Default.tw_end;

                    string uri = "http://nico.ms/" + LiveID;

                    msg = msg.Replace("@URL", uri);

                    // タイトル取得
                    if (msg.Contains("@TITLE"))
                    {
                        using (WebClient wc = new WebClient())
                        {
                            try
                            {
                                Stream stm = wc.OpenRead(uri);
                                Encoding enc = Encoding.GetEncoding("utf-8");
                                StreamReader sr = new StreamReader(stm, enc);

                                string html = sr.ReadToEnd();

                                int st = html.IndexOf("<title>");
                                int en = html.IndexOf("</title>");

                                if (st > 0 && en > 0)
                                {
                                    string title = html.Substring(st + 7, en - st - 17);
                                    if (title == null || title.Length == 0)
                                        return;
                                    msg = msg.Replace("@TITLE", title);
                                }
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine("TwWorker_DoWork:" + ex.Message);
                                return;
                            }
                        }
                    }

                    Debug.WriteLine(msg);

                    // Twitterは140文字制限
                    if (msg.Length > 140)
                    {
                        MessageBox.Show("メッセージが長すぎてTwitterにポスト出来ません。", "NicoLive");
                        mTwPost = true;
                        return;
                    }

                    // Twitterへポスト
                    if (msg.Length > 0)
                    {
                        if (tw.Post(msg, "#nicolive"))
                        {
                            mTwPost = start;
                        }
                    }
                }
            });
            th.Start();
        }