static void Main(string[] args) { Init : Console.Title = "LFNet.QQ 基于QQ2009协议开发 作者:dobit QQ:156798087"; StartLogin(); AddEvents(); HelpMessage(); while (Client.LoginStatus == LoginStatus.Login) { string s = Console.ReadLine(); if (s == "") { continue; } if (s.StartsWith("-") || s.StartsWith("/") || TQQ == null) { s = s.Replace("-", "").Replace("/", ""); if (s.ToLower() == "x") { Client.Logout(); Console.WriteLine(); Console.WriteLine("退出成功"); Client.LoginStatus = LoginStatus.Logout; break; } ParseCommand(s); } else { if (TQQ != null) { if (AutoReply) { Lynfo.GoogleTranslateApi.GoogleTranslateApi GTA = new Lynfo.GoogleTranslateApi.GoogleTranslateApi(); GTA.TranslateCompleted += new EventHandler <Lynfo.GoogleTranslateApi.TranslateCompletedEventArgs>(GTA_TranslateCompleted); GTA.TranslateAsync(Lynfo.GoogleTranslateApi.GoogleTranslateApi.Language.CHINESE_SIMPLIFIED, Lynfo.GoogleTranslateApi.GoogleTranslateApi.Language.ENGLISH, s, TQQ); } else { SendMsg(TQQ, s); } } } } //Console.WriteLine(); Echo("是否重新登录(Y/N):"); if (Console.ReadLine().ToLower() == "y") { goto Init; } }
static void MessageManager_ReceiveNormalIM(object sender, LFNet.QQ.Events.QQEventArgs <ReceiveIMPacket, OutPacket> e) { Echo(string.Format("{0},{1}[{2}] 说:{3}", LFNet.QQ.Utils.Util.GetDateTimeFromMillis(e.InPacket.NormalHeader.SendTime), e.InPacket.Header.Sender, e.QQClient.QQUser.Friends[(int)e.InPacket.Header.Sender].Nick, e.InPacket.NormalIM.Message)); #if Robot string ret = LFNet.Robot.Robot.Parse(e.InPacket.NormalIM.TextMessage, Guid.Empty, null); if (!string.IsNullOrEmpty(ret)) { Echo(string.Format("系统自动回复{0}说:{1}", e.InPacket.NormalHeader.Sender, ret)); e.QQClient.MessageManager.SendIM(e.InPacket.NormalHeader.Sender, ret); } else { if (AutoReply) { Lynfo.GoogleTranslateApi.GoogleTranslateApi GTA = new Lynfo.GoogleTranslateApi.GoogleTranslateApi(); GTA.TranslateCompleted += new EventHandler <Lynfo.GoogleTranslateApi.TranslateCompletedEventArgs>(GTA_TranslateCompleted); GTA.TranslateAsync(Lynfo.GoogleTranslateApi.GoogleTranslateApi.Language.CHINESE_SIMPLIFIED, Lynfo.GoogleTranslateApi.GoogleTranslateApi.Language.ENGLISH, e.InPacket.NormalIM.TextMessage, new QQBasicInfo(e.InPacket.Header.Sender, QQType.QQ, 0)); } } #endif }
static void ClusterManager_ReceiveClusterIM(object sender, LFNet.QQ.Events.QQEventArgs <ReceiveIMPacket, OutPacket> e) { Echo(string.Format("{0},{2}在群{1}中说:{3}", LFNet.QQ.Utils.Util.GetDateTimeFromMillis(e.InPacket.ClusterIM.SendTime), e.InPacket.Header.Sender, e.InPacket.ClusterIM.Sender, e.InPacket.ClusterIM.Message)); #if Robot string ret = LFNet.Robot.Robot.Parse(e.InPacket.ClusterIM.TextMessage, Guid.Empty, null); if (!string.IsNullOrEmpty(ret)) { Echo(string.Format("系统自动回复群{0}:{1}", e.InPacket.ClusterIM.ExternalId, ret)); e.QQClient.ClusterManager.SendClusterIM((int)e.InPacket.Header.Sender, ret); } else { if (AutoReply && e.InPacket.ClusterIM.Sender != e.QQClient.QQUser.QQ) { Lynfo.GoogleTranslateApi.GoogleTranslateApi GTA = new Lynfo.GoogleTranslateApi.GoogleTranslateApi(); GTA.TranslateCompleted += new EventHandler <Lynfo.GoogleTranslateApi.TranslateCompletedEventArgs>(GTA_TranslateCompleted2); GTA.TranslateAsync(Lynfo.GoogleTranslateApi.GoogleTranslateApi.Language.CHINESE_SIMPLIFIED, Lynfo.GoogleTranslateApi.GoogleTranslateApi.Language.ENGLISH, e.InPacket.ClusterIM.TextMessage, new LFNet.QQ.Entities.QQBasicInfo(e.InPacket.Header.Sender, QQType.Cluster, 0)); } } #endif }