示例#1
0
        /// <summary>
        /// 自动获取B站动态
        /// </summary>
        /// <param name="cqApi">CQApi</param>
        public static async void BiliUpdateCheck(CQApi cqApi)
        {
            //读取配置文件
            Config config       = new Config(cqApi.GetLoginQQ().Id);
            Module moduleEnable = config.LoadedConfig.ModuleSwitch;
            List <GroupSubscription> Subscriptions = config.LoadedConfig.SubscriptionConfig.GroupsConfig;
            //数据库
            SubscriptionDBHelper dbHelper = new SubscriptionDBHelper(cqApi);

            //检查模块是否启用
            if (!moduleEnable.Bili_Subscription || !moduleEnable.PCR_Subscription)
            {
                return;
            }
            foreach (GroupSubscription subscription in Subscriptions)
            {
                //PCR动态订阅
                if (subscription.PCR_Subscription)
                {
                    await GetDynamic(cqApi, 353840826, subscription.GroupId, dbHelper);
                }
                //臭DD的订阅
                foreach (long biliUser in subscription.SubscriptionId)
                {
                    await GetDynamic(cqApi, biliUser, subscription.GroupId, dbHelper);
                }
            }
        }
示例#2
0
 public TimerInit(CQApi cqApi, int updateSpan)
 {
     subscriptionThread = new Timer(SubscriptionEvent,                  //事件处理
                                    cqApi,                              //酷Q API
                                    new TimeSpan(0),                    //即刻执行
                                    new TimeSpan(0, 0, 0, updateSpan)); //设置刷新间隔
 }
        /// <summary>
        /// 使用原始数据初始化 <see cref="GroupMemberInfo"/> 类的新实例
        /// </summary>
        /// <param name="api">用于获取信息的实例</param>
        /// <param name="cipherBytes">原始数据</param>
        /// <exception cref="ArgumentNullException">当参数 cipherBytes 为 null 时引发此异常</exception>
        /// <exception cref="InvalidDataException">原始数据格式错误</exception>
        public GroupMemberInfo(CQApi api, byte[] cipherBytes)
        {
            if (cipherBytes == null)
            {
                throw new ArgumentNullException("cipherBytes");
            }

            using (BinaryReader reader = new BinaryReader(new MemoryStream(cipherBytes)))
            {
                if (reader.Length() < 40)
                {
                    throw new InvalidDataException("读取失败, 原始数据格式错误");
                }
                this.Group             = new Group(api, reader.ReadInt64_Ex());
                this.QQ                = new QQ(api, reader.ReadInt64_Ex());
                this.Nick              = reader.ReadString_Ex(CQApi.DefaultEncoding);
                this.Card              = reader.ReadString_Ex(CQApi.DefaultEncoding);
                this.Sex               = (QQSex)reader.ReadInt32_Ex();
                this.Age               = reader.ReadInt32_Ex();
                this.Area              = reader.ReadString_Ex(CQApi.DefaultEncoding);
                this.JoinGroupDateTime = reader.ReadInt32_Ex().ToDateTime();
                this.LastSpeakDateTime = reader.ReadInt32_Ex().ToDateTime();
                this.Level             = reader.ReadString_Ex(CQApi.DefaultEncoding);
                this.MemberType        = (QQGroupMemberType)reader.ReadInt32_Ex();
                this.IsBadRecord       = reader.ReadInt32_Ex() == 1;
                this.ExclusiveTitle    = reader.ReadString_Ex(CQApi.DefaultEncoding);
                this.LastSpeakDateTime = reader.ReadInt32_Ex().ToDateTime();
                this.IsAllowEditorCard = reader.ReadInt32_Ex() == 1;
            }
        }
