Exemplo n.º 1
0
 public frmRegister()
 {
     InitializeComponent();
     ServicePointManager.Expect100Continue = false;
     ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation;
     this.WaInstance = new WhatsAppApi.WhatsApp(string.Empty, string.Empty, string.Empty);
 }
Exemplo n.º 2
0
 public frmRegister()
 {
     InitializeComponent();
     ServicePointManager.Expect100Continue = false;
     ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation;
     this.WaInstance = new WhatsAppApi.WhatsApp(string.Empty, string.Empty, string.Empty);
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            bool res = processArgs(args);

            if (!res)
            {
                printHelp();
                return;
            }

            Instance = new WhatsAppApi.WhatsApp(Username, Password, "WhatsApp", Debug, true);
            if (Debug)
            {
                WhatsAppApi.Helper.DebugAdapter.Instance.OnPrintDebug += Instance_OnPrintDebug;
            }
            Instance.OnError         += Instance_OnError;
            Instance.OnGetSyncResult += Instance_OnGetSyncResult;
            Instance.Connect();
            Instance.Login();
            if (Instance.ConnectionStatus == WhatsAppApi.ApiBase.CONNECTION_STATUS.LOGGEDIN)
            {
                //logged in
                Instance.SendSync(Numbers, Mode, Context);

                while (Instance.pollMessage(false))
                {
                    ;
                }
            }
            else
            {
                Console.WriteLine("Login failed: {0}", Instance.ConnectionStatus);
            }
        }
Exemplo n.º 4
0
 public frmUserChat(WhatsAppApi.WhatsApp whats, User user)
 {
     InitializeComponent();
     this.whatsApp = whats;
     this.user     = user;
     this.isTyping = false;
     WhatsEventHandler.MessageRecievedEvent += WhatsEventHandlerOnMessageRecievedEvent;
     WhatsEventHandler.IsTypingEvent        += WhatsEventHandlerOnIsTypingEvent;
 }
Exemplo n.º 5
0
        public static string ISendMessage(string to, string txt)
        {
            var tmpMessage = new FMessage(GetJID(to), true)
            {
                data = txt
            };

            WhatsAppApi.WhatsApp wa = new WhatsAppApi.WhatsApp();
            wa.SendMessage(tmpMessage, wa.hidden);
            return(tmpMessage.identifier_key.ToString());
        }
Exemplo n.º 6
0
        protected void SendMessaggioWhatsApp(string messaggio)
        {
            WhatsAppApi.WhatsApp wa = new WhatsAppApi.WhatsApp("+39 3492240520", "", "GratisForGratis", false, false);
            wa.OnConnectSuccess += () =>
            {
                Response.Write("connect");
                wa.OnLoginSuccess += (phno, data) =>
                {
                    wa.SendMessage("+39 3492240520", messaggio);
                };

                wa.OnLoginFailed += (data) =>
                {
                    Response.Write("login failed" + data);
                };
                wa.Login();
            };
            wa.OnConnectFailed += (ex) =>
            {
                Response.Write("connection failed");
            };
        }
Exemplo n.º 7
0
        private void btnsendfile_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            //dialog.Filter = "Text files | *.txt"; // file types, that will be allowed to upload
            dialog.Multiselect = false;                 // allow/deny user to upload more than one file at a time
            if (dialog.ShowDialog() == DialogResult.OK) // if user clicked OK
            {
                String path = dialog.FileName;          // get name of file
                string type = path.Substring(path.Length - 3);
                type = type.ToUpper();
                if (type.Contains("JPG") || type.Contains("GIF") || type.Contains("PNG"))

                {
                    System.Drawing.Image image = System.Drawing.Image.FromFile(path);
                    //yasodha
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                    byte[] imginbytes       = ms.ToArray();
                    WhatsAppApi.WhatsApp wa = new WhatsAppApi.WhatsApp();
                    //string to = "919177556688";
                    WhatsAppApi.WhatsApp.ImageType imp = new  WhatsAppApi.WhatsApp.ImageType();
                    WhatSocket.Instance.SendMessageImage(this.user.WhatsUser.GetFullJid(), imginbytes, imp);
                }
                else
                {
                    byte[]     videoinbytes = null;
                    FileStream fs           = new FileStream(path,
                                                             FileMode.Open,
                                                             FileAccess.Read);
                    BinaryReader br       = new BinaryReader(fs);
                    long         numBytes = new FileInfo(path).Length;
                    videoinbytes = br.ReadBytes((int)numBytes);
                    WhatsAppApi.WhatsApp.VideoType vid = new WhatsAppApi.WhatsApp.VideoType();
                    WhatSocket.Instance.SendMessageVideo(this.user.WhatsUser.GetFullJid(), videoinbytes, vid);
                }
            }
        }
