コード例 #1
0
        public void setEmgEvent(List <Event> EventList)
        {
            pso2Event.Clear();

            foreach (Event evn in EventList)
            {
                Event tmp;

                if (evn is emgQuest)
                {
                    emgQuest emgTmp = evn as emgQuest;
                    tmp = new emgQuest(emgTmp.eventTime, emgTmp.eventName, emgTmp.live, emgTmp.liveEnable);
                    pso2Event.Add(tmp);
                }
                else
                {
                    if (evn is casino)
                    {
                        //casino cas = evn as casino;
                        tmp = new casino(evn.eventTime);
                        pso2Event.Add(tmp);
                    }
                    else
                    {
                        //エラー
                        System.Console.WriteLine("なにかがおかしい");
                    }
                }
            }

            //pso2Event.Sort((a, b) => (a.eventTime - b.eventTime).Seconds);
            setNextEmg();
            calcNextNofity();
        }
コード例 #2
0
        public List <Event> getTodayEmg()    //今日の緊急クエスト一覧を取得
        {
            DateTime dt     = DateTime.Now;
            TimeSpan OneDay = new TimeSpan(24, 0, 0);

            DateTime toDay00 = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0);
            DateTime toDay01 = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0) + OneDay;

            List <Event> output = new List <Event>();

            foreach (Event ev in pso2Event)
            {
                if (DateTime.Compare(ev.eventTime, toDay00) >= 0 && DateTime.Compare(ev.eventTime, toDay01) < 0)
                {
                    if (ev is emgQuest)
                    {
                        emgQuest tmp = (emgQuest)ev;
                        output.Add(new emgQuest(tmp.eventTime, tmp.eventName, tmp.live, tmp.liveEnable));
                    }

                    if (ev is casino)
                    {
                        casino tmp = (casino)ev;
                        output.Add(new casino(tmp.eventTime));
                    }
                }
            }

            return(output);
        }
コード例 #3
0
        public void addEmg(emgQuest emg)    //緊急クエストの追加
        {
            pso2Event.Add(emg);

            pso2Event.Sort((a, b) => (int)(a.eventTime - b.eventTime).TotalSeconds);

            string emgname = myFunction.getLiveEmgStr(emg);

            logOutput.writeLog("緊急クエスト「{0}」を{1}に追加しました。", emgname, emg.eventTime.ToString("MM/dd HH:mm"));
            setNextEmg();
            calcNextNofity();
        }
コード例 #4
0
        static public string getLiveEmgStr(emgQuest e, string section = "->")    //クーナライブがある時に使う
        {
            if (e.liveEnable == true)
            {
                if (Regex.IsMatch(e.live, "^クーナスペシャルライブ「.*」") == true) //他のライブの時は無理
                {
                    //もっといい方法がありそう
                    string str = Regex.Replace(e.live, "^クーナスペシャルライブ「", "");
                    str = Regex.Replace(str, "」$", "");
                    return(string.Format("{0}{1}{2}", str, section, e.eventName));
                }
                else
                {
                    return(string.Format("{0}{1}{2}", e.live, section, e.eventName));
                }
            }

            return(e.eventName);
        }
コード例 #5
0
        public string outputBufferEmg()
        {
            string output = "";

            int count = 0;

            foreach (Event ev in pso2EventBuffer)
            {
                if (ev is emgQuest)
                {
                    emgQuest emg = (emgQuest)ev;
                    if (emg.liveEnable == true)
                    {
                        DateTime livetime = emg.eventTime - new TimeSpan(0, 30, 0);

                        output += string.Format("({0:00}/{1:00} {2:00}:{3:00}){4}\n", livetime.Month, livetime.Day, livetime.Hour, livetime.Minute, emg.live);
                        output += string.Format("({0:00}/{1:00} {2:00}:{3:00}){4}", emg.eventTime.Month, emg.eventTime.Day, emg.eventTime.Hour, emg.eventTime.Minute, emg.eventName);
                    }
                    else
                    {
                        output += string.Format("({0:00}/{1:00} {2:00}:{3:00}){4}", ev.eventTime.Month, ev.eventTime.Day, ev.eventTime.Hour, ev.eventTime.Minute, ev.eventName);
                    }
                }
                else
                {
                    output += string.Format("({0:00}/{1:00} {2:00}:{3:00}){4}", ev.eventTime.Month, ev.eventTime.Day, ev.eventTime.Hour, ev.eventTime.Minute, ev.eventName);
                }

                if (count != pso2EventBuffer.Count - 1)
                {
                    output += "\n";
                }

                count++;
                //output += Environment.NewLine;
            }

            return(output);
        }