示例#4
0
        public void OnMessage(object sender, CQEventEventArgs e)
        {
            Match  m;
            string msg = null;

            if (e.GetType() == typeof(CQGroupMessageEventArgs))
            {
                msg = ((CQGroupMessageEventArgs)e).Message.Text;
            }
            else
            {
                msg = ((CQPrivateMessageEventArgs)e).Message.Text;
            }

            if ((m = Commands[0].Match(msg)).Success)
            {
                Ai.Reply(e, " 欢迎使用憨批链接生成器,输入格式\"生成!!{url}!!{title}!!{content}(optional:!!{image_url})\"");
            }
            else if ((m = Commands[1].Match(msg)).Success)
            {
                Ai.Reply(e, CQApi.CQCode_ShareLink(m.Groups[1].Value, m.Groups[2].Value, m.Groups[3].Value, m.Groups[4].Value).ToSendString());
            }
            else if ((m = Commands[2].Match(msg)).Success)
            {
                Ai.Reply(e, CQApi.CQCode_ShareLink(m.Groups[1].Value, m.Groups[2].Value, m.Groups[3].Value).ToSendString());
            }
        }
示例#5
0
        /// <summary>
        /// 初始化 <see cref="QQMessage"/> 类的新实例
        /// </summary>
        /// <param name="api">用于获取信息的实例</param>
        /// <param name="id">消息ID</param>
        /// <param name="msg">消息内容</param>
        /// <param name="isRegex">是否正则</param>
        public QQMessage(CQApi api, int id, string msg, bool isRegex)
        {
            if (api == null)
            {
                throw new ArgumentNullException("api");
            }

            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }

            this.CQApi          = api;
            this.Id             = id;
            this.Text           = msg;
            this.IsRegexMessage = isRegex;
            this.RegexResult    = null;

            #region --正则事件解析--
            if (isRegex)
            {
                // 进行正则事件消息解析
                this.RegexResult = ParseRegexMessage(msg);
            }
            #endregion
        }
示例#6
0
 public ReceivedMessage(CQApi api, long groupId, long qqId, int id, string msg, bool isRegex = false)
 {
     Type    = "group";
     Group   = new Group(api, groupId);
     QQ      = new QQ(api, qqId);
     Message = new QQMessage(api, id, msg, isRegex);
 }
示例#7
0
        public static CQCode GetIllustPic(Pixiv_PID info)
        {
            string path       = Path.Combine(Environment.CurrentDirectory, "data", "image", "LoliconPic", $"{info.data.id}.jpg");
            string pathcqcode = Path.Combine("LoliConPic", $"{info.data.id}.jpg");

            using (HttpWebClient http = new HttpWebClient())
            {
                http.TimeOut = 5000;
                try
                {
                    if (!File.Exists(path))
                    {
                        string url = string.Empty;
                        url = info.data.imageUrls[0].original.Replace("pximg.net", "pixiv.cat");

                        http.DownloadFile(url, path);
                        CommonHelper.AntiHX(path);
                        MainSave.CQLog.Info("插画详情", "图片下载成功,正在尝试发送");
                    }
                }
                catch (Exception e)
                {
                    MainSave.CQLog.Info("插画详情", $"图片下载失败,错误信息:{e.Message}");
                    return(CQApi.CQCode_Image("Error.jpg"));
                }
            }
            return(CQApi.CQCode_Image(pathcqcode));
        }
示例#8
0
        public static void Main()
        {
            Native.Csharp.Sdk.Cqp.CQApi.Sender = new TaskReceiver();
            //传递假的container
            Register(FakeCoolQ);
            //注册假的CQ
            CQApi = new CQApi(404233);
            CQLog = new CQLog(404233);
            //取得注册的接口
            Startup      = FakeCoolQ.Resolve <ICQStartup>("酷Q启动事件");
            GroupMessage = FakeCoolQ.Resolve <IGroupMessage>("群消息处理");
            //触发假的启动事件
            Startup.CQStartup(null, new CQStartupEventArgs(CQApi, CQLog, 0, 0, "startup", "CQStartup", 0));

            //启动Tcp监听线程
            Thread t = new Thread(new ThreadStart(WebProcess.Listening));

            t.Start();

            //触发假的群聊事件
            if (NotTestInputing)
            {
                return;
            }
            while (true)
            {
                string content = Console.ReadLine();
                Console.WriteLine($"↓ 你:\n{content}");
                GroupMessage.GroupMessage(null, new CQGroupMessageEventArgs(CQApi, CQLog, 0, 0, "groupmessage", "CQGroupMessage", 0, 0,
                                                                            msgid, GroupID, QQID, "", content, false));
                msgid++;
            }
        }
