Exemplo n.º 1
0
 /// <summary>
 /// DBから指定された式を消去する
 /// </summary>
 /// <param name="n">消す数字</param>
 /// <param name="with_save">保存するか (default: true)</param>
 /// <returns>消去できたらTrue</returns>
 public bool delete(int n, bool with_save = true)
 {
     if (hdb.map.ContainsKey(n))
     {
         hdb.map.Remove(n);
         if (with_save)
         {
             JsonMgr <HanshinDB> .Save(hdb, filename);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 阪神算
        /// </summary>
        public Hanshin(string _filename = "hanshin.json")
        {
            filename = _filename;
            if (System.IO.File.Exists(filename))
            {
                hdb = JsonMgr <HanshinDB> .Load(filename);
            }
            else
            {
                hdb          = new HanshinDB();
                hdb.map      = new Dictionary <int, string>();
                hdb.map[334] = "334";
                hdb.map[29]  = "33-4";
                JsonMgr <HanshinDB> .Save(hdb, filename);
            }

            rat = new RatEvaluator();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Slack
        /// </summary>
        public SlackBot(string filename = "config.json")
        {
            if (System.IO.File.Exists(filename))
            {
                conf = JsonMgr <Config> .Load(filename);
            }
            else
            {
                var _conf = new Config();
                _conf.token              = "<YOUR BOT TOKEN HERE>";
                _conf.next_procon        = DateTime.MinValue;
                _conf.procon_notice_time = 0;
                _conf.manager_ids        = new List <string>()
                {
                    "<MANAGER USERNAME HERE>"
                };
                _conf.channels = new List <string>()
                {
                    "<CHANNEL HERE (without #)>"
                };
                _conf.procon_notice_channels = new List <string>()
                {
                    "<PROCON NOTICE CHANNEL HERE (without #)>"
                };

                JsonMgr <Config> .Save(_conf, filename);

                throw new Exception(string.Format("{0}を設定してください。", filename));
            }

            client = new SlackSocketClient(conf.token);

            channel_ids = new List <string>();
            core        = new BotCore(conf);
            IsConnected = false;

            // プロコン残り日数表通知用
            timer_procon          = new System.Timers.Timer();
            timer_procon.Interval = 1000;
            timer_procon.Elapsed += Timer_procon_Elapsed;
        }