static void Main(string[] args) { #if DEBUG uint qq = 976811781u; string pass = Console.ReadLine(); #else Console.Write("请输入QQ:"); uint qq = uint.Parse(Console.ReadLine()); Console.Write("请输入密码:"); string pass = Console.ReadLine(); #endif client = new QQClient(qq, pass); client.User.IsUdp = true; client.LoginStatusChanged += client_LoginStatusChanged; client.ReceiveClusterIM += client_ReceiveClusterIM; client.ReceiveNormalIM += client_ReceiveNormalIM; client.AddedToCluster += client_AddedToCluster; client.LoginSuccessed += client_LoginSuccessed; client.CardChanged += client_CardChanged; client.ClusterAdminChanged += client_ClusterAdminChanged; client.AddToClusterNeedAuth += client_AddToClusterNeedAuth; client.AddedToClusterInvite += client_AddedToClusterInvite; client.Login(); var input = Console.ReadLine(); while (client.User.LoginStatus == Coco.Framework.Entities.LoginStatus.NeedVerifyCode) { client.SendVerifyCode(input); input = Console.ReadLine(); } client.Logout(); }
private void button1_Click(object sender, EventArgs e) { if (!had) { had = true; this.label5.Visible = true; msg = this.richTextBox1.Text.Trim() + "\n----------------------------------\n本消息由QQMessage发送\nhttp://www.2081.org/labs.html"; user = new QQUser(Int32.Parse(this.textBox1.Text.Trim()), this.textBox2.Text); client = new QQ.NET.QQClient(user); user.IsUdp = true; client.LoginServerHost = "219.133.62.8"; client.ConnectionManager.NetworkError += new EventHandler <ErrorEventArgs>(ConnectionManager_NetworkError); client.LoginManager.LoginFailed += new EventHandler <QQEventArgs <LoginReplyPacket, LoginPacket> >(LoginManager_LoginFailed); client.LoginManager.LoginSuccessed += new EventHandler <QQEventArgs <LoginReplyPacket, LoginPacket> >(LoginManager_LoginSuccessed); client.FriendManager.GetFriendListSuccessed += new EventHandler <QQEventArgs <GetFriendListReplyPacket, GetFriendListPacket> >(FriendManager_GetFriendListSuccessed); client.Error += new EventHandler <QQEventArgs <ErrorPacket, OutPacket> >(client_Error); client.MessageManager.ReceiveNormalIM += new EventHandler <QQEventArgs <ReceiveIMPacket, OutPacket> >(MessageManager_ReceiveNormalIM); client.Login(); } else { MessageBox.Show("请关闭程序后,重新登录发送。"); } }
static void Main(string[] args) { QQUser user = new QQUser(MyQQ, MyPassWord); client = new QQClient() { QQUser = user }; client.EventReceive_0x0017 += Client_EventReceive_0x0017; client.EventReceive_0x00CE += Client_EventReceive_0x00CE; client.EventReceive_0x00BA += Client_EventReceive_0x00BA; client.Login(); Console.ReadKey(); }
static void Main(string[] args) { QQClient // 登录 .Login((bytes) => { using (var ms = new MemoryStream(bytes)) { QQClient.ConsoleWriteImage(new Bitmap(Image.FromStream(ms))); Logger.Instance.Info("二维码已打印在屏幕,请使用手机QQ扫描。"); } }) // 好友消息回调 .ReceivedFriendMessage((message) => { //message.Reply("test"); Logger.Instance.Info($"{message.Sender.Alias ?? message.Sender.Nickname}:{message.Content}"); }) // 群消息回调 .ReceivedGroupMessage((message) => { Logger.Instance.Info( $"[{message.Group.Name}]{message.Sender.Alias ?? message.Sender.Nickname}:{message.Content}"); if (message.Content.IsMatch(@"^\s*Knock knock\s*$")) { message.Reply("Who's there?"); } else if (message.StrictlyMentionedMe) { message.Reply("什么事?"); } }) // 讨论组消息回调 .ReceivedDiscussionMessage((message) => { Logger.Instance.Info($"[{message.Discussion.Name}]{message.Sender.Nickname}:{message.Content}"); }) // 消息回显 .ReceivedMessageEchoEventArgs((e) => { Logger.Instance.Info($"{e.Target.Name}>{e.Content}"); }) //开始服务 .Start((client) => { Logger.Instance.Info($"欢迎,{client.Nickname}!"); }); Console.ReadLine(); }
private static void Main(string[] args) { #if NETCOREAPP2_0 || NETCOREAPP2_1 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); #endif var user = new QQUser(MyQQ, MyPassWord); client = new QQClient { QQUser = user }; client.EventReceive_0x0017 += Client_EventReceive_0x0017; client.EventReceive_0x00CE += Client_EventReceive_0x00CE; client.EventReceive_0x00BA += Client_EventReceive_0x00BA; client.Login(); Console.ReadKey(); }
private static void StartLogin() { Init: #if RELEASE int qq = 0; bool IsQQNum = false; while (!IsQQNum) { try { Console.Write("QQ账号:"); string s = Console.ReadLine(); Console.WriteLine("您输入的QQ号是:{0}", s); qq = int.Parse(s); IsQQNum = true; } catch { Console.WriteLine("QQ号码错误,请重新输入:"); IsQQNum = false; } } Console.Write("密码:"); string p = ""; p = Console.ReadLine(); Console.Write("是否隐身登陆(Y/N):"); string st = Console.ReadLine(); Console.Clear(); QQUser user2 = new QQUser(qq, p); if (st == "Y" || st == "y") { user2.LoginMode = QQStatus.HIDDEN; } #else QQUser user2 = new QQUser(1667100016, "qweqwe123++"); #endif Client = new QQClient(user2); Client.LoginManager.LoginStatusChanged += new EventHandler <LFNet.QQ.Events.LoginStatusChangedEventArgs <LoginStatus> >(LoginManager_LoginStatusChanged); //user2.IsUdp = true;//设置登录模式 udp 或tcp Client.LoginServerHost = "219.133.49.171"; //指定默认的服务器IP地址,可以不指定服务器IP,系统自动搜索可用的IP //UDP登录服务器【sz.tencent.com】域名解析成功,解析为【219.133.49.171】 //UDP登录服务器【sz2.tencent.com】域名解析成功,解析为【219.133.60.31】 //UDP登录服务器【sz3.tencent.com】域名解析成功,解析为【219.133.48.87】 //UDP登录服务器【sz4.tencent.com】域名解析成功,解析为【219.133.40.138】 //UDP登录服务器【sz5.tencent.com】域名解析成功,解析为【219.133.49.169】 //UDP登录服务器【sz6.tencent.com】域名解析成功,解析为【219.133.60.37】 //UDP登录服务器【sz7.tencent.com】域名解析成功,解析为【219.133.48.89】 //UDP登录服务器【sz8.tencent.com】域名解析成功,解析为【219.133.40.37】 //UDP登录服务器【sz9.tencent.com】域名解析成功,解析为【219.133.60.39】 Client.Login(); while (Client.LoginStatus != LoginStatus.Login)//如果没有登录成功则 { if (Client.LoginStatus == LoginStatus.NeedVerifyCode) { Console.Write("请输入验证码:"); string code = Console.ReadLine(); Client.LoginStatus = LoginStatus.SendVerifyCode; Client.LoginManager.LoginSendVerifyCode(code); } else if (Client.LoginStatus == LoginStatus.WrongPassword) { goto Init; } //else if(Client.LoginStatus ==LoginStatus.ChangeServer) //{ // Console.WriteLine("尝试连接:"+Client.LoginServerHost); //} Thread.Sleep(100); } foreach (ClusterInfo clusterInfo in Client.QQUser.ClusterList.Values) { if (clusterInfo.ExternalId == 0) { Client.ClusterManager.GetClusterInfo(clusterInfo.QQBasicInfo.QQ); } } }
private static void StartLogin() { Init: #if !RELEASE int qq = 0; bool IsQQNum = false; while (!IsQQNum) { try { Console.Write("QQ账号:"); string s = Console.ReadLine(); Console.WriteLine("您输入的QQ号是:{0}", s); qq = int.Parse(s); IsQQNum = true; } catch { Console.WriteLine("QQ号码错误,请重新输入:"); IsQQNum = false; } } Console.Write("密码:"); string p = ""; p = Console.ReadLine(); Console.Write("是否隐身登陆(Y/N):"); string st = Console.ReadLine(); Console.Clear(); QQUser user2 = new QQUser(qq, p); if (st == "Y" || st == "y") { user2.LoginMode = QQStatus.HIDDEN; } #else QQUser user2 = new QQUser(156798087, "..."); #endif Client = new QQClient(user2); Client.LoginManager.LoginStatusChanged += new EventHandler <LFNet.QQ.Events.LoginStatusChangedEventArgs <LoginStatus> >(LoginManager_LoginStatusChanged); //user2.IsUdp = true;//设置登录模式 udp 或tcp Client.LoginServerHost = "219.133.49.171"; //指定默认的服务器IP地址,可以不指定服务器IP,系统自动搜索可用的IP Client.Login(); while (Client.LoginStatus != LoginStatus.Login) //如果没有登录成功则 { if (Client.LoginStatus == LoginStatus.NeedVerifyCode) { Console.Write("请输入验证码:"); string code = Console.ReadLine(); Client.LoginStatus = LoginStatus.SendVerifyCode; Client.LoginManager.LoginSendVerifyCode(code); } else if (Client.LoginStatus == LoginStatus.WrongPassword) { goto Init; } //else if(Client.LoginStatus ==LoginStatus.ChangeServer) //{ // Console.WriteLine("尝试连接:"+Client.LoginServerHost); //} Thread.Sleep(100); } }