コード例 #6
0
        public override void reloadPSO2Event()
        {
            //取得する緊急クエストの日数を計算
            DateTime dt = DateTime.Now;

            int getDays = 7 - ((int)dt.DayOfWeek + 4) % 7;                            //この先の緊急を取得する日数

            if (getDays == 7)                                                         //水曜日の時
            {
                DateTime dt1630 = new DateTime(dt.Year, dt.Month, dt.Day, 17, 00, 0); //今日の17:00
                if (DateTime.Compare(dt, dt1630) <= 0)
                {
                    getDays = 0;
                }
            }

            //バッファの初期化など
            if (base.pso2EventBuffer.Count != 0)
            {
                base.pso2EventBuffer.Clear();
            }

            //緊急クエスト取得成功・失敗の結果
            bool getOK = true;

            //緊急クエストの取得
            for (int i = 0; i <= getDays; i++)
            {
                DateTime getEmgTime = dt + new TimeSpan(i, 0, 0, 0);

                //JSONを生成
                sendjson_eventgetter jsonData = new sendjson_eventgetter();
                jsonData.EventDate = getEmgTime.ToString("yyyyMMdd");
                string data = JsonConvert.SerializeObject(jsonData, Formatting.Indented);

                //HTTPによる取得
                StringContent sc = new StringContent(data, encode, "application/json");

                Task <string> resultHTTP;
                try
                {
                    resultHTTP = AsyncHttpPOST(sc);
                    resultHTTP.Wait();
                }
                catch (System.NullReferenceException)
                {
                    break;
                }

                //結果をstringにする

                /*
                 * Task<string> resultStrTask;
                 * try
                 * {
                 *  resultStrTask = resultHTTP.Result.Content.ReadAsStringAsync();
                 * }
                 * catch(System.NullReferenceException)    //緊急クエストの取得に失敗
                 * {
                 *  break;
                 * }
                 * resultStrTask.Wait();
                 */
                string result = resultHTTP.Result;

                //Jsonをパース
                List <JsonPSO2Event> Jsonresult = new List <JsonPSO2Event>();
                Jsonresult = JsonConvert.DeserializeObject <List <JsonPSO2Event> >(result);

                //バッファに格納
                bool   live     = false;
                string livename = "";

                foreach (JsonPSO2Event ev in Jsonresult)
                {
                    DateTime emgDT = new DateTime(DateTime.Now.Year, ev.Month, ev.Date, ev.Hour, ev.Minute, 0);

                    if (ev.EventType == "緊急")
                    {
                        emgQuest emg;
                        if (live == true)
                        {
                            emg      = new emgQuest(emgDT, ev.EventName, livename);
                            live     = false;
                            livename = "";
                        }
                        else
                        {
                            emg = new emgQuest(emgDT, ev.EventName);
                        }
                        base.pso2EventBuffer.Add(emg);
                    }

                    if (ev.EventType == "ライブ")
                    {
                        live     = true;
                        livename = ev.EventName;
                    }

                    if (ev.EventType == "カジノイベント")
                    {
                        casino cas = new casino(emgDT);
                        base.pso2EventBuffer.Add(cas);
                    }
                }
            }

            if (getOK == true)
            {
                logOutput.writeLog("緊急クエストの情報を取得しました。緊急クエストは以下の通りです。\n" + outputBufferEmg());
            }
        }