示例#9
0
        /// <summary>
        /// 使用指定的原始数据初始化 <see cref="GroupInfo"/> 类的新实例
        /// </summary>
        /// <param name="api">用于获取信息的实例</param>
        /// <param name="cipherBytes">原始数据</param>
        /// <param name="oldApi">是否兼容老久API</param>
        /// <exception cref="ArgumentNullException">当参数 cipherBytes 为 null 时引发此异常</exception>
        /// <exception cref="InvalidDataException">原始数据格式错误</exception>
        public GroupInfo(CQApi api, byte[] cipherBytes, bool oldApi = false)
        {
            if (cipherBytes == null)
            {
                throw new ArgumentNullException("cipherBytes");
            }

            this._isOldApi = oldApi;

            using (BinaryReader reader = new BinaryReader(new MemoryStream(cipherBytes)))
            {
                if (reader.Length() < 10)
                {
                    throw new InvalidDataException("读取失败, 原始数据格式错误");
                }

                this.Group = new Group(api, reader.ReadInt64_Ex());
                this.Name  = reader.ReadString_Ex(CQApi.DefaultEncoding);
                if (!oldApi)
                {
                    this.CurrentMemberCount = reader.ReadInt32_Ex();
                    this.MaxMemberCount     = reader.ReadInt32_Ex();
                }
            }
        }
示例#10
0
 /// <summary>
 /// 初始化 <see cref="CQFriendAddEventArgs"/> 类的新实例
 /// </summary>
 /// <param name="api">酷Q的接口实例</param>
 /// <param name="log">酷Q的日志实例</param>
 /// <param name="id">事件Id</param>
 /// <param name="type">事件类型</param>
 /// <param name="name">事件名称</param>
 /// <param name="function">函数名称</param>
 /// <param name="priority">默认优先级</param>
 /// <param name="subType">子类型</param>
 /// <param name="sendTime">发送时间</param>
 /// <param name="fromQQ">来源QQ</param>
 public CQFriendAddEventArgs(CQApi api, CQLog log, int id, int type, string name, string function, uint priority, int subType, int sendTime, long fromQQ)
     : base(api, log, id, type, name, function, priority)
 {
     this.SubType  = (CQFriendAddType)subType;
     this.SendTime = sendTime.ToDateTime();
     this.FromQQ   = new QQ(api, fromQQ);
 }
示例#11
0
        public static string Join(long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛");
            }

            //检查是否开始
            if (ps.Flag != "")
            {
                return(CQApi.CQCode_At(uid) + "飞花令已经开始了!不能中途参加!");
            }

            //检查是否参加
            foreach (var tmp in ps.Players)
            {
                if (tmp.Uid == uid)
                {
                    return(CQApi.CQCode_At(uid) + "你已经加入比赛!");
                }
            }
            ps.Players.Add(new Player(uid));
            return(CQApi.CQCode_At(uid) + "加入比赛成功!" + CQApi.CQCode_At(ps.CreateUid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!");
        }
示例#12
0
    public static void AppStart(CQApi _CQApi, CQLog _CQLog)
    {
        CQApi = _CQApi;
        CQLog = _CQLog;
        InitAdminFile();

        if (ins == null)
        {
            ins = new List <TimeCheck>();
        }
        string        path = CQApi.AppDirectory;
        DirectoryInfo root = new DirectoryInfo(path);

        foreach (FileInfo f in root.GetFiles())
        {
            string name = f.Name;
            if (name.Contains("config-"))
            {
                int       start = name.IndexOf("-") + 1;
                int       end   = name.IndexOf(".json");
                long      group = long.Parse(name.Substring(start, end - start));
                TimeCheck temp  = new TimeCheck(group);
                ins.Add(temp);
                string json = ReadFromFile(path + name);
                temp.Initialize(json);
            }
        }
    }
示例#13
0
 /// <summary>
 /// 返回此实例等效的CQ码形式
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     if (this._originalString == null)
     {
         if (this._items.Count == 0)
         {
             // 特殊CQ码, 抖动窗口
             this._originalString = string.Format("[CQ:{0}]", _type.GetDescription());
         }
         else
         {
             // 普通CQ码, 带参数
             StringBuilder builder = new StringBuilder();
             builder.Append("[CQ:");
             builder.Append(this._type.GetDescription());                         // function
             foreach (KeyValuePair <string, string> item in this._items)
             {
                 builder.AppendFormat(",{0}={1}", item.Key, CQApi.CQEnCode(item.Value, true));
             }
             builder.Append("]");
             this._originalString = builder.ToString();
         }
     }
     return(this._originalString);
 }
