Ejemplo n.º 1
0
        public static int Auto(User Sender, string Msg)
        {
            DatabaseHelper dbh = new DatabaseHelper(MainPlugin.MainDatabase);
            DataTable      dt  = dbh.Execute("select * from games where case_text = '" + Msg.Replace("-", "横").Replace("\"", "双引号").Replace("'", "单引号") + "'");

            if (dt.Rows.Count == 0)
            {
                dbh.Close();
                return(0);
            }
            long start_time, end_time;

            long.TryParse(dt.Rows[0]["start_time"].ToString(), out start_time);
            long.TryParse(dt.Rows[0]["end_time"].ToString(), out end_time);
            if (start_time > TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
            {
                return(0);
            }
            if (end_time < TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
            {
                return(0);
            }
            string obj = dt.Rows[0]["bouns_random"].ToString();
            int    bounsRandom = 0, faildRandom = 0;

            int.TryParse(obj, out bounsRandom);

            obj = dt.Rows[0]["faild_random"].ToString();
            int.TryParse(obj, out faildRandom);

            if (faildRandom >= new Random().Next(1, 101))
            {
                string faild_text = dt.Rows[0]["faild_text"].ToString();
                faild_text = faild_text.Replace("<use_num>", dt.Rows[0]["use_num"].ToString())
                             .Replace("<at>", Sender.AT)
                             .Replace("\\n", "\n");
                Sender.Send(faild_text);
                return(1);
            }

            SqliteHelper.SetConnectionString(MainPlugin.MainDatabase, "");
            SqliteHelper helper = new SqliteHelper();

            helper.ExecuteReader("update games set use_num = use_num + 1 where case_text = '" + Msg.Replace("-", "横").Replace("\"", "双引号").Replace("'", "单引号") + "'", new SQLiteParameter()
            {
            });

            if (bounsRandom >= new Random().Next(1, 101))
            {
                string    toDoJson = dt.Rows[0]["to_do_json"].ToString();
                ToDoModel model    = ToDoModelHelper.GetModel(toDoJson);
                Sender.Loveca        = Sender.Loveca + model.loveca;
                Sender.MandarinPoint = Sender.MandarinPoint + model.mardarin_point;
                Sender.CouponTicket  = Sender.CouponTicket + model.coupon_ticket;
                Sender.AtBanCard     = Sender.AtBanCard + model.at_ban_card;
                Sender.RandomBanCard = Sender.RandomBanCard + model.random_ban_card;
                //Sender.NoNormalScoutTicket = Sender.NoNormalScoutTicket + model.no_normal_scout_ticket;
                Sender.ScoutTicket       = Sender.ScoutTicket + model.scout_ticket;
                Sender.ElevenScoutTicket = Sender.ElevenScoutTicket + model.eleven_scout_ticket;
                string back_text_bouns = dt.Rows[0]["back_text_bouns"].ToString();
                back_text_bouns = back_text_bouns.Replace("<loveca>", model.loveca.ToString())
                                  .Replace("<point>", model.mardarin_point.ToString())
                                  .Replace("<coupon_ticket>", model.coupon_ticket.ToString())
                                  .Replace("<at_ban_card>", model.at_ban_card.ToString())
                                  .Replace("<random_ban_card>", model.random_ban_card.ToString())
                                  //.Replace("<no_normal_scout_ticket>", model.no_normal_scout_ticket.ToString())
                                  .Replace("<scout_ticket>", model.scout_ticket.ToString())
                                  .Replace("<eleven_scout_ticket>", model.eleven_scout_ticket.ToString())
                                  .Replace("<use_num>", dt.Rows[0]["use_num"].ToString())
                                  .Replace("<at>", Sender.AT)
                                  .Replace("\\n", "\n");
                Sender.Send(back_text_bouns);
                return(1);
            }
            string back_text = dt.Rows[0]["back_text"].ToString();

            back_text = back_text.Replace("<use_num>", dt.Rows[0]["use_num"].ToString())
                        .Replace("<at>", Sender.AT)
                        .Replace("\\n", "\n");
            Sender.Send(back_text);
            return(1);
        }
Ejemplo n.º 2
0
        public static int Auto(User Sender,string Msg)
        {
            if(Msg == "积分商店")
            {
                DatabaseHelper dbh = new DatabaseHelper(MainPlugin.MainDatabase);
                DataTable dt = dbh.Execute("select * from mardarin_store");
                if(dt.Rows.Count == 0)
                {
                    Sender.Send(Sender.AT + "商店暂时没有东西可以卖啦Orz");
                    dbh.Close();
                    return 1;
                }
                string toSend = " --- 积分商店 --- \n" + 
                                " ID 价格   物品";
                foreach(DataRow dr in dt.Rows)
                {
                    int num = 0;
                    string obj = "";
                    int.TryParse(dr["start_time"].ToString(), out num);
                    if(num > TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
                    {
                        continue;
                    }
                    int.TryParse(dr["end_time"].ToString(), out num);
                    if (num < TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
                    {
                        continue;
                    }
                    toSend = toSend + "\n" + dr["sid"].ToString() + " " + dr["use_points"].ToString() + "Point " + dr["title"].ToString();
                }

                Sender.Send(toSend + "\n请回复 /详情 商品ID 来查看详情");
                dbh.Close();
                return 1;
            }
            else if(Msg.IndexOf("购买") == 0)
            {
                int num = 0;
                string obj = "";
                obj = Msg.Replace("购买","");
                int.TryParse(obj, out num);
                if(num <= 0)
                {
                    Sender.Send(Sender.AT + "不存在序号为" + obj + "的商品!");
                    return 1;
                }
                DatabaseHelper dbh = new DatabaseHelper(MainPlugin.MainDatabase);
                DataTable dt = dbh.Execute("select * from mardarin_store where sid = " + num);
                if (dt.Rows.Count == 0)
                {
                    Sender.Send(Sender.AT + "不存在序号为" + obj + "的商品!");
                    dbh.Close();
                    return 1;
                }
                int.TryParse(dt.Rows[0]["start_time"].ToString(), out num);
                if (num > TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
                {
                    Sender.Send(Sender.AT + "该商品未上架!");
                    return 1;
                }
                int.TryParse(dt.Rows[0]["end_time"].ToString(), out num);
                if (num < TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
                {
                    Sender.Send(Sender.AT + "该商品已下架!");
                    return 1;
                }
                obj = dt.Rows[0]["use_points"].ToString();
                int.TryParse(obj, out num);
                if (Sender.MandarinPoint < num)
                {
                    Sender.Send(Sender.AT + "你所持的蜜柑Points不足够买这个东西!");
                    dbh.Close();
                    return 1;
                }
                Sender.MandarinPoint = Sender.MandarinPoint - num;
                string toDoJson = dt.Rows[0]["to_do_json"].ToString();
                string sendMsg = dt.Rows[0]["on_buyed_send_msg"].ToString();
                ToDoModel model = ToDoModelHelper.GetModel(toDoJson);
                Sender.Loveca = Sender.Loveca + model.loveca;
                Sender.MandarinPoint = Sender.MandarinPoint + model.mardarin_point;
                Sender.CouponTicket = Sender.CouponTicket + model.coupon_ticket;
                Sender.AtBanCard = Sender.AtBanCard + model.at_ban_card;
                Sender.RandomBanCard = Sender.RandomBanCard + model.random_ban_card;
                //Sender.NoNormalScoutTicket = Sender.NoNormalScoutTicket + model.no_normal_scout_ticket;
                Sender.ScoutTicket = Sender.ScoutTicket + model.scout_ticket;
                Sender.ElevenScoutTicket = Sender.ElevenScoutTicket + model.eleven_scout_ticket;

                Sender.Send(sendMsg);
                dbh.Close();
            }
            else if(Msg.IndexOf("详情") == 0)
            {
                int num = 0;
                string obj = "";
                obj = Msg.Replace("详情", "");
                int.TryParse(obj, out num);
                if (num <= 0)
                {
                    Sender.Send(Sender.AT + "不存在序号为" + obj + "的商品!");
                    return 1;
                }
                DatabaseHelper dbh = new DatabaseHelper(MainPlugin.MainDatabase);
                DataTable dt = dbh.Execute("select * from mardarin_store where sid = " + num);
                if (dt.Rows.Count == 0)
                {
                    Sender.Send(Sender.AT + "不存在序号为" + obj + "的商品!");
                    dbh.Close();
                    return 1;
                }
                obj = dt.Rows[0]["use_points"].ToString();
                int.TryParse(obj, out num);
                string toSendMsg = " --- 积分商店 --- ";
                toSendMsg = toSendMsg + "\n" + dt.Rows[0]["title"].ToString() + "\n" + dt.Rows[0]["description"].ToString().Replace("\\n","\n")
                    + "\n价格:" + num + "Points";
                int.TryParse(dt.Rows[0]["start_time"].ToString(), out num);
                if (num > TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
                {
                    toSendMsg = toSendMsg + "\n该商品暂未上架";
                }
                int.TryParse(dt.Rows[0]["end_time"].ToString(), out num);
                if (num < TimeStampHelper.ConvertDateTimeInt(DateTime.Now))
                {
                    toSendMsg = toSendMsg + "\n该商品现已下架";
                }
                else
                {
                    toSendMsg = toSendMsg + "\n回复 /购买" + dt.Rows[0]["sid"].ToString() + " 来购买";
                }

                Sender.Send(toSendMsg);
                dbh.Close();
            }
            return 0;
        }