using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chat.Framework.QQSdk
{
///
/// QQ基类
///
public abstract class QQBase
{
public override string ToString()
{
if (!string.IsNullOrWhiteSpace(Password))
{
var data = new { QQ = QQ, Password = Password, IsEQQ = IsEQQ };
return CsharpHttpHelper.HttpExtend.ByteToHex(Encoding.UTF8.GetBytes(CsharpHttpHelper.HttpHelper.ObjectToJson(data)));
}
return string.Empty;
}
///
/// QQ
///
public uint QQ { get; protected set; }
///
/// 昵称
///
public string Nickname { get; protected set; }
///
/// 密码
///
public string Password { get; internal set; }
///
///
///
protected bool IsRegisterEvent { get; set; }
public DateTime EndTime { get; internal set; }
///
/// 是否已经登录
///
public bool IsLogin { get; internal set; }
///
/// 是否企业QQ
///
public bool IsEQQ { get; set; }
///
/// 不支持提示语
///
const string NoAccess = "对不起,该协议暂时不支持此函数!";
///
/// 退出登录
///
public virtual void Logout() { throw new Exception(NoAccess); }
///
/// 登录
///
public virtual void Login() { throw new Exception(NoAccess); }
//public virtual void ShowLogin(string Username = null) { throw new Exception(NoAccess); }
///
/// 发送好友消息
///
/// QQ
/// 消息的内容
public virtual void SendFriendMessage(uint QQ, string Message) { throw new Exception(NoAccess); }
///
/// 发送临时消息
///
/// QQ
/// 发送的消息
/// Token
public virtual void SendTempMessage(uint QQ, string Message, byte[] Token) { throw new Exception(NoAccess); }
///
/// 发送临时消息
///
/// QQ
/// 发送的消息
public virtual void SendTempMessage(uint QQ, string Message) { throw new Exception(NoAccess); }
///
/// 同意好友添加
///
///
/// 3:同意并添加对方为好友;4:同意;5:拒绝
/// 理由
public virtual void AerifyAddMe(uint QQ, byte Agree = 4, string Message = "") { throw new Exception(NoAccess); }
///
/// 同意用户入群
///
///
///
///
///
public virtual void AerifyAddGroup(uint groupId, uint QQ, bool Agree = true, string Message = "") { throw new Exception(NoAccess); }
///
/// 发送好友图片消息
///
/// QQ号
/// 消息内容
public virtual void SendFriendImage(uint QQ, string ImageSrc) { throw new Exception(NoAccess); }
///
/// 发送群消息
///
/// 群号
/// 图片地址,支持本机或网络图片
public virtual void SendGroupMessage(uint GroupId, string Message) { throw new Exception(NoAccess); }
///
/// 发送消息
///
/// 发送至
/// 发送的内容
/// 是否群消息
/// 临时会话?
public virtual Task SendMessage(uint username, string message, bool isGroup = false, bool isTemp = false) { return null; }
///
/// 发送群图片消息
///
/// 群号
/// 图片地址,支持本机或网络图片
public virtual void SendGroupImage(uint GroupId, string ImageSrc) { throw new Exception(NoAccess); }
///
/// 发送视频消息
///
/// 发送给谁
/// 图片地址,支持本机本地
//public virtual void SendFriendVideo(uint toUsername, string videoSrc) { throw new Exception(NoAccess); }
///
/// 发送视频消息
///
/// 群号
/// 图片地址,支持本机本地
//public virtual void SendGroupVideo(uint GroupId, string ImageSrc) { throw new Exception(NoAccess); }
///
/// 发送日志
///
/// 日志内容
protected void OnLog(string Message)
{
ChatClient.QQEvents.OnEvent(new Events.QQLogEvents(this) { Message = $"QQ:{QQ}->{Message}" });
}
}
}