示例#14
0
        public static string Start(long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛");
            }

            //检查是否开始
            if (ps.Flag != "")
            {
                return(CQApi.CQCode_At(uid) + "飞花令已经开始了!");
            }

            //检查是否发起者
            if (ps.CreateUid != uid)
            {
                return(CQApi.CQCode_At(uid) + "不是创建者无法开始飞花令!\n" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!");
            }

            if (ps.Players.Count < 2)
            {
                return(CQApi.CQCode_At(uid) + "人数不足!无法开始比赛!\n请选手们回复【飞花令加入】参与!");
            }

            ps.Flag = PoemData.GetFlag();
            return($"飞花令开始!\n系统出题,关键字为【{ps.Flag}】\n请回复带有【{ps.Flag}】的诗句!\n(直接回复诗句即可)\n" +
                   $"现在请{CQApi.CQCode_At(ps.Players[0].Uid)}首先开始回复!\n(PS:如果暂时想不出来,请回复【飞花令跳过】)");
        }
示例#15
0
        /// <summary>
        /// 使用 CQ码 字符串初始化 <see cref="CQCode"/> 类的新实例
        /// </summary>
        /// <param name="str">CQ码字符串 或 包含CQ码的字符串</param>
        private CQCode(string str)
        {
            this._originalString = str;

            #region --解析 CqCode--
            Match match = _regices.Value[0].Match(str);
            if (!match.Success)
            {
                throw new FormatException("无法解析所传入的字符串, 字符串非CQ码格式!");
            }
            #endregion

            #region --解析CQ码类型--
            if (!System.Enum.TryParse <CQFunction> (match.Groups[1].Value, true, out _type))
            {
                this._type = CQFunction.Unknown;                    // 解析不出来的时候, 直接给一个默认
            }
            #endregion

            #region --解析键值对--
            MatchCollection collection = _regices.Value[1].Matches(match.Groups[2].Value);
            this._items = new Dictionary <string, string> (collection.Count);
            foreach (Match item in collection)
            {
                this._items.Add(item.Groups[1].Value, CQApi.CQDeCode(item.Groups[2].Value));
            }
            #endregion
        }
示例#16
0
 /// <summary>
 /// 初始化 <see cref="CQPrivateMessageEventArgs"/> 类的新实例
 /// </summary>
 /// <param name="api">酷Q的接口实例</param>
 /// <param name="log">酷Q的日志实例</param>
 /// <param name="id">事件id</param>
 /// <param name="type">事件类型</param>
 /// <param name="name">事件名称</param>
 /// <param name="function">事件函数名</param>
 /// <param name="priority">事件优先级</param>
 /// <param name="subType">消息子类型</param>
 /// <param name="msgId">消息ID</param>
 /// <param name="fromQQ">来源QQ</param>
 /// <param name="msg">消息内容</param>
 /// <param name="isRegex">是否为正则消息</param>
 public CQPrivateMessageEventArgs(CQApi api, CQLog log, int id, int type, string name, string function, uint priority, int subType, int msgId, long fromQQ, string msg, bool isRegex)
     : base(api, log, id, type, name, function, priority)
 {
     this.SubType = (CQPrviateMessageType)subType;
     this.FromQQ  = new QQ(api, fromQQ);
     this.Message = new QQMessage(api, msgId, msg, isRegex);
 }
