574 lines
22 KiB
C#
574 lines
22 KiB
C#
|
using Chat.Framework.PCRobotSDK;
|
|||
|
using Chat.Framework.Properties;
|
|||
|
using Chat.Framework.QQSdk;
|
|||
|
using Chat.Framework.QQSdk.Events;
|
|||
|
using Chat.Framework.QQSdk.QPlus;
|
|||
|
//using Chat.Framework.QQSdk.PCQQ;
|
|||
|
using Chat.Framework.WXSdk;
|
|||
|
using Chat.Framework.WXSdk.Events;
|
|||
|
using Chat.Framework.WXSdk.Implement;
|
|||
|
using Chat.Framework.WXSdk.UIForm;
|
|||
|
using CsharpHttpHelper;
|
|||
|
using Grant.Framework;
|
|||
|
using Newtonsoft.Json;
|
|||
|
using PCRobot.Pack;
|
|||
|
using Robot.Framework;
|
|||
|
using Robot.Framework.Entities;
|
|||
|
using SuperSocket.SocketBase;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Windows.Forms;
|
|||
|
using UI.Framework.Forms;
|
|||
|
|
|||
|
namespace Chat.Framework
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 机器人综合管理类
|
|||
|
/// </summary>
|
|||
|
public class ChatClient
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 消息频繁休眠时间
|
|||
|
/// </summary>
|
|||
|
public static int MessFrequentSleepTime { get; set; } = 5;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Hook通讯秘钥
|
|||
|
/// </summary>
|
|||
|
public static string SocketPassword { get; set; } = "";
|
|||
|
|
|||
|
static ChatClient()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
QQClients = new Dictionary<string, QQBase>();
|
|||
|
WXClient = new Dictionary<string, WeixinBase>();
|
|||
|
//PCRobotPool = new PCRobotPool();
|
|||
|
//QQPool = new QQPool();
|
|||
|
WXSdkConfig = new WXSdkConfig();
|
|||
|
QQEvents = new QQEventManage();
|
|||
|
Events = new EventManage();
|
|||
|
Grant.Framework.GrantClient.Get().GrantEvent += GrantEvent;
|
|||
|
Wechat_HeadPack = new HeadPack_Hook();//注册微信Hook 的掉线检测包
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 图片CDN缓存
|
|||
|
/// </summary>
|
|||
|
public static Dictionary<string, object> ImageCDNs = new Dictionary<string, object>();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// hook(易转发)
|
|||
|
/// </summary>
|
|||
|
public static PCRobotPool PCRobotPool { get; private set; } = new PCRobotPool();
|
|||
|
//public static QQPool QQPool { get; private set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 机器人QQ基础字典
|
|||
|
/// </summary>
|
|||
|
public static Dictionary<string, QQBase> QQClients { get; private set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 机器人微信基类集合,已经登录微信机器人集合
|
|||
|
/// </summary>
|
|||
|
public static Dictionary<string, WeixinBase> WXClient { get; private set; }
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
public static WXSdkConfig WXSdkConfig { get; private set; }
|
|||
|
/// <summary>
|
|||
|
/// 微信事件管理
|
|||
|
/// </summary>
|
|||
|
public static EventManage Events { get; private set; }
|
|||
|
/// <summary>
|
|||
|
/// QQ事件管理
|
|||
|
/// </summary>
|
|||
|
public static QQEventManage QQEvents { get; private set; }
|
|||
|
|
|||
|
//public static QQCaptchaBrowser QQBrowser;
|
|||
|
private static HeadPack_Hook Wechat_HeadPack { get; set; }
|
|||
|
|
|||
|
internal static QQClient IniClient(uint qq, string pass, bool isCache = true)
|
|||
|
{
|
|||
|
var qClient = new QQClient(qq, pass);
|
|||
|
if (isCache)
|
|||
|
{
|
|||
|
if (QQClients.ContainsKey(qq.ToString()))
|
|||
|
{
|
|||
|
//var qClientTmp = QQClients[qq.ToString()];
|
|||
|
//if (qClientTmp != null && qClientTmp.User != null && qClientTmp.User.Status != QQStatus.离线)
|
|||
|
// qClientTmp.Logout();
|
|||
|
|
|||
|
var qBaseTmp = QQClients[qq.ToString()];
|
|||
|
qBaseTmp.Login();
|
|||
|
}
|
|||
|
QQClients[qq.ToString()] = new QQClientImpl_QQPlus(qClient);
|
|||
|
}
|
|||
|
return qClient;
|
|||
|
}
|
|||
|
|
|||
|
private static void GrantEvent(customer customer, string message)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
//.WriteLog("授权异常!" + (string.IsNullOrEmpty(message) ? "" : message));
|
|||
|
if (customer.softId == 1001)
|
|||
|
{
|
|||
|
var v = WXClient.Values.FirstOrDefault(f => f.Status == WxStatus.在线 && f.User.Uin.ToString() == customer.cardname);
|
|||
|
if (v == null) return;
|
|||
|
//【xxxxxxxxxxxxx】授权检测异常:刷新Token失败,请重新登录。
|
|||
|
if (message.Contains("Token"))
|
|||
|
return;
|
|||
|
|
|||
|
v.LoginOut();
|
|||
|
v.ChangeStatus(WxStatus.已退出);
|
|||
|
Events.OnEvent(new WXWriteLog(v) { Message = $"【{v.WeixinHao}】授权检测异常:" + message });
|
|||
|
}
|
|||
|
else if (customer.softId == 1002 && QQClients.ContainsKey(customer.cardname))
|
|||
|
{
|
|||
|
var qBase = QQClients[customer.cardname];
|
|||
|
|
|||
|
if (qBase is QQClientImpl_QQPlus)
|
|||
|
{
|
|||
|
var tmp = (qBase as QQClientImpl_QQPlus);
|
|||
|
var client = tmp.QQClient;
|
|||
|
if (client != null && client.User != null && client.User.LoginStatus == LoginStatus.Login)
|
|||
|
{
|
|||
|
if (message.Contains("Token"))
|
|||
|
return;
|
|||
|
|
|||
|
//v.User.Status = QQStatus.离线;
|
|||
|
client.Logout();
|
|||
|
QQEvents.OnEvent(new QQLogEvents(tmp) { Message = $"【{customer.cardname}】授权检测异常:" + message });
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private static object license_data = new object();
|
|||
|
|
|||
|
public delegate byte[] FindLicenseData(string method, string data, string api);
|
|||
|
private static FindLicenseData FindLicense;
|
|||
|
|
|||
|
public static void BindLicenseData(FindLicenseData action)
|
|||
|
{
|
|||
|
if (FindLicense == null)
|
|||
|
{
|
|||
|
FindLicense = action;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public delegate string GetServerData(string key);
|
|||
|
public static GetServerData GetServerDataMethod;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 查询数据中的用户信息
|
|||
|
/// </summary>
|
|||
|
public static Func<string, WXSdk.Friend> GetDBWechatFriend;
|
|||
|
|
|||
|
|
|||
|
//internal static Dictionary<string, object> GetLicenseData(string method, object data, string api = "api/member.ashx")
|
|||
|
//{
|
|||
|
// lock (license_data)
|
|||
|
// {
|
|||
|
// var _data = Util.HexToStr(Encoding.UTF8.GetBytes(Util.ObjectToJson(data)));
|
|||
|
// var _rest = FindLicense.Invoke(method, _data, api);
|
|||
|
// var _json = Encoding.UTF8.GetString(_rest);
|
|||
|
// if (!_json.StartsWith("{")) throw new Exception(_json);
|
|||
|
// var _dic = Util.ConvertJsonToDic(_json);
|
|||
|
// if (_dic == null) throw new Exception(_json);
|
|||
|
// return _dic;
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// hook协议退出微信
|
|||
|
/// </summary>
|
|||
|
/// <param name="wei_xin_hao">要退出的微信号</param>
|
|||
|
public static void LoginOutWeixin(string wei_xin_hao)
|
|||
|
{
|
|||
|
var wx = WXClient.FirstOrDefault(f => f.Key == wei_xin_hao).Value;
|
|||
|
if (wx != null)
|
|||
|
{
|
|||
|
WXClient.Remove(wei_xin_hao);
|
|||
|
wx.LoginOut();
|
|||
|
wx.Dispose();
|
|||
|
wx = null;
|
|||
|
}
|
|||
|
var pcRobot = PCRobotPool.GetSession(wei_xin_hao);
|
|||
|
if (pcRobot != null)
|
|||
|
PCRobotPool.Remove(pcRobot);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// hook协议退出调用此方法,附带提示语信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="wei_xin_hao">要退出的微信号</param>
|
|||
|
/// <param name="message">附带退出原因(弹窗)</param>
|
|||
|
public static void LoginOutWeixin(string wei_xin_hao, string message)
|
|||
|
{
|
|||
|
var wx = WXClient.FirstOrDefault(f => f.Key == wei_xin_hao).Value;
|
|||
|
if (wx != null)
|
|||
|
{
|
|||
|
WXClient.Remove(wei_xin_hao);
|
|||
|
wx.LoginOut(message);
|
|||
|
wx.Dispose();
|
|||
|
wx = null;
|
|||
|
}
|
|||
|
var pcRobot = PCRobotPool.GetSession(wei_xin_hao);
|
|||
|
if (pcRobot != null)
|
|||
|
PCRobotPool.Remove(pcRobot);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 协议微信登录
|
|||
|
/// </summary>
|
|||
|
/// <param name="weixinhao"></param>
|
|||
|
/// <param name="username"></param>
|
|||
|
/// <param name="userpass"></param>
|
|||
|
/// <param name="data62"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static string LoginWeixin(string weixinhao, string username, string userpass, string data62)
|
|||
|
{
|
|||
|
var v = WXClient.FirstOrDefault(f => f.Key == weixinhao).Value as WXClientImpl_IPAD;
|
|||
|
if (v == null)
|
|||
|
{
|
|||
|
v = new WXClientImpl_IPAD(weixinhao);
|
|||
|
}
|
|||
|
if (v.Status == WxStatus.在线) return string.Empty;
|
|||
|
if (v.Login(username, userpass, data62))
|
|||
|
{
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
else return v.LoginErrorMessage;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 协议微信登录
|
|||
|
/// </summary>
|
|||
|
/// <param name="wei_xin_hao"></param>
|
|||
|
/// <param name="data"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool LoginWeixin(string wei_xin_hao = "", string data = "")
|
|||
|
{
|
|||
|
string deviceid = string.Empty;
|
|||
|
if (string.IsNullOrEmpty(wei_xin_hao))
|
|||
|
{
|
|||
|
// if (MessageBox.Show(@"对不起,由于近期个别微信有出现封号!
|
|||
|
//为了您的账号安全,暂时不提供协议登陆!
|
|||
|
//请下载【易转发-微信官方客户端】登陆,保障您的账号安全!
|
|||
|
//-------------
|
|||
|
//下载地址已复制到剪切板,请粘贴到浏览器下载
|
|||
|
//-------------
|
|||
|
//注意:如果您执意要通过协议登陆,请点击确定!!!", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
|
|||
|
if (BaseForm.ShowSuccessAutoClose(@"对不起,由于近期个别微信有出现封号!
|
|||
|
为了您的账号安全,暂时不提供协议登陆!
|
|||
|
请下载【易转发-微信官方客户端】登陆,保障您的账号安全!
|
|||
|
-------------
|
|||
|
下载地址已复制到剪切板,请粘贴到浏览器下载
|
|||
|
-------------
|
|||
|
注意:如果您执意要通过协议登陆,请点击确定!!!", new DialogResult[] { DialogResult.OK, DialogResult.Cancel }) == DialogResult.Cancel)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
Clipboard.SetDataObject(Resources.易转发下载地址 + "?=" + new Random().Next(100, 2000));
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{ }
|
|||
|
return false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var WeixinHao = new WXSdk.UIForm.SetwxhForm();
|
|||
|
WeixinHao.ShowDialog();
|
|||
|
if (string.IsNullOrEmpty(WeixinHao.wxh))
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
wei_xin_hao = WeixinHao.wxh;
|
|||
|
deviceid = WeixinHao.deviceid;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
var v = WXClient.FirstOrDefault(f => f.Key == wei_xin_hao).Value;
|
|||
|
if (v != null)
|
|||
|
{
|
|||
|
var vx = new WXClientImpl_IPAD(wei_xin_hao);
|
|||
|
if (!string.IsNullOrEmpty(deviceid)) vx.DeviceId = deviceid;
|
|||
|
v = vx;
|
|||
|
v.ShowLogin();
|
|||
|
}
|
|||
|
else if (data == "input_password")
|
|||
|
{
|
|||
|
var vx = new WXClientImpl_IPAD(wei_xin_hao);
|
|||
|
v = vx;
|
|||
|
vx.ShowPasswordForm();
|
|||
|
}
|
|||
|
else if (string.IsNullOrEmpty(data))
|
|||
|
{
|
|||
|
var vx = new WXClientImpl_IPAD(wei_xin_hao);
|
|||
|
if (!string.IsNullOrEmpty(deviceid)) vx.DeviceId = deviceid;
|
|||
|
v = vx;
|
|||
|
v.ShowLogin();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
v = new WXClientImpl_IPAD(wei_xin_hao, data);
|
|||
|
v.ResetConnection();
|
|||
|
}
|
|||
|
return v.Status == WxStatus.在线 ? true : false;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// PC微信设置登录
|
|||
|
/// </summary>
|
|||
|
/// <param name="device">之前登陆的设备信息</param>
|
|||
|
/// <param name="robotname">之前登陆的微信账号</param>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool LoginPcWeixin(string device, string robotname, RobotType rType)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var appSs = PCRobotPool.ClientSessions.Values.Where(f => f.device == device).ToList();
|
|||
|
if (appSs == null || appSs.Count == 0)
|
|||
|
BaseForm.ShowSuccessAutoClose(@"未找到该设备信息
|
|||
|
可能原因如下:
|
|||
|
1、易转发软件非最新版(升级试试)
|
|||
|
2、请检查易转发是否已和软件连接成功
|
|||
|
3、易转发端软件目录变更(需要易转发端登录)");
|
|||
|
else
|
|||
|
{
|
|||
|
var appS = appSs[0];
|
|||
|
//foreach (var appS in appSs)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var msgid = SendServer(appS.appSession, robotname, rType);
|
|||
|
if (!string.IsNullOrEmpty(msgid))
|
|||
|
{
|
|||
|
var rst = PCRobotPool.PackHist.GetResult(msgid).Result;
|
|||
|
if (rst != null)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var commonResult = rst as CommonResult;
|
|||
|
if (commonResult != null)
|
|||
|
{
|
|||
|
if (string.IsNullOrWhiteSpace(commonResult.Data))
|
|||
|
throw new Exception("获取二维码异常");
|
|||
|
var rlc = JsonConvert.DeserializeObject<RemoteLoginCode>(commonResult.Data);
|
|||
|
if (rlc != null)
|
|||
|
{
|
|||
|
if (rlc.pid == -1)
|
|||
|
throw new Exception(rlc.b64Md5);
|
|||
|
var codeImg = Utils.Common.ConvertBase64ToImage(rlc.cImgB64);
|
|||
|
var form = new PCLoginForm(codeImg, rlc, robotname, appS.appSession);
|
|||
|
form.ShowDialog();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
BaseForm.ShowSuccessAutoClose("请求易转发:" + ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{ }
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
BaseForm.ShowSuccessAutoClose("PC登录异常:" + ex.Message);
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
internal static string SendServer(AppSession app, string robotname, RobotType rType, string pid = "-1")
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var cmd = PCRobotCMD.getlogincode;
|
|||
|
var msg = new LoginCodeMsg()
|
|||
|
{
|
|||
|
Cmd = cmd,
|
|||
|
RobotType = rType,
|
|||
|
RobotUsername = robotname,
|
|||
|
RobotUsernick = string.Empty,
|
|||
|
Data = pid,
|
|||
|
Key = SocketPassword
|
|||
|
};
|
|||
|
var json = HttpHelper.ObjectToJson(msg);
|
|||
|
var text = PackTool.CompressString(json);
|
|||
|
//var t = PackTool.DecompressString(text);
|
|||
|
|
|||
|
var need_send = $"{cmd} {text}\r\n";
|
|||
|
app.TrySend(need_send);
|
|||
|
return msg.MsgId;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{ }
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
internal static void UpdateWXClient(WeixinBase Client)
|
|||
|
{
|
|||
|
if (!WXClient.ContainsKey(Client.WeixinHao))
|
|||
|
{
|
|||
|
WXClient.Add(Client.WeixinHao, Client);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var tempClient = WXClient[Client.WeixinHao];
|
|||
|
if (tempClient != Client)
|
|||
|
{
|
|||
|
tempClient.LoginOut();
|
|||
|
}
|
|||
|
WXClient[Client.WeixinHao] = Client;
|
|||
|
}
|
|||
|
Console.Write(Client.ToString());
|
|||
|
Events.OnEvent(new WXSdk.Events.WXRefreshUser(Client));
|
|||
|
}
|
|||
|
|
|||
|
#region QQ
|
|||
|
/// <summary>
|
|||
|
/// QQ登录
|
|||
|
/// </summary>
|
|||
|
/// <param name="qqStr">QQ账号</param>
|
|||
|
/// <param name="pass">QQ密码</param>
|
|||
|
/// <param name="isEQQ">是否企业QQ</param>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool LoginQQ(string qqStr = "", string pass = "", bool isEQQ = false)
|
|||
|
{
|
|||
|
var flag = false;
|
|||
|
QQClient qClient = null;
|
|||
|
if (!string.IsNullOrWhiteSpace(qqStr) && !string.IsNullOrWhiteSpace(pass))
|
|||
|
{
|
|||
|
uint qq;
|
|||
|
if (uint.TryParse(qqStr, out qq))
|
|||
|
{
|
|||
|
var q = QQClients.FirstOrDefault(f => f.Key == qqStr).Value;
|
|||
|
if (q == null)
|
|||
|
{
|
|||
|
qClient = new QQClient();
|
|||
|
new QQClientImpl_QQPlus(qClient);
|
|||
|
//qClient.LoginStatusChanged += QClient_LoginStatusChanged;
|
|||
|
qClient.QQProtocol = isEQQ ? "企业QQ" : "PCQQ";
|
|||
|
qClient.User = new QQUser(qq, pass);
|
|||
|
qClient.Login();
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if (!flag)
|
|||
|
{
|
|||
|
var form = new QQLoginForm(qqStr);
|
|||
|
if (form.ShowDialog() != DialogResult.OK)
|
|||
|
return false;
|
|||
|
qClient = form.qPlusClient.QQClient;
|
|||
|
}
|
|||
|
|
|||
|
return qClient.User.LoginStatus == LoginStatus.Login;
|
|||
|
}
|
|||
|
|
|||
|
//private static void QClient_LoginStatusChanged(object sender, Robot.Framework.SDK.LoginStatusChangedQQEventArgs e)
|
|||
|
//{
|
|||
|
// if (sender is QQClient)
|
|||
|
// {
|
|||
|
// var q = sender as QQClient;
|
|||
|
// QQEvents.OnEvent(new QQLogEvents(null) { Message = $"QQ({q.User.NickName}【{q.User.QQ}】) {LoginStatus.Failed} {e.Other}" });
|
|||
|
// if (e.LoginStatus == LoginStatus.Login)
|
|||
|
// {
|
|||
|
// UpdateQQClient(new QQClientImpl_QQPlus(sender as QQClient));
|
|||
|
// q.LoginStatusChanged -= QClient_LoginStatusChanged;
|
|||
|
// }
|
|||
|
// else if(e.LoginStatus == LoginStatus.Failed || e.LoginStatus == LoginStatus.WrongPassword || e.LoginStatus == LoginStatus.JiHuo)
|
|||
|
// {
|
|||
|
// q.LoginStatusChanged -= QClient_LoginStatusChanged;
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 退出QQ
|
|||
|
/// </summary>
|
|||
|
/// <param name="qq">QQ</param>
|
|||
|
public static void LoginOutQQ(string qq)
|
|||
|
{
|
|||
|
if (QQClients.ContainsKey(qq))
|
|||
|
{
|
|||
|
var qClient = QQClients[qq];
|
|||
|
QQClients.Remove(qq);
|
|||
|
qClient.Logout();
|
|||
|
qClient = null;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新QQ信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="Client"></param>
|
|||
|
internal static void UpdateQQClient(QQBase Client)
|
|||
|
{
|
|||
|
if (!QQClients.ContainsKey(Client.QQ.ToString()))
|
|||
|
{
|
|||
|
QQClients.Add(Client.QQ.ToString(), Client);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var qBase = QQClients[Client.QQ.ToString()];
|
|||
|
//if (tempClient != Client)
|
|||
|
//{
|
|||
|
// tempClient.Logout();
|
|||
|
//}
|
|||
|
//QQClients[Client.User.QQ.ToString()] = Client;
|
|||
|
if (qBase != Client)
|
|||
|
{
|
|||
|
qBase.Logout();
|
|||
|
}
|
|||
|
QQClients[Client.QQ.ToString()] = Client;
|
|||
|
}
|
|||
|
//Console.Write(Client.ToString());
|
|||
|
QQEvents.OnEvent(new QQSdk.Events.QQRefreshUser(Client));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
public static void SetWeixinCore(string[] grpc, string[] auth)
|
|||
|
{
|
|||
|
// WXClientTool.grpc_info = grpc;
|
|||
|
WXClientTool.auth_info = auth;
|
|||
|
}
|
|||
|
|
|||
|
//public static Client LoginQQ(uint QQ, string pass, bool isEQQ = false)
|
|||
|
//{
|
|||
|
// var User = new QQUser(QQ, pass);
|
|||
|
// User.LoginMode = QQLite.Framework.QQEnum.QQStatus.const_3;//QQ登录状态(在线|Q我吧|离开...)
|
|||
|
// var client = new Client(User);
|
|||
|
// //client.SetTXProtocol(isEQQ ? QQLite.Framework.QQEnum.TXProtocolType.QQEIM_1_9 : QQLite.Framework.QQEnum.TXProtocolType.QQ_6_8, true);
|
|||
|
// client.SetTXProtocol(isEQQ ? QQLite.Framework.QQEnum.TXProtocolType.QQEIM_1_9 : QQLite.Framework.QQEnum.TXProtocolType.QQ_8_9, true);
|
|||
|
// return client;
|
|||
|
//}
|
|||
|
|
|||
|
}
|
|||
|
}
|