public void Stop() { _listen = false; thRecv.Abort(); wa.Disconnect(); wa.OnLoginSuccess -= wa_OnLoginSuccess; wa.OnLoginFailed -= wa_OnLoginFailed; wa.OnGetMessage -= wa_OnGetMessage; wa.OnGetMessageReceivedClient -= wa_OnGetMessageReceivedClient; wa.OnGetMessageReceivedServer -= wa_OnGetMessageReceivedServer; wa.OnNotificationPicture -= wa_OnNotificationPicture; wa.OnGetPresence -= wa_OnGetPresence; wa.OnGetGroupParticipants -= wa_OnGetGroupParticipants; wa.OnGetLastSeen -= wa_OnGetLastSeen; wa.OnGetTyping -= wa_OnGetTyping; wa.OnGetPaused -= wa_OnGetPaused; wa.OnGetMessageImage -= wa_OnGetMessageImage; wa.OnGetMessageAudio -= wa_OnGetMessageAudio; wa.OnGetMessageVideo -= wa_OnGetMessageVideo; wa.OnGetMessageLocation -= wa_OnGetMessageLocation; wa.OnGetMessageVcard -= wa_OnGetMessageVcard; wa.OnGetPhoto -= wa_OnGetPhoto; wa.OnGetPhotoPreview -= wa_OnGetPhotoPreview; wa.OnGetGroups -= wa_OnGetGroups; wa.OnGetSyncResult -= wa_OnGetSyncResult; wa.OnGetStatus -= wa_OnGetStatus; wa.OnGetPrivacySettings -= wa_OnGetPrivacySettings; DebugAdapter.Instance.OnPrintDebug -= Instance_OnPrintDebug; wa = null; _queue.PeekCompleted -= new PeekCompletedEventHandler(OnPeekCompleted); _queue.ReceiveCompleted -= new ReceiveCompletedEventHandler(OnReceiveCompleted); }
public void Stop() { _listen = false; wa.Disconnect(); wa_1.Disconnect(); _queue.PeekCompleted -= new PeekCompletedEventHandler(OnPeekCompleted); _queue.ReceiveCompleted -= new ReceiveCompletedEventHandler(OnReceiveCompleted); }
private static void Main(string[] args) { var tmpEncoding = Encoding.UTF8; System.Console.OutputEncoding = Encoding.Default; System.Console.InputEncoding = Encoding.Default; string nickname = "WhatsAPI Test"; string sender = "3526********"; // Mobile number with country code (but without + or 00) string password = "******"; //v2 password string target = "316********"; // Mobile number to send the message to WhatsApp wa = new WhatsApp(sender, password, nickname, true); wa.Connect(); wa.Login(); wa.sendNickname(nickname); wa.Disconnect(); wa.PresenceSubscription(target); wa.GetStatus(target); ProcessChat(wa, ""); Console.ReadKey(); }
public void Stop() { if (waClient != null && waClient.ConnectionStatus != ApiBase.CONNECTION_STATUS.DISCONNECTED) { waClient.Disconnect(); } }
private string SendWhats() { // Moto G dual chip // 353334061452427 // 353334061452435 string imei = "353334061452435"; //My IMEI //string imei = "00c9caf9c2ca86b624d3defcf199d4f1"; //My IMEI //WhatsApp me = new WhatsApp(sender, imei, nickname, true); WhatsApp me = null; using (MD5 md5Hash = MD5.Create()) { String corrected = new string(imei.ToCharArray()); string hash1 = GetMd5Hash(md5Hash, "353334061452427"); // IMEI SIM CLARO string hash2 = GetMd5Hash(md5Hash, "353334061452435"); // IMEI SIM TIM string hash3 = GetMd5Hash(md5Hash, "Android9589"); // Senha WART me = new WhatsApp("5521995891097", hash1, "API Test", true); me.Connect(); me.Login(); //Response.Write(me.Login(null) + " | "); //Response.Write(me.Login(md5Hash.ComputeHash(Encoding.Unicode.GetBytes(hash3))) + " | "); // byte[] b = { // getByte("00"), getByte("c9"), getByte("ca"), getByte("f9"), // getByte("c2"), getByte("ca"), getByte("86"), getByte("b6"), // getByte("24"), getByte("d3"), getByte("de"), getByte("fc"), // getByte("f1"), getByte("99"), getByte("d4"), getByte("f1") }; // me.Login(b); } //using (MD5 md5Hash = MD5.Create()) //{ // string hash1 = GetMd5Hash(md5Hash, "353334061452427"); // string hash2 = GetMd5Hash(md5Hash, "353334061452435"); // //string hashs = "00c9caf9c2ca86b624d3defcf199d4f1"; // //me.Login(md5Hash.ComputeHash(Encoding.UTF8.GetBytes(imei))); //} Response.Write(me.ConnectionStatus + " | "); // I get a Connection! Response.Write(me.SendMessage("5521969476360", "Amor! Retorna")); // Send Message //No Message received :( me.Disconnect(); return(""); }
private void signOutToolStripMenuItem_Click(object sender, EventArgs e) { signOutToolStripMenuItem.Visible = false; wa.Disconnect(); panel2.Enabled = false; panel1.Enabled = true; panel1.BringToFront(); }
private void btnImage_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "PNG|*.png|JPG|*.jpg|*GIF|*.gif", ValidateNames = true, Multiselect = false }) { if (ofd.ShowDialog() == DialogResult.OK) { fileName = ofd.FileName; index = ofd.FilterIndex; lblPath.Text = string.Format("Path: {0}", ofd.FileName); // timer.Stop(); wa.Disconnect(); Thread.Sleep(3000); wa.Connect(); wa.Login(); } } }
public override void Dispose() { _wa.Disconnect(); }
private bool SendEmailNotification(string[] listEmail) { bool answer = false; var emailEmpresa = "*****@*****.**"; string dateCurrent = DateTime.Now.ToString("yyyy-MM-dd"); for (int i = 0; i < listEmail.Length; i++) { var row = listEmail[i].Split('|'); if (row.Length > 3) { string description = row[0]; string date = row[1]; decimal amount = decimal.Parse(row[2]); string name = row[3]; string lastName = row[4]; string emailUser = row[5]; string pin = row[6]; string phoneuser = row[7]; string currencycode = row[8]; decimal amountUsd = decimal.Parse(row[9]); if (currencycode == "USD") { amount = amountUsd; } MyMessages mm = new MyMessages(); Email email = new Email(); Numalet numalet = new Numalet(); MyFunctions mf = new MyFunctions(); string body = mm.EmailDebePagar(description, date, amount, name, lastName, numalet.ToCustomCardinal(amount), dateCurrent, pin, currencycode); answer = email.SendEmail(emailUser, "PAGOS EN INRESORTS", body, true); answer = email.SendEmail(emailEmpresa, "PAGOS EN INRESORTS", body, true); string error = ""; WhatsApp whatsApp = new WhatsApp("51942953243", "", "INRESORTS", false, false); whatsApp.OnConnectSuccess += () => { whatsApp.OnLoginSuccess += (phone, data) => { whatsApp.SendMessage("51969542529", "prueba de envio"); }; whatsApp.OnLoginFailed += (data) => { error = data; }; }; whatsApp.OnConnectFailed += (ex) => { error = ex.Message; }; whatsApp.Connect(); string vencio = "vencerá"; if (DateTime.Parse(date) < DateTime.Now) { vencio = "venció"; } string mess = $"Hola {name} te queremos recordar que el dia {mf.DateFormatClient(date)} {vencio} tu {description} de Monto {amount.ToString()} {currencycode}. Saludos Inresorts"; phoneuser = phoneuser.Replace("+", ""); string sen = whatsApp.SendMessage(phoneuser, mess); string sen2 = whatsApp.SendMessage("+51938627011", mess); string url = $"<a target='_blank' href='https://api.whatsapp.com/send?phone={phoneuser}&text={mess}'>{name}</a> | "; ListMessaggeWhatsapp.Text += url; whatsApp.Disconnect(); } } return(answer); }