示例#17
0
 /// <summary>
 /// 初始化 <see cref="CQStatusEventArgs"/> 类的新实例
 /// </summary>
 /// <param name="api">酷Q的接口实例</param>
 /// <param name="log">酷Q的日志实例</param>
 /// <param name="id">事件Id</param>
 /// <param name="name">名称</param>
 /// <param name="title">标题</param>
 /// <param name="function">函数名</param>
 /// <param name="period">刷新间隔</param>
 public CQStatusEventArgs(CQApi api, CQLog log, int id, string name, string title, string function, long period)
     : base(api, log, function)
 {
     this.Id     = id;
     this.Name   = name;
     this.Title  = title;
     this.Period = new TimeSpan(period * TimeSpan.TicksPerMillisecond);
 }
示例#18
0
        /// <summary>
        /// 由托管环境初始化的 <see cref="CQMenuExport"/> 的新实例
        /// </summary>
        static CQMenuExport()
        {
            api = AppInfo.UnityContainer.Resolve <CQApi> (AppInfo.Id);
            log = AppInfo.UnityContainer.Resolve <CQLog> (AppInfo.Id);

            // 调用方法进行实例化
            ResolveBackcall();
        }
 public string Handler(CQGroupMessageEventArgs e, Base_SQLHelper.SQLHelperData b)
 {
     if (SQL.UserExists(b, e.FromQQ))
     {
         SQL.AddFavorEveryChat(b, e.FromQQ);
     }
     return(CQApi.CQCode_Image("pixiv/" + new Base_FileHelper().RandomGetImg("data/image/pixiv")).ToString());
 }
 /// <summary>
 /// 使用指定的密文初始化 <see cref="BasisStreamModel"/> 类的新实例
 /// </summary>
 /// <param name="api">模型使用的 <see cref="Cqp.CQApi"/></param>
 /// <param name="cipherBytes">模型使用的解密密文字节数组</param>
 /// <exception cref="ArgumentNullException">参数: api 或 cipherBytes 为 null</exception>
 public BasisStreamModel(CQApi api, byte[] cipherBytes)
     : base(api)
 {
     using (BinaryReader reader = new BinaryReader(new MemoryStream(cipherBytes)))
     {
         this.Initialize(reader);
     }
 }
 /// <summary>
 /// 初始化 <see cref="CQGroupManageChangeEventArgs"/> 类的新实例
 /// </summary>
 /// <param name="api">酷Q的接口实例</param>
 /// <param name="log">酷Q的日志实例</param>
 /// <param name="id">事件Id</param>
 /// <param name="type">事件类型</param>
 /// <param name="name">事件名称</param>
 /// <param name="function">函数名称</param>
 /// <param name="priority">默认优先级</param>
 /// <param name="subType">子类型</param>
 /// <param name="sendTime">发送时间</param>
 /// <param name="fromGroup">来源群</param>
 /// <param name="beingOperateQQ">被操作QQ</param>
 public CQGroupManageChangeEventArgs(CQApi api, CQLog log, int id, int type, string name, string function, uint priority, int subType, int sendTime, long fromGroup, long beingOperateQQ)
     : base(api, log, id, type, name, function, priority)
 {
     this.SubType        = (CQGroupManageChangeType)subType;
     this.SendTime       = sendTime.ToDateTime();
     this.FromGroup      = new Group(api, fromGroup);
     this.BeingOperateQQ = new QQ(api, beingOperateQQ);
 }
示例#22
0
 /// <summary>
 /// 初始化 <see cref="CQGroupUploadEventArgs"/> 类的新实例
 /// </summary>
 /// <param name="api">酷Q的接口实例</param>
 /// <param name="log">酷Q的日志实例</param>
 /// <param name="id">事件Id</param>
 /// <param name="type">事件类型</param>
 /// <param name="name">事件名称</param>
 /// <param name="function">函数名称</param>
 /// <param name="priority">默认优先级</param>
 /// <param name="subType">子类型</param>
 /// <param name="sendTime">发送时间</param>
 /// <param name="fromGroup">来源群</param>
 /// <param name="fromQQ">来源QQ</param>
 /// <param name="file">文件信息</param>
 public CQGroupUploadEventArgs(CQApi api, CQLog log, int id, int type, string name, string function, uint priority, int subType, int sendTime, long fromGroup, long fromQQ, string file)
     : base(api, log, id, type, name, function, priority)
 {
     this.SubType   = (CQGroupFileUploadType)subType;
     this.SendTime  = sendTime.ToDateTime();
     this.FromGroup = new Group(api, fromGroup);
     this.FromQQ    = new QQ(api, fromQQ);
     this.FileInfo  = new GroupFileInfo(file);
 }
