public static bool NetPost(string url, string param, Action <Stream> onLoad, Action <Exception> onError, string charset = "") { try { byte[] bs = Encoding.ASCII.GetBytes(param); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded" + charset; request.ContentLength = bs.Length; using (Stream reqStream = request.GetRequestStream()) { reqStream.Write(bs, 0, bs.Length); } using (WebResponse wr = request.GetResponse()) { var stream = wr.GetResponseStream(); onLoad(stream); stream.Close(); stream.Dispose(); return(true); } } catch (System.Exception e) { IRQQApi.Api_OutPutLog(e.ToString()); if (onError != null) { onError(e); } return(false); } }
public static bool NetGet(string url, Action <Stream> onLoad, Action <Exception> onError) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "GET"; using (WebResponse wr = request.GetResponse()) { var stream = wr.GetResponseStream(); onLoad(stream); stream.Close(); stream.Dispose(); return(true); } } catch (System.Exception e) { IRQQApi.Api_OutPutLog(e.ToString()); if (onError != null) { onError(e); } return(false); } }
public static void NickNameChange(string group_qq, string qq, string newName, bool check = true) { if (check && !IsInited) { return; } var person = GetPerson(group_qq, qq); if (person == null) { person = AddNewPerson(group_qq, qq); } if (person == null) { return; } person.NickName = newName; IRQQApi.Api_OutPutLog(string.Format("改名 QQ:{0}", qq)); }
public static void InitLocalization() { string path = Config.CachePath + "\\Localization.txt"; localization = new Dictionary <string, string>(); if (!File.Exists(path)) { return; } string[] lines = File.ReadAllLines(path); foreach (var line in lines) { var kv = line.Split(new string[] { "|-zxc-|" }, StringSplitOptions.RemoveEmptyEntries); localization.Add(kv[0].Trim(), kv[1].Trim()); } foreach (var kv in localization) { IRQQApi.Api_OutPutLog(kv.Key + " " + kv.Value); } IRQQApi.Api_OutPutLog("加载文本" + lines.Length.ToString() + "条"); }