private void tCore_Tick(object sender, EventArgs e) { if (CheckParams()) { if (cbAutoAccept.Checked) { tRequest readyReq = Request(RestSharp.Method.GET, "/lol-matchmaking/v1/ready-check"); if (readyReq.IsAvaible()) { ReadyCheck.Root readyCheck = JsonConvert.DeserializeObject <ReadyCheck.Root>(readyReq.Content); if (readyCheck.State == "InProgress") { Request(RestSharp.Method.POST, "/lol-matchmaking/v1/ready-check/accept"); } } } if (cbTimeStatus.Checked) { tRequest chatReq = Request(RestSharp.Method.GET, "/lol-chat/v1/me"); if (chatReq.IsAvaible()) { Chat.Root chat = new Chat.Root(); chat.StatusMessage = DateTime.Now.ToString("hh:mm"); tRequest chatPutReq = Request(RestSharp.Method.PUT, "/lol-chat/v1/me", JsonConvert.SerializeObject(chat), RestSharp.DataFormat.Json); } } } }
private void MainForm_Load(object sender, EventArgs e) { if (LCU.LCU.CheckParams()) { LCU.LCU.tRequest summonerReq = LCU.LCU.Request(RestSharp.Method.GET, "/lol-summoner/v1/current-summoner"); if (summonerReq.IsAvaible()) { Summoner.Root summoner = JsonConvert.DeserializeObject <Summoner.Root>(summonerReq.Content); lblUsername.Text = summoner.DisplayName; pbProfile.ImageLocation = "http://ddragon.leagueoflegends.com/cdn/10.24.1/img/profileicon/" + summoner.ProfileIconId + ".png"; pbLevel.Value = summoner.PercentCompleteForNextLevel; pbLevel.Content = "(" + summoner.XpSinceLastLevel + "/" + summoner.XpUntilNextLevel + ")"; } LCU.LCU.tRequest walletReq = LCU.LCU.Request(RestSharp.Method.GET, "/lol-store/v1/wallet"); if (walletReq.IsAvaible()) { Wallet.Root wallet = JsonConvert.DeserializeObject <Wallet.Root>(walletReq.Content); lblBE.Text = wallet.Ip.ToString(); lblRP.Text = wallet.Rp.ToString(); } tRequest chatReq = Request(RestSharp.Method.GET, "/lol-chat/v1/me"); if (chatReq.IsAvaible()) { Chat.Root chat = JsonConvert.DeserializeObject <Chat.Root>(chatReq.Content); tbStatus.Content = chat.StatusMessage; } } }
private void btnChangeStatus_Click(object sender, EventArgs e) { if (CheckParams()) { tRequest chatReq = Request(RestSharp.Method.GET, "/lol-chat/v1/me"); if (chatReq.IsAvaible()) { Chat.Root chat = new Chat.Root(); chat.StatusMessage = tbStatus.Content; tRequest chatPutReq = Request(RestSharp.Method.PUT, "/lol-chat/v1/me", JsonConvert.SerializeObject(chat), RestSharp.DataFormat.Json); } } }
public static tRequest Request(RestSharp.Method method, string url, object parameter = null, DataFormat dataFormat = DataFormat.None) { string[] parameters = Parameters(); if (parameters[0] != null || parameters[1] != null) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Combine(ServicePointManager.ServerCertificateValidationCallback, new RemoteCertificateValidationCallback(RemoteCertificate.Certificate.CertificateObj)); RestClient restClient = new RestClient("https://127.0.0.1:" + parameters[1]) { Authenticator = new HttpBasicAuthenticator("riot", parameters[0]) }; RestRequest request = new RestRequest(url, method, dataFormat); if (parameter != null) { switch (dataFormat) { case DataFormat.None: request.AddBody(parameter); break; case DataFormat.Json: request.AddJsonBody(parameter); break; case DataFormat.Xml: request.AddXmlBody(parameter); break; } } var result = restClient.Execute(request); tRequest req = new tRequest(); req.URL = url; req.Content = result.Content; req.Status = result.StatusCode; return(req); } return(default(tRequest)); }