public static List <GroupInfo> GetGroupList2(ICoolQApi api) { List <GroupInfo> list = new List <GroupInfo>(); try { //CQLogger.GetInstance().AddLog(string.Format("[↓][帐号] 取群列表", new object[0])); string url = "http://qun.qq.com/cgi-bin/qun_mgr/get_group_list"; var postData = new Dictionary <string, string>(); XJHTTP xJHTTP = new XJHTTP(); CookieContainer cookieContainer = xJHTTP.StringToCookie("qun.qq.com", api.GetCookies()); postData.Add("bkn", api.GetCsrfToken().ToString()); HttpResults httpResults = xJHTTP.PostHtml(url, "http://qun.qq.com/member.html", "bkn=" + api.GetCsrfToken().ToString(), false, cookieContainer, 15000); string sourceString = httpResults.Html; MyLogUtil.ToLog(httpResults.Html); var strReg = "{\"gc\":([1-9][0-9]{4,10}),\"gn\":\"(.*?)\",\"owner\":([1-9][0-9]{4,10})}"; Regex reg = new Regex(strReg); MatchCollection matches = reg.Matches(sourceString); MyJsonUtil <GroupInfo2> myJsonUtil = new MyJsonUtil <GroupInfo2>(); foreach (Match match in matches) { GroupInfo2 g = myJsonUtil.parseJsonStr(match.Value); list.Add(new GroupInfo(g.gn, g.gc, g.owner)); } } catch (Exception ex) { //MessageBox.Show(ex.Message); MyLogUtil.ErrToLog("获取群列表出现错误,原因:" + ex); } return(list); }
public static MovieConfig GetMovieJsonConfig() { string dirPath = GetDllRoot() + "MovieConfig.txt"; if (File.Exists(dirPath)) { MyJsonUtil <MovieConfig> myJsonUtil = new MyJsonUtil <MovieConfig>(); MovieConfig movieConfig = myJsonUtil.parseJsonStr(MyFileUtil.readFileAll(dirPath)); return(movieConfig); } else { return(null); } }
public static List <ResourceApiInfo> GetVipParserApiList() { string dirPath = GetDllRoot() + "VipParser.txt"; if (File.Exists(dirPath)) { MyJsonUtil <List <ResourceApiInfo> > myJsonUtil = new MyJsonUtil <List <ResourceApiInfo> >(); List <ResourceApiInfo> list = myJsonUtil.parseJsonStr(MyFileUtil.readFileAll(dirPath)); return(list); } else { return(new List <ResourceApiInfo>()); } }
/// <summary> /// 获取基础配置 /// </summary> /// <returns></returns> public static BaseJson GetBaseJsonConfig() { string dirPath = GetDllRoot() + "BaseJson.txt"; if (File.Exists(dirPath)) { MyJsonUtil <BaseJson> myJsonUtil = new MyJsonUtil <BaseJson>(); BaseJson baseJson = myJsonUtil.parseJsonStr(MyFileUtil.readFileAll(dirPath)); return(baseJson); } else { return(new BaseJson()); } }
/// <summary> /// 获取本地配置文件 /// </summary> /// <returns></returns> public static SystemConfigJson GetSystemConfigJson() { try { if (!File.Exists(GetSystemConfigJsonPath())) { return(null); } else { MyJsonUtil <SystemConfigJson> myJsonUtil = new MyJsonUtil <SystemConfigJson>(); string content = MyFileUtil.readFileAll(GetSystemConfigJsonPath()); SystemConfigJson systemConfigJson = myJsonUtil.parseJsonStr(content); return(systemConfigJson); } }catch (Exception e) { return(null); } }
private void UpdateAndSaveMovieConfig() { MovieConfig movieConfig = new MovieConfig(); movieConfig.CheckedQQQun = new Dictionary <long, int>(); //设置选中的QQ群 for (int i = 0; i < skinDataGridView1.Rows.Count; i++) { DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)this.skinDataGridView1.Rows[i].Cells[0]; if ((bool)checkBox.Value == true) { movieConfig.CheckedQQQun.Add((long)this.skinDataGridView1.Rows[i].Cells[2].Value, 1); } } //监听到群消息后,是否需要 @机器人触发命令: movieConfig.IsNeed = (radioButton1.Checked == true) ? true : false; //搜索命令 movieConfig.SearchCommand = string.IsNullOrWhiteSpace(skinTextBox2.Text)?"": skinTextBox2.Text; //未找到电影时,机器人在“群中”给用户的回复: movieConfig.NoSearchedMovieInQun = string.IsNullOrWhiteSpace(skinTextBox3.Text) ? "" : skinTextBox3.Text; //找到电影时,机器人在“群中”给用户的回复: movieConfig.HaveSearchedMovieInQun = string.IsNullOrWhiteSpace(skinTextBox6.Text) ? "" : skinTextBox6.Text; //未找到电影时,机器人“私聊”给与的回复: movieConfig.NoSearchedMovie = string.IsNullOrWhiteSpace(skinTextBox4.Text) ? "" : skinTextBox4.Text; //找到电影时,机器人“私聊”给与的回复: movieConfig.HaveSearchedMovie = string.IsNullOrWhiteSpace(skinTextBox5.Text) ? "" : skinTextBox5.Text; //是否开启私聊接受信息 movieConfig.IsCanPrivateMessage = radioButton7.Checked ? true:false; //选中的解析资源的方式 movieConfig.ConvertLinkIndex = skinComboBox1.SelectedIndex; //选择的解析器 movieConfig.SelectedParserIndex = skinComboBox2.SelectedIndex; //更新缓存数据 CacheData.MovieConfig = movieConfig; //持久化 MyJsonUtil <MovieConfig> myJsonUtil = new MyJsonUtil <MovieConfig>(); MyFileUtil.writeToFile(MySystemUtil.GetMovieJsonPath(), myJsonUtil.parseJsonObj(movieConfig)); }
internal Member Recharge(double money, long qq) { Member member = null; MyJsonUtil <Member> myJsonUtil = new MyJsonUtil <Member>(); string memberPath = MySystemUtil.GetMemberPath(qq); if (File.Exists(memberPath)) { string content = MyFileUtil.readFileAll(memberPath); member = myJsonUtil.parseJsonStr(content); //判断用户是否过期 long currentTime = Convert.ToInt64(MyDateUtil.GetTimeStamp(DateTime.Now)); if (currentTime > member.Time)//说明已经过期 { long outOfDate = currentTime + AddTime(money); member.DateDesp = MyDateUtil.ConvertStringToDateTime("" + outOfDate).ToString("yyyy-MM-dd HH:mm:ss"); member.Time = outOfDate; member.Type = 3; } else//还没有过期 { member.Time = member.Time + AddTime(money); member.DateDesp = MyDateUtil.ConvertStringToDateTime("" + member.Time).ToString("yyyy-MM-dd HH:mm:ss"); member.Type = 3; } MyFileUtil.writeToFile(memberPath, myJsonUtil.parseJsonObj(member)); } else { member = new Member(); long currentTime = Convert.ToInt64(MyDateUtil.GetTimeStamp(DateTime.Now)); long outOfDate = currentTime + AddTime(money); member.DateDesp = MyDateUtil.ConvertStringToDateTime("" + outOfDate).ToString("yyyy-MM-dd HH:mm:ss"); member.Time = outOfDate; member.Type = 3; MyFileUtil.writeToFile(memberPath, myJsonUtil.parseJsonObj(member)); } return(member); }
internal Member GetMemberDate(long fromQQ) { Member member = null; string memberPath = MySystemUtil.GetMemberPath(fromQQ); if (File.Exists(memberPath)) { MyJsonUtil <Member> myJsonUtil = new MyJsonUtil <Member>(); string content = MyFileUtil.readFileAll(memberPath); member = myJsonUtil.parseJsonStr(content); long currentTime = Convert.ToInt64(MyDateUtil.GetTimeStamp(DateTime.Now)); if (currentTime > member.Time)//说明已经过期 { member.Type = 2; } } else { member = new Member(); member.Type = 1;//1不是会员 2 会员过期 3 正常会员 } return(member); }
private BaseJson UpdateAndSaveBaseJson() { BaseJson baseJson = new BaseJson(); baseJson.Keys = new Dictionary <string, string>(); baseJson.CheckedQQQun = new Dictionary <long, int>(); //设置关键词1 if (!string.IsNullOrWhiteSpace(this.textBox1.Text) && !string.IsNullOrWhiteSpace(this.textBox2.Text) && (checkBox1.Checked || checkBox2.Checked)) { baseJson.Keys.Add(this.textBox1.Text + "-##-" + (checkBox1.Checked ? 1 : 0) + "-##-" + (checkBox2.Checked ? 1 : 0), this.textBox2.Text); } //设置关键词2 if (!string.IsNullOrWhiteSpace(this.textBox4.Text) && !string.IsNullOrWhiteSpace(this.textBox3.Text) && (checkBox4.Checked || checkBox3.Checked)) { baseJson.Keys.Add(this.textBox4.Text + "-##-" + (checkBox4.Checked ? 1 : 0) + "-##-" + (checkBox3.Checked ? 1 : 0), this.textBox3.Text); } //设置关键词3 if (!string.IsNullOrWhiteSpace(this.textBox6.Text) && !string.IsNullOrWhiteSpace(this.textBox5.Text) && (checkBox6.Checked || checkBox5.Checked)) { baseJson.Keys.Add(this.textBox6.Text + "-##-" + (checkBox6.Checked ? 1 : 0) + "-##-" + (checkBox5.Checked ? 1 : 0), this.textBox5.Text); } //设置关键词4 if (!string.IsNullOrWhiteSpace(this.textBox8.Text) && !string.IsNullOrWhiteSpace(this.textBox7.Text) && (checkBox8.Checked || checkBox7.Checked)) { baseJson.Keys.Add(this.textBox8.Text + "-##-" + (checkBox8.Checked ? 1 : 0) + "-##-" + (checkBox7.Checked ? 1 : 0), this.textBox7.Text); } //设置关键词5 if (!string.IsNullOrWhiteSpace(this.textBox10.Text) && !string.IsNullOrWhiteSpace(this.textBox9.Text) && (checkBox10.Checked || checkBox9.Checked)) { baseJson.Keys.Add(this.textBox10.Text + "-##-" + (checkBox10.Checked ? 1 : 0) + "-##-" + (checkBox9.Checked ? 1 : 0), this.textBox9.Text); } //设置选中的QQ群 for (int i = 0; i < skinDataGridView2.Rows.Count; i++) { DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)this.skinDataGridView2.Rows[i].Cells[0]; if ((bool)checkBox.Value == true) { baseJson.CheckedQQQun.Add((long)this.skinDataGridView2.Rows[i].Cells[2].Value, 1); } } //是否自动加用户入群 baseJson.IsAutoAddQun = radioButton6.Checked ? true:false; //是否自动添加好友 baseJson.IsAutoAddFriend = radioButton3.Checked ? true:false; //入群后欢迎词 baseJson.NewerEnterQun = string.IsNullOrWhiteSpace(skinTextBox1.Text)?"": skinTextBox1.Text; //更新缓存数据 CacheData.BaseJson = baseJson; //持久化 MyJsonUtil <BaseJson> myJsonUtil = new MyJsonUtil <BaseJson>(); MyFileUtil.writeToFile(MySystemUtil.GetBaseJsonPath(), myJsonUtil.parseJsonObj(baseJson)); return(baseJson); }