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); }
/// <summary> /// 开始处理 /// </summary> /// <returns></returns> public int Run() { try { // 全群发送同一条信息 if (Msg.IndexOf("#全群通知") == 0) { if (Sender.QQ == -10000) { IEnumerable <GroupInfo> groups = ExtrasCoolApiExtensions.GetGroupList(MainPlugin.CoolQApi); string Broadcast = Msg.Replace("#全群通知", ""); foreach (GroupInfo group in groups) { User system = new User(-100000, new UserSource(UserSource.GroupMessage, new Group(group.GroupNumber), 0)); system.Send(Broadcast); } return(1); } } // 强制回收垃圾 if (Msg.IndexOf("#回收垃圾") == 0) { if (Sender.QQ == 1813274096) { GC.Collect(); Sender.Send("void GC.Collect();成功"); return(1); } } // 强制重新载入全部用户 if (Msg.IndexOf("#重载用户") == 0) { if (Sender.QQ == 1813274096) { IEnumerable <GroupInfo> info = ExtrasCoolApiExtensions.GetGroupList(MainPlugin.CoolQApi); int groups = 0, users = 0; foreach (GroupInfo inf in info) { Group gp = new Group(inf.GroupNumber); ModelWithSourceString <IEnumerable <GroupMemberInfo> > members = CoolApiExtensions.GetGroupMemberList(MainPlugin.CoolQApi, inf.GroupNumber); foreach (GroupMemberInfo i in members.Model) { User usr = new User(i.Number, new UserSource(UserSource.GroupMessage, new Group(gp.QQId), 0)); users++; } groups++; } GC.Collect(); Sender.Send("已经重新载入了" + groups + "个群," + users + "个QQ。"); return(1); } } // 如果被封禁则不处理 if (Sender.Source.Group != null) { if (Sender.Source.Group.IsBaned) { return(1); } } if (Sender.IsBaned) { return(1); } // 你群如果关了千歌不处理 if (Sender.Source.Group != null) { if (!Sender.Source.Group.IsEnable) { if (rcc(Msg) != "开千歌") { return(1); } } } // 菜单 if (Menu.AutoSend(rcc(Msg), Sender) != 0) { return(1); } // 开启千歌 if (rcc(Msg) == "开千歌") { ModelWithSourceString <GroupMemberInfo> info = CoolApiExtensions.GetGroupMemberInfoV2(MainPlugin.CoolQApi, Sender.Source.Group.QQId, Sender.QQ, false); if (info.Model.Authority == "群主" || info.Model.Authority == "管理员" || Sender.QQ == 1813274096) { Sender.Send(Sender.AT + "千歌已开启"); Sender.Source.Group.IsEnable = true; return(1); } else { Sender.Send(Sender.AT + "请管理员来进行操作"); return(1); } } // 关闭千歌 if (rcc(Msg) == "关千歌") { ModelWithSourceString <GroupMemberInfo> info = CoolApiExtensions.GetGroupMemberInfoV2(MainPlugin.CoolQApi, Sender.Source.Group.QQId, Sender.QQ, false); if (info.Model.Authority == "群主" || info.Model.Authority == "管理员" || Sender.QQ == 1813274096) { Sender.Send(Sender.AT + "千歌已关闭"); Sender.Source.Group.IsEnable = false; return(1); } else { Sender.Send(Sender.AT + "请管理员来进行操作"); return(1); } } // 群状态 if (Sender.Source.Group != null) { if (rcc(Msg) == "群状态") { Status.Auto3(Sender.Source.Group); } } // 蜜柑商店 if (MardarinStore.Auto(Sender, rcc(Msg)) != 0) { return(1); } // 小游戏 if (MiniGame.Auto(Sender, rcc(Msg)) != 0) { return(1); } // 签到 if (rcc(Msg) == "签到") { return(new Checkin(Sender).Check()); } // 抛锦球 if (ThrowBall.Auto(Sender, rcc(Msg)) == 1) { return(1); } // 状态 if (rcc(Msg) == "状态") { return(Status.Auto(Sender)); } if (rcc(Msg) == "我的状态") { return(Status.Auto2(Sender)); } // 档线 if (rcc(Msg) == "档线") { return(Yohane.StopLine.Auto(Sender)); } // 转账 if (Transfer.Auto(Sender, rcc(Msg)) == 1) { return(1); } // "Sudo" if (Sender.QQ == 1813274096) { if (rcc(Msg).IndexOf("sudo") == 0) { string[] parm = Msg.Split('|'); if (parm.Length >= 3) { int num = 0; int.TryParse(parm[1], out num); Command cmd = new Command(parm[2], new User(num, Sender.Source), TimeStampHelper.ConvertDateTimeInt(DateTime.Now).ToString()); return(cmd.Run()); } } } // 抽卡 if (ScoutSimulator.Msg.Auto(Sender, rcc(Msg)) != 0) { return(1); } // 抽奖 if (Lottery.Auto(Sender, rcc(Msg)) != 0) { return(1); } // 鸽服号状态 if (SIF.CN.Status.Auto(Sender, rcc(Msg)) != 0) { return(1); } // 算运势 if (rcc(Msg) == "算运势") { return(Divination.Auto(Sender)); } // 点歌 if (rcc(Msg).IndexOf("网易点歌") == 0) { return(ChooseSong.Choose.Auto(Sender, rcc(Msg))); } // 算日美ID #region /*long getRF_id = 0; * if (Msg.Length == 12) * { * if (long.TryParse(Msg.Replace("算账号",""), out getRF_id) == true) * { * getRF_id = getRF_id * 526850996; * getRF_id = getRF_id % 999999937; * Sender.Send(Sender.AT + "Uid: " + Msg.Replace("算账号", "") + "\n" + * "Id: " + getRF_id); * return 1; * } * else * { * MessageSendHelper.Send(Sender, " × 计算失败!以下是狗开发的一点人生经验:\n - 不支持国服\n - 文本格式不对\n - 数值转换错误"); * return 1; * } * } * else * { * MessageSendHelper.Send(Sender, " × 计算失败!以下是狗开发的一点人生经验:\n - 不支持国服\n - 文本格式不对\n - 未知"); * return 1; * }*/ #endregion // 聊天解析Beta if (Chat.Msg.Auto(Sender, Msg) != 0) { return(1); } } catch (Exception ex) { Logger.Log ("Ex:" + ex.Message, Logger.WARN, new long[] { }, 0); Sender.Send("ChikaBot Test System\n错误信息 " + ex.Message + "\n错误来源 " + ex.Source + "\n错误堆叠 " + ex.StackTrace); //ExceptionReportHelper.Send("消息处理", Sender, ex, Msg); //Sender.Send(" × 千歌酱出了一个Bug, 暂时不能陪你玩了...\n 错误类型:" + ex.GetType().ToString()); } return(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; }
public static int Auto(User Sender, string Msg) { if (Msg == "抽奖") { if (Sender.MandarinPoint < 500) { Sender.Send("你的蜜柑Points不足500!"); return(1); } Sender.MandarinPoint = Sender.MandarinPoint - 500; Random rd = new Random(); int num = rd.Next(1, 10000); if (num == 1) { if (rd.Next(1, 10000) == 1) { Sender.Send(Sender.AT + "恭喜你中了Loveca * 1~这颗Loveca可以在 国服 日服 美服兑换,请联系Q柚兑换吧~"); Command cmd = new Command("#全群通知恭喜" + Sender.QQ + "抽奖中了一颗SIF中的Loveca~", new User(-10000, new UserSource(UserSource.GroupMessage, Sender.Source.Group, 0)), TimeStampHelper.ConvertDateTimeInt(DateTime.Now).ToString()); new User(1813274096, new UserSource(UserSource.PrivateMessage, null, 0)).Send(Sender.QQ + "获得了一颗Loveca,请及时兑换"); return(1); } else { num = rd.Next(1, 10000); } } else if (num > 1 && num <= 500) { Sender.Send(Sender.AT + " 获得绿卷一张~已发送到你的背包~"); Sender.ScoutTicket++; return(1); } else if (num > 500 && num <= 2000) { Sender.Send(Sender.AT + " 获得Loveca一块,这个Loveca只能在机器人内使用!"); Sender.Loveca++; return(1); } else if (num > 2000 && num <= 4000) { Sender.Send(Sender.AT + " 获得蜜柑Poins × 500点~已发送到你的背包~"); Sender.MandarinPoint = Sender.MandarinPoint + 500; return(1); } else if (num > 4000 && num <= 7000) { Sender.Send(Sender.AT + " 获得蜜柑Points × 100点~已发送到你的背包~"); Sender.MandarinPoint = Sender.MandarinPoint + 100; return(1); } else { Sender.Send(Sender.AT + " 什么都没得到哦~"); return(1); } } return(0); }