示例#23
0
        private string GetResultStr(bool sendImg = false)
        {
            string rs;
            int    star3Count = 0;
            int    star2Count = 0;
            int    star1Count = 0;
            int    pigStone   = 0;
            string star3Name  = string.Empty;

            if (GetResult.ContainsKey(1) && GetResult[1] != null)
            {
                foreach (var temp in GetResult[1])
                {
                    star1Count += temp.Value;
                    pigStone   += temp.Value;
                }
            }
            if (GetResult.ContainsKey(2) && GetResult[1] != null)
            {
                foreach (var temp in GetResult[2])
                {
                    star2Count += temp.Value;
                    pigStone   += temp.Value * 10;
                }
            }
            if (GetResult.ContainsKey(3) && GetResult[3] != null)
            {
                int i = 1;
                foreach (var temp in GetResult[3])
                {
                    star3Count += temp.Value;
                    pigStone   += temp.Value * 50;
                    star3Name  += temp.Key + "×" + temp.Value + (i++ % 3 == 0?"\n":"  ");
                }
            }
            string ImgP = string.Empty;
            CQCode imgC = null;

            if (sendImg)
            {
                ImgP = GetResultImg();
                if (ImgP != null)
                {
                    imgC = CQApi.CQCode_Image(ImgP);
                    ImgP = imgC.ToSendString();
                }
                else
                {
                    ImgP = string.Empty;
                }
            }
            return(rs = "素敵な仲間が増えますよ!\n" + ImgP +
                        MyString.str["恭喜骑士君获得"] + "\n" +
                        star3Name + "\n" +
                        "★★★×" + star3Count + "★★×" + star2Count + "★×" + star1Count + "\n" +
                        MyString.str["获得母猪石×"] + pigStone);
        }
示例#24
0
 /// <summary>
 /// 初始化 <see cref="CQEventEventArgs"/> 类的新实例
 /// </summary>
 /// <param name="api">酷Q的接口实例</param>
 /// <param name="log">酷Q的日志实例</param>
 /// <param name="id">事件id</param>
 /// <param name="type">类型</param>
 /// <param name="name">名称</param>
 /// <param name="function">函数名</param>
 /// <param name="priority">默认优先级</param>
 public CQEventEventArgs(CQApi api, CQLog log, int id, int type, string name, string function, uint priority)
     : base(api, log, function)
 {
     this.Id       = id;
     this.Type     = (CQMessageEventType)type;
     this.Name     = name;
     this.Priority = priority;
     this.Handler  = false;
 }
示例#25
0
 /// <summary>
 /// 存在非法参数时的响应
 /// </summary>
 /// <param name="e">CQGroupMessageEventArgs</param>
 /// <param name="commandType">指令类型</param>
 /// <param name="errDescription">错误描述</param>
 public static void GetIllegalArgs(CQGroupMessageEventArgs e, PCRGuildCmdType commandType, string errDescription)
 {
     ConsoleLog.Warning("PCR公会管理", "非法参数");
     e.FromGroup.SendGroupMessage(
         CQApi.CQCode_At(e.FromQQ.Id),
         "\n非法参数请重新输入指令" +
         $"\n错误:{errDescription}" +
         $"\n指令帮助:{GetCommandHelp(commandType)}");
 }
 /// <summary>
 /// 初始化 <see cref="CQFriendAddRequestEventArgs"/> 类的新实例
 /// </summary>
 /// <param name="api">酷Q的接口实例</param>
 /// <param name="log">酷Q的日志实例</param>
 /// <param name="id">事件Id</param>
 /// <param name="type">事件类型</param>
 /// <param name="name">事件名称</param>
 /// <param name="function">函数名称</param>
 /// <param name="priority">默认优先级</param>
 /// <param name="subType">子类型</param>
 /// <param name="sendTime">发送时间</param>
 /// <param name="fromQQ">来源QQ</param>
 /// <param name="msg">附言</param>
 /// <param name="responseFlag">反馈标识</param>
 public CQFriendAddRequestEventArgs(CQApi api, CQLog log, int id, int type, string name, string function, uint priority, int subType, int sendTime, long fromQQ, string msg, string responseFlag)
     : base(api, log, id, type, name, function, priority)
 {
     this.SubType       = (CQFriendAddRequestType)subType;
     this.SendTime      = sendTime.ToDateTime();
     this.FromQQ        = new QQ(api, fromQQ);
     this.AppendMessage = msg;
     this.Request       = new QQRequest(api, responseFlag);
 }
