private async void button3_Click_1(object sender, EventArgs e) { if (textBox1.Text != "") { Loading(SendMessageB, true); string notify = ""; if (NewApi.isAuthenticated()) { TLInputPeerUser iuser = null; Random rand = new Random(); string search = textBox1.Text.Trim().Replace("@", "").Replace("+", "").Replace(" ", "").ToLower(); TLUser user = await FindPeer(search); if (user != null) { TLInputPeerUser Puser = new TLInputPeerUser(); Puser.setAccessHash(user.getAccessHash()); Puser.setUserId(user.getId()); if (search == null || search == "") { search = user.getFirstName() + " " + user.getLastName(); } TLRequestMessagesSendMessage req = new TLRequestMessagesSendMessage(); req.setRandomId(rand.Next()); req.setPeer(Puser); req.setMessage(MessageTB.Text); try { //TLUpdates res = (TLUpdates)Api.doRpcCall(req); var res = await WTask.Task.Run(() => Api.doRpcCall(req)); //MessageBox.Show(string.Join(",", res)); notify = "پیام به " + search + " ارسال شد."; //NotifyBar.ForeColor = Color.Green; } catch (Exception ex) { notify = "خطا: " + ex.Message; //NotifyBar.ForeColor = Color.Red; } } } Loading(SendMessageB, false, notify); } }
private async void ForwardB_Click(object sender, EventArgs e) { if (ForwardTB.Text.Trim() != "" && textBox1.Text.Trim() != "") { Loading(ForwardB, true); string notify = ""; if (NewApi.isAuthenticated()) { TLInputPeerUser iuser = null; Random rand = new Random(); string search = textBox1.Text.Trim().Replace("@", "").Replace("+", "").Replace(" ", "").ToLower(); TLUser user = await FindPeer(search); if (user != null) { TLInputPeerUser Puser = new TLInputPeerUser(); Puser.setAccessHash(user.getAccessHash()); Puser.setUserId(user.getId()); if (search == null || search == "") { search = user.getFirstName() + " " + user.getLastName(); } string[] lines = System.Text.RegularExpressions.Regex.Split(ForwardTB.Text.Trim(), "\r\n"); long Faccess = 0; int FId = 0; TLIntVector mId = new TLIntVector(); FId = Convert.ToInt32(lines[0].Trim() + ""); Faccess = Convert.ToInt64(lines[1].Trim() + ""); mId.add(Convert.ToInt32(lines[2].Trim() + "")); TLInputPeerUser from = new TLInputPeerUser(); from.setAccessHash(Faccess); from.setUserId(FId); TLLongVector lRand = new TLLongVector(); lRand.add(rand.Next()); TLRequestMessagesForwardMessages req = new TLRequestMessagesForwardMessages(); req.setFromPeer(from); req.setToPeer(Puser); req.setId(mId); req.setRandomId(lRand); req.enableSilent(true); req.enableWithMyScore(true); try { //var res = Api.doRpcCall(req); var res = await WTask.Task.Run(() => NewApi.Api().doRpcCall(req)); notify = "پیام به " + search + " فوروارد شد."; //NotifyBar.ForeColor = Color.Green; } catch (Exception ex) { notify = "خطا: " + ex.Message; //NotifyBar.ForeColor = Color.Red; } } } Loading(ForwardB, false, notify); } }