コード例 #7
0
        public void commandProcess(string command, string[] args)
        {
            if (command == "stop" || command == "exit" || command == "quit")   //停止
            {
                saveConfig();
                end = true;
            }

            if (command == "reload") //再取得
            {
                admin.getEmgFromNet();
            }

            if (command == "post")
            {
                if (args.Length == 1)
                {
                    string postEnc = convertCode(args[0], Console.InputEncoding, Encoding.UTF8);
                    service.sendService(postEnc);
                }
            }

            if (command == "rodos") //バル・ロドス通知設定関連
            {
                if (args.Length == 1)
                {
                    bool modify = false;

                    if (args[0] == "true" || args[0] == "1" || args[0] == "yes" || args[0] == "y" || args[0] == "enable")
                    {
                        bot.rodos = true;
                        logOutput.writeLog("デイリーバル・ロドス討伐(VH)の通知は有効にしました。");
                        modify = true;
                    }

                    if (args[0] == "false" || args[0] == "0" || args[0] == "no" || args[0] == "n" || args[0] == "disable")
                    {
                        bot.rodos = false;
                        logOutput.writeLog("デイリーバル・ロドス討伐(VH)の通知は無効にしました。");
                        modify = true;
                    }

                    if (modify == false)
                    {
                        System.Console.WriteLine("値が不正です。");
                    }
                }
                else
                {
                    if (bot.rodos == true)
                    {
                        System.Console.WriteLine("デイリーバル・ロドス討伐(VH)の通知は有効です。");
                    }
                    else
                    {
                        System.Console.WriteLine("デイリーバル・ロドス討伐(VH)の通知は無効です。");
                    }
                }
            }

            if (command == "url")
            {
                if (args.Length == 1)
                {
                    service.url = args[0];
                    logOutput.writeLog(string.Format("Discord WebHooks URLを{0}に変更しました。", args[0]));
                }
                else
                {
                    System.Console.WriteLine(service.url);
                }
            }

            if (command == "list") //緊急クエストの表示
            {
                string str = myFunction.EmgArrStrNumbered(admin.getPSO2Event());
                System.Console.WriteLine(str);
            }

            if (command == "rm" || command == "del" || command == "delete")
            {
                if (args.Length == 1)
                {
                    int  number    = 0;
                    bool enableDel = int.TryParse(args[0], out number);

                    if (enableDel == true)
                    {
                        admin.delPSO2Event(number - 1);
                    }
                }
                else
                {
                    System.Console.WriteLine("引数が不正です。");
                }
            }

            if (command == "add")
            {
                if (args.Length != 5 && args.Length != 6)
                {
                    System.Console.WriteLine("引数の数が違います。");
                    return;
                }

                bool monthEnable = false;
                bool dayEnable   = false;
                bool hourEnable  = false;
                bool minEnable   = false;

                int    month = 0;
                int    day   = 0;
                int    hour  = 0;
                int    min   = 0;
                string name  = "";

                monthEnable = int.TryParse(args[0], out month);
                dayEnable   = int.TryParse(args[1], out day);
                hourEnable  = int.TryParse(args[2], out hour);
                minEnable   = int.TryParse(args[3], out min);
                name        = args[4];

                if ((monthEnable && dayEnable && hourEnable && minEnable) == false)
                {
                    System.Console.WriteLine("値が不正です。");
                    return;
                }

                DateTime time = new DateTime(DateTime.Now.Year, month, day, hour, min, 0);

                if ((time - DateTime.Now).TotalSeconds < 0) //過去の時間の場合は1年追加
                {
                    time += new TimeSpan(365, 0, 0, 0);
                }

                if (args.Length == 5)
                {
                    emgQuest em = new emgQuest(time, name);
                    admin.addEmg(em);
                }

                if (args.Length == 6)
                {
                    string   live = args[5];
                    emgQuest em   = new emgQuest(time, name, live);
                    admin.addEmg(em);
                }
            }

            if (command == "hasha")
            {
                bool ok = false;
                if (args.Length == 0)
                {
                    if (bot.chp == true)
                    {
                        logOutput.writeLog("覇者の紋章通知は有効です。");
                        ok = true;
                    }
                    else
                    {
                        logOutput.writeLog("覇者の紋章通知は無効です。");
                        ok = true;
                    }
                }
                if (args.Length == 1)
                {
                    if (args[0] == "true" || args[0] == "1" || args[0] == "yes" || args[0] == "y" || args[0] == "enable")
                    {
                        bot.chp = true;
                        logOutput.writeLog("覇者の紋章通知を有効にしました。");
                        ok = true;
                    }

                    if (args[0] == "false" || args[0] == "0" || args[0] == "no" || args[0] == "n" || args[0] == "disable")
                    {
                        bot.chp = false;
                        logOutput.writeLog("覇者の紋章通知を無効にしました。");
                        ok = true;
                    }

                    if (args[0] == "list")
                    {
                        logOutput.writeLog("覇者の紋章通知時間は以下の通りです。\n{0}", admin.getChpList());
                        ok = true;
                    }

                    if (args[0] == "reload")
                    {
                        logOutput.writeLog("覇者の紋章キャンペーンの情報を取得します。");
                        admin.getChanpionFromNet();
                        ok = true;
                    }
                }

                if (args.Length == 2)
                {
                    if (args[0] == "csvfile")
                    {
                        chpFile = args[1];
                        logOutput.writeLog("{0}から覇者の紋章通知時間を読み込みます。", args[1]);
                        admin.setChpTimeList(args[1]);

                        if (bot.chp == false)
                        {
                            System.Console.WriteLine("覇者の紋章通知は無効です。「hasha enable」コマンドで有効にしてください。");
                        }

                        ok = true;
                    }
                }

                if (ok == false)
                {
                    System.Console.WriteLine("値が不正です。");
                }
            }

            if (command == "help")
            {
                outputHelp();
            }

            if (command == "version")
            {
                outputVersion();
            }


            /*
             * if(command == "debug")
             * {
             *  admin.debug = true;
             * }
             */
        }