Example #1
0
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult()
            {
                Result   = true,
                SendFlag = true,
            };

            //检查额度限制
            if (QuotaHelper.QuotaCheck(e.FromGroup, e.FromQQ) is false)
            {
                return(result);
            }
            PublicVariables.ReadOrderandAnswer();

            SendText sendText = new SendText();

            sendText.SendID = e.FromGroup;
            result.SendObject.Add(sendText);
            if (e.Message.Text.Trim().Length == GetOrderStr().Length)
            {
                sendText.MsgToSend.Add("指令无效,请在指令后添加pid");
                return(result);
            }
            if (!int.TryParse(e.Message.Text.Substring(GetOrderStr().Length).Replace(" ", ""), out int pid))
            {
                sendText.MsgToSend.Add("指令无效,检查是否为纯数字");
                return(result);
            }
            result.SendFlag = false;
            e.FromGroup.SendGroupMessage($"正在查询pid={pid}的插画信息,请等待……");
            IllustInfo illustInfo = PixivAPI.GetIllustInfo(pid);

            e.FromGroup.SendGroupMessage(illustInfo.IllustText);
            var message = e.FromGroup.SendGroupMessage(illustInfo.IllustCQCode);

            if (illustInfo.R18_Flag)
            {
                IniConfig ini  = MainSave.ConfigMain;
                Task      task = new Task(() =>
                {
                    Thread.Sleep(ini.Object["R18"]["RevokeTime"] * 1000);
                    e.CQApi.RemoveMessage(message.Id);
                }); task.Start();
            }
            return(result);
        }
Example #2
0
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult()
            {
                Result   = true,
                SendFlag = true,
            };

            //检查额度限制
            if (QuotaHelper.QuotaCheck(e.FromGroup, e.FromQQ) is false)
            {
                return(result);
            }
            PublicVariables.ReadOrderandAnswer();

            SendText sendText = new SendText();

            sendText.SendID = e.FromGroup;
            result.SendObject.Add(sendText);

            string keyword = e.Message.Text.Replace(" ", "").Substring(GetOrderStr().Length);

            e.FromGroup.SendGroupMessage($"正在查询关键字为{keyword}的插画信息,请等待……");
            IllustInfo illustInfo = PixivAPI.GetHotSearch(keyword);

            e.FromGroup.SendGroupMessage(illustInfo.IllustText);
            var message = e.FromGroup.SendGroupMessage(illustInfo.IllustCQCode);

            if (illustInfo.R18_Flag)
            {
                IniConfig ini  = MainSave.ConfigMain;
                Task      task = new Task(() =>
                {
                    Thread.Sleep(PublicVariables.R18_RevokeTime * 1000);
                    e.CQApi.RemoveMessage(message.Id);
                }); task.Start();
            }
            return(result);
        }
Example #3
0
        public override (List <NetTask>, ExtractedInfo) Extract(string url, IExtractorOption option = null)
        {
            if (!PixivAPI.Auth(Settings.Instance.Model.PixivSettings.Id, Settings.Instance.Model.PixivSettings.Password))
            {
                throw new ExtractorException("Authentication error! Check setting.json/PixivSetting.");
            }

            var match = ValidUrl.Match(url).Groups;

            if (option == null)
            {
                option = new PixivExtractorOption {
                    Type = ExtractorType.Works
                }
            }
            ;

            if (match[2].Value.StartsWith("member") && option.ExtractInformation == false)
            {
                var user  = PixivAPI.GetUsersAsync(match["id"].Value.ToInt()).Result;
                var works = PixivAPI.GetUsersWorksAsync(match["id"].Value.ToInt(), 1, 10000000).Result;

                option.SimpleInfoCallback?.Invoke($"{user[0].Name} ({user[0].Account})");

                option.ThumbnailCallback?.Invoke(NetTask.MakeDefault(user[0].ProfileImageUrls.Px170x170));

                var result = new List <NetTask>();

                foreach (var work in works)
                {
                    if (work.PageCount > 1)
                    {
                        ;
                    }
                    if (work.Type == null || work.Type == "illustration")
                    {
                        var task = NetTask.MakeDefault(work.ImageUrls.Large);
                        task.Filename = work.ImageUrls.Large.Split('/').Last();
                        task.SaveFile = true;
                        task.Referer  = url;
                        task.Format   = new ExtractorFileNameFormat
                        {
                            Artist  = user[0].Name,
                            Account = user[0].Account,
                            Id      = user[0].Id.Value.ToString(),
                            FilenameWithoutExtension = Path.GetFileNameWithoutExtension(work.ImageUrls.Large.Split('/').Last()),
                            Extension = Path.GetExtension(work.ImageUrls.Large.Split('/').Last()).Replace(".", "")
                        };
                        result.Add(task);
                    }
                    else if (work.Type == "ugoira")
                    {
                        var ugoira_data = PixivAPI.GetUgoiraAsync(work.Id.ToString()).Result;
                        var task        = NetTask.MakeDefault(ugoira_data.ZipUrls.Medium);
                        task.Filename = ugoira_data.ZipUrls.Medium.Split('/').Last();
                        task.SaveFile = true;
                        task.Referer  = url;
                        var pptask = new PostprocessorTask();
                        pptask.Postprocessor = new UgoiraPostprocessor {
                            Frames = ugoira_data.Frames
                        };
                        task.PostProcess = pptask;
                        task.Format      = new ExtractorFileNameFormat
                        {
                            Artist  = user[0].Name,
                            Account = user[0].Account,
                            Id      = user[0].Id.Value.ToString(),
                            FilenameWithoutExtension = Path.GetFileNameWithoutExtension(ugoira_data.ZipUrls.Medium.Split('/').Last()),
                            Extension = Path.GetExtension(ugoira_data.ZipUrls.Medium.Split('/').Last()).Replace(".", "")
                        };
                        result.Add(task);
                    }
                }

                result.ForEach(task => task.Format.Extractor = GetType().Name.Replace("Extractor", ""));
                return(result, new ExtractedInfo {
                    Type = ExtractedInfo.ExtractedType.UserArtist
                });
            }
            else if (option.ExtractInformation == true)
            {
                var user = PixivAPI.GetUsersAsync(match["id"].Value.ToInt()).Result;
                return(null, null /*user*/);
            }

            return(null, null);
        }