Exemplo n.º 8
0
        public static void ChekWALoginMy(DataRow dr, DataMy dt)
        {
            Int32   ok = 1;
            Int32   no = 0;
            decimal iiii;
            Int32   i = Convert.ToInt32(dr[0].ToString());

            dr[1] = dr[1].ToString().Replace("+", "");
            dr[1] = dr[1].ToString().Replace("-", "");
            dr[1] = dr[1].ToString().Replace("(", "");
            dr[1] = dr[1].ToString().Replace(")", "");
            dr[1] = dr[1].ToString().TrimStart(new char[] { '0' });
            // MessageBox.Show(dr[1].ToString()+"Первый");
            decimal.TryParse(dr[1].ToString().Trim(), out iiii);
            if (iiii <= 0)
            {
                return;
            }
            if (i >= 0 && i < 2147483647)
            {
                //  MessageBox.Show(dr[1].ToString()+"Второй"+iiii.ToString());
                string namber = dr[1].ToString() ?? " ";
                //WhatsAppApi.Parser.PhoneNumber pn =new WhatsAppApi.Parser.PhoneNumber(namber);
                string passWord         = dr[2].ToString() ?? " ";
                string nik              = dr[3].ToString() ?? " ";
                WhatsAppApi.WhatsApp wa = new WhatsAppApi.WhatsApp(namber, passWord, nik);

                wa.OnConnectSuccess += () =>
                {
                    // MessageBox.Show("Присоеденились");
                    wa.OnLoginSuccess += (phoneNumber, data) =>
                    {
                        MessageBox.Show("Залогинились");
                        dt.UpdateIsActive(i, ok);
                        dt.UpdateEror(i, " ");
                        dt.UpdateDateLastLogin(i, LogicMy.dtToUnix(DateTime.Now));
                    };
                    wa.OnLoginFailed += (data) =>
                    {
                        MessageBox.Show("Не удалось залогиниться: " + data);
                        dt.UpdateIsActive(i, no);
                        dt.UpdateEror(i, data.ToString());
                        dt.UpdateDateBlock(i, LogicMy.dtToUnix(DateTime.Now));
                    };
                    wa.OnError += (id, from, code, text) =>
                    {
                        dt.UpdateIsActive(i, no);
                        dt.UpdateEror(i, id + " : " + @from + " : " + code + " : " + text);
                        MessageBox.Show(id + " : " + from + " : " + code + " : " + text);
                    };
                    wa.Login();
                };
                wa.OnConnectFailed += (ex) =>
                {
                    MessageBox.Show("Не удалось присоедениться");
                    dt.UpdateEror(i, ex.Message);
                };
                wa.Connect();
                wa.Disconnect();
            }
        }
Exemplo n.º 9
0
 public static void Create(string username, string password, string nickname, bool debug = false)
 {
     _instance = new WhatsAppApi.WhatsApp(username, password, nickname, debug);
 }
Exemplo n.º 10
0
 public static void Create(string username, string password, string nickname, bool debug = false)
 {
     _instance = new WhatsAppApi.WhatsApp(username, password, nickname, debug);
 }
Exemplo n.º 11
0
 public static void Create(string username, string password, string nickname, bool debug = false)
 {
     _instance = new WhatsAppApi.WhatsApp(username, password, nickname, debug);
     _instance.OnProcessMessageException += OnProcessMessageExceptionEvent;
 }