Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            client = new Client();
            qrForm = new QrCodeForm();

            client.ExceptionCatched           += Client_ExceptionCatched;;
            client.GetLoginQrCodeComplete     += Client_GetLoginQrCodeComplete;;
            client.CheckScanComplete          += Client_CheckScanComplete;;
            client.LoginComplete              += Client_LoginComplete;;
            client.BatchGetContactComplete    += Client_BatchGetContactComplete;;
            client.GetContactComplete         += Client_GetContactComplete;;
            client.MPSubscribeMsgListComplete += Client_MPSubscribeMsgListComplete;;
            client.LogoutComplete             += Client_LogoutComplete;;
            client.ReceiveMsg             += Client_ReceiveMsg;;
            client.DelContactListComplete += Client_DelContactListComplete;;
            client.ModContactListComplete += Client_ModContactListComplete;
            Console.WriteLine("小助手启动");
            client.Start();
            qrForm.ShowDialog();

            Console.ReadLine();
            client.Close();
            Console.ReadLine();
            client.Logout();

            //获取群成员详情,需要我们主动调用,一般用不到,因为群里已经包含Member基本信息。
            //Contact chatRoom = contactDict["群UserName"];
            //string listStr = string.Join(",", chatRoom.MemberList);
            //client.GetBatchGetContactAsync(listStr, chatRoom.UserName);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            client = new Client();
            qrForm = new QrCodeForm();
            string cookie = @"ptui_loginuin=12345678;last_wxuin=****;wxuin=****;webwxuvid=****; webwx_auth_ticket=****";

            client.ExceptionCatched           += Client_ExceptionCatched;;
            client.GetLoginQrCodeComplete     += Client_GetLoginQrCodeComplete;;
            client.CheckScanComplete          += Client_CheckScanComplete;;
            client.LoginComplete              += Client_LoginComplete;;
            client.BatchGetContactComplete    += Client_BatchGetContactComplete;;
            client.GetContactComplete         += Client_GetContactComplete;;
            client.MPSubscribeMsgListComplete += Client_MPSubscribeMsgListComplete;;
            client.LogoutComplete             += Client_LogoutComplete;;
            client.ReceiveMsg             += Client_ReceiveMsg;;
            client.DelContactListComplete += Client_DelContactListComplete;;
            client.ModContactListComplete += Client_ModContactListComplete;
            Console.WriteLine("小助手启动");
            client.Start(cookie);
            //qrForm.ShowDialog();


            while (true)
            {
                var keyinfo = Console.ReadKey();
                switch (keyinfo.Key)
                {
                case ConsoleKey.NumPad1:
                    client.SendMsgAsync("双击666!", "filehelper");
                    break;

                case ConsoleKey.NumPad2:
                    OpenFileDialog openImgFileDialog = new OpenFileDialog();
                    openImgFileDialog.Filter = "图片|*.jpg;*.png;*.gif";
                    if (openImgFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        var file = new FileInfo(openImgFileDialog.FileName);
                        client.SendMsgAsync(file, "filehelper");
                    }
                    break;

                case ConsoleKey.Escape:
                    client.Close();
                    client.Logout();
                    break;
                }
            }

            //获取群成员详情,需要我们主动调用,一般用不到,因为群里已经包含Member基本信息。
            //Contact chatRoom = contactDict["群UserName"];
            //string listStr = string.Join(",", chatRoom.MemberList);
            //client.GetBatchGetContactAsync(listStr, chatRoom.UserName);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            client = new Client();
            qrForm = new QrCodeForm();

            string cookie = null;

            //获取登陆之后记录的cookie,实现推送手机端登陆,取代扫码
            //若不需要,注释掉以下代码即可
            if (File.Exists(cookiePath))
            {
                StreamReader sr = new StreamReader(cookiePath, Encoding.Default);
                cookie = sr.ReadLine();
                sr.Close();
            }

            client.ExceptionCatched           += Client_ExceptionCatched;;
            client.GetLoginQrCodeComplete     += Client_GetLoginQrCodeComplete;;
            client.CheckScanComplete          += Client_CheckScanComplete;;
            client.LoginComplete              += Client_LoginComplete;;
            client.BatchGetContactComplete    += Client_BatchGetContactComplete;;
            client.GetContactComplete         += Client_GetContactComplete;;
            client.MPSubscribeMsgListComplete += Client_MPSubscribeMsgListComplete;;
            client.LogoutComplete             += Client_LogoutComplete;;
            client.ReceiveMsg             += Client_ReceiveMsg;;
            client.DelContactListComplete += Client_DelContactListComplete;;
            client.ModContactListComplete += Client_ModContactListComplete;
            Console.WriteLine("小助手启动");
            client.Start(cookie);
            //qrForm.ShowDialog();


            while (true)
            {
                var keyinfo = Console.ReadKey();
                switch (keyinfo.Key)
                {
                case ConsoleKey.NumPad1:
                    client.SendMsgAsync("双击666!", "filehelper");
                    break;

                case ConsoleKey.NumPad2:
                    OpenFileDialog openImgFileDialog = new OpenFileDialog();
                    openImgFileDialog.Filter = "图片|*.jpg;*.png;*.gif";
                    if (openImgFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        var file = new FileInfo(openImgFileDialog.FileName);
                        client.SendMsgAsync(file, "filehelper");
                    }
                    break;

                case ConsoleKey.Escape:
                    client.Close();
                    client.Logout();
                    break;
                }
            }

            //获取群成员详情,需要我们主动调用,一般用不到,因为群里已经包含Member基本信息。
            //Contact chatRoom = contactDict["群UserName"];
            //string listStr = string.Join(",", chatRoom.MemberList);
            //client.GetBatchGetContactAsync(listStr, chatRoom.UserName);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            try
            {
                //全局异常设定
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                //生成对象
                client = new Client();
                qrForm = new QrCodeForm();

                string cookie = null;
                //获取登陆之后记录的cookie,实现推送手机端登陆,取代扫码
                //若不需要,注释掉以下代码即可
                if (File.Exists(cookiePath))
                {
                    StreamReader sr = new StreamReader(cookiePath, Encoding.Default);
                    cookie = sr.ReadLine();
                    sr.Close();
                }

                client.ExceptionCatched           += Client_ExceptionCatched;;
                client.GetLoginQrCodeComplete     += Client_GetLoginQrCodeComplete;;
                client.CheckScanComplete          += Client_CheckScanComplete;;
                client.LoginComplete              += Client_LoginComplete;;
                client.BatchGetContactComplete    += Client_BatchGetContactComplete;;
                client.GetContactComplete         += Client_GetContactComplete;;
                client.MPSubscribeMsgListComplete += Client_MPSubscribeMsgListComplete;;
                client.LogoutComplete             += Client_LogoutComplete;;
                client.ReceiveMsg             += Client_ReceiveMsg;;
                client.DelContactListComplete += Client_DelContactListComplete;;
                client.ModContactListComplete += Client_ModContactListComplete;

                Console.WriteLine("扫描启动...");
                Log.Write("扫描启动...");

                client.Start(cookie);

                //qrForm.ShowDialog();

                //启动Pic和Heart的时钟
                m_heartClock.HeartBeatClockEvent += M_heartClock_HeartBeatClockEvent;
                m_picClock.PicturesClockEvent    += M_picClock_PicturesClockEvent;
                m_heartClock.Start();
                m_picClock.Start();

                //
                while (true)
                {
                    var keyinfo = Console.ReadKey();
                    switch (keyinfo.Key)
                    {
                    case ConsoleKey.D1:                               //1
                        client.SendMsgAsync("测试助手发送!", "filehelper"); //测试成功,似乎文件助手这里username不是中文,而是所谓的这种专用ID-Name
                        break;

                    case ConsoleKey.D2:    //2
                        OpenFileDialog openImgFileDialog = new OpenFileDialog();
                        openImgFileDialog.Filter = "图片|*.jpg;*.png;*.gif";
                        if (openImgFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            var file = new FileInfo(openImgFileDialog.FileName);
                            client.SendMsgAsync(file, "filehelper");
                        }
                        break;

                    case ConsoleKey.Escape:
                        client.Close();
                        client.Logout();
                        break;
                    }
                }

                //获取群成员详情,需要我们主动调用,一般用不到,因为群里已经包含Member基本信息。
                //Contact chatRoom = contactDict["群UserName"];
                //string listStr = string.Join(",", chatRoom.MemberList);
                //client.GetBatchGetContactAsync(listStr, chatRoom.UserName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw new Exception(ex.Message);
            }
        }