示例#27
0
 /// <summary>
 /// 初始化 <see cref="Discuss"/> 类的新实例
 /// </summary>
 /// <param name="api">用于获取信息的实例</param>
 /// <param name="discussId">用于初始化实例的QQ号</param>
 public Discuss(CQApi api, long discussId)
 {
     this.CQApi = api;
     if (discussId < MinValue)
     {
         throw new ArgumentOutOfRangeException("discussId");
     }
     this.Id = discussId;
 }
示例#28
0
        /// <summary>
        /// 使用指定的 <see cref="Cqp.CQApi"/> 初始化当前类的新实例
        /// </summary>
        /// <param name="api">模型使用的 <see cref="Cqp.CQApi"/></param>
        /// <exception cref="ArgumentNullException">参数: api 为 null</exception>
        public BasisModel(CQApi api)
        {
            if (api == null)
            {
                throw new ArgumentNullException("api");
            }

            this.CQApi = api;
        }
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult
            {
                Result   = true,
                SendFlag = true,
            };
            SendText sendText = new SendText
            {
                SendID = e.FromGroup,
            };

            //检查额度限制
            if (QuotaHelper.QuotaCheck(e.FromGroup, e.FromQQ) is false)
            {
                return(result);
            }
            try
            {
                string tagName      = e.Message.Text.Substring(GetOrderStr().Length).Trim();
                var    searchResult = TagSearch(tagName);
                if (searchResult.Count > 0 && searchResult[0] != 0)
                {
                    int id  = searchResult.OrderBy(x => Guid.NewGuid().ToString()).First();
                    var pic = YandeRePic.GetYandePic(id);
                    Directory.CreateDirectory(Path.Combine(MainSave.ImageDirectory, "YandeRePic"));
                    e.FromGroup.SendGroupMessage(pic.ToString());
                    using (HttpWebClient http = new HttpWebClient()
                    {
                        TimeOut = 10000,
                        Encoding = Encoding.UTF8,
                        Proxy = MainSave.Proxy,
                        AllowAutoRedirect = true,
                    })
                    {
                        string fileName = Path.Combine(MainSave.ImageDirectory, "YandeRePic", $"{pic.ID}.jpg");
                        if (File.Exists(fileName) is false)
                        {
                            http.DownloadFile(pic.PicLargeURL, fileName);
                        }
                    }
                    sendText.MsgToSend.Add(CQApi.CQCode_Image(Path.Combine("YandeRePic", $"{pic.ID}.jpg")).ToSendString());
                }
                else
                {
                    sendText.MsgToSend.Add("没有找到结果呢,请查看是否使用了正确的tag名称");
                }
            }
            catch (Exception exc)
            {
                e.CQLog.Info("YandeReTag解析出错", $"错误信息: {exc.Message} 错误位置: {exc.StackTrace}");
                sendText.MsgToSend.Add("解析出错,查看日志获取详细信息");
            }
            result.SendObject.Add(sendText);
            return(result);
        }
示例#30
0
        /// <summary>
        /// 初始化 <see cref="QQ"/> 类的新实例
        /// </summary>
        /// <param name="api">模型使用的 <see cref="Cqp.CQApi"/></param>
        /// <param name="qqId">模型所托管QQ号的基础值</param>
        /// <exception cref="ArgumentNullException">参数: api 是 null</exception>
        /// <exception cref="ArgumentOutOfRangeException">QQ号超出范围</exception>
        public QQ(CQApi api, long qqId)
            : base(api)
        {
            if (qqId < QQ.MinValue)
            {
                throw new ArgumentOutOfRangeException("qqId");
            }

            this.Id = qqId;
        }