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

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

            var functionResult = CustomAPI_Image(e.Message.Text);

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

            var states = e.FromGroup.SendGroupMessage(functionResult.MsgToSend[0]);

            if (functionResult.HandlingFlag)//自动撤回
            {
                IniConfig ini  = MainSave.ConfigMain;
                Task      task = new Task(() =>
                {
                    Thread.Sleep(ini.Object["R18"]["RevokeTime"] * 1000);
                    e.CQApi.RemoveMessage(states.Id);
                }); task.Start();
            }
            return(result);
        }
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult()
            {
                Result   = true,
                SendFlag = false,
            };

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

            var functionResult = JsonDeserize_Image(e.Message.Text, e.FromGroup, e.FromQQ);

            if (functionResult == null)
            {
                return(result);
            }
            var staues = e.FromGroup.SendGroupMessage(functionResult.MsgToSend[0]);

            if (functionResult.HandlingFlag)//自动撤回
            {
                IniConfig ini  = MainSave.ConfigMain;
                Task      task = new Task(() =>
                {
                    Thread.Sleep(PublicVariables.R18_RevokeTime * 1000);
                    e.CQApi.RemoveMessage(staues.Id);
                }); task.Start();
            }
            return(result);
        }
        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);
        }
        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);
        }
        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
            {
                int yandeID = Convert.ToInt32(e.Message.Text.Split(' ')[1]);
                var t       = GetYandePic(yandeID);
                Directory.CreateDirectory(Path.Combine(MainSave.ImageDirectory, "YandeRePic"));
                e.FromGroup.SendGroupMessage(t.ToString());
                using (HttpWebClient http = new HttpWebClient()
                {
                    TimeOut = 10000,
                    Encoding = Encoding.UTF8,
                    Proxy = MainSave.Proxy,
                    AllowAutoRedirect = true,
                })
                {
                    string fileName = Path.Combine(MainSave.ImageDirectory, "YandeRePic", $"{t.ID}.jpg");
                    if (File.Exists(fileName) is false)
                    {
                        http.DownloadFile(t.PicLargeURL, fileName);
                    }
                }
                sendText.MsgToSend.Add(CQApi.CQCode_Image(Path.Combine("YandeRePic", $"{t.ID}.jpg")).ToSendString());
            }
            catch (Exception exc)
            {
                e.CQLog.Info("YandeReID解析出错", $"错误信息: {exc.Message} 错误位置: {exc.StackTrace}");
                sendText.MsgToSend.Add("解析出错,查看日志获取详细信息");
            }
            result.SendObject.Add(sendText);
            return(result);
        }
        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);
        }
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult()
            {
                Result   = true,
                SendFlag = false,
            };

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

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

            if (e.Message.CQCodes.Count != 0)
            {
                foreach (var item in e.Message.CQCodes)
                {
                    if (item.IsImageCQCode)
                    {
                        SauceNao_Call(item, e);
                        Thread.Sleep(1000);
                    }
                }
            }
            else
            {
                result.SendFlag = true;
                MainSave.SauceNao_Saves.Add(new DelayAPI_Save(e.FromGroup.Id, e.FromQQ.Id));
                sendText.MsgToSend.Add("请在接下来的一条消息内发送需要搜索的图片");
            }
            return(result);
        }
        public FunctionResult Progress(CQGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult()
            {
                Result   = true,
                SendFlag = false,
            };

            //检查额度限制
            if (QuotaHelper.QuotaCheck(e.FromGroup, e.FromQQ) is false)
            {
                return(result);
            }
            //拉取图片,处理时间受地区与网速限制
            var pic = GetLoliConPicHelper
                      .GetSetuPic(e.Message.Text.Substring(GetOrderStr().Length), out string objectTostring);

            pic.SendID = e.FromGroup.Id;
            try
            {
                SendText text = new SendText
                {
                    MsgToSend = new List <string>(),
                    SendID    = e.FromGroup,
                };
                objectTostring.Replace("<@>", e.FromQQ.CQCode_At().ToSendString());
                // 处理返回文本,替换可配置文本为结果,发送处理结果
                if (!string.IsNullOrWhiteSpace(objectTostring))
                {
                    text.MsgToSend.Add(objectTostring);
                }
                result.SendObject.Add(text);
                result.SendFlag = true;
                IniConfig ini = MainSave.ConfigMain;
                if (pic.HandlingFlag)//是否成功处理消息
                {
                    //TODO: Improve this code
                    //处理一番后发现, 成功发送时只有一个图片文本, 虽说不规范, 以后再说吧
                    var msg = e.FromGroup.SendGroupMessage(pic.MsgToSend[0]);
                    if (PublicVariables.R18_PicRevoke)//自动撤回
                    {
                        Task task = new Task(() =>
                        {
                            Thread.Sleep(PublicVariables.R18_RevokeTime * 1000);
                            e.CQApi.RemoveMessage(msg.Id);
                        }); task.Start();
                    }
                }
                else//处理消息失败
                {
                    result.SendFlag = true;
                    result.SendObject.Add(pic);
                    QuotaHelper.PlusMemberQuota(e.FromGroup.Id, e.FromQQ.Id);
                }
            }
            catch (Exception exc)
            {
                SendText text = new SendText
                {
                    MsgToSend = new List <string>(),
                    SendID    = e.FromGroup,
                };
                text.MsgToSend.Add($"发生未知错误,错误信息:在{exc.Source}上, 发生错误: {exc.Message}");
                result.SendObject.Add(text);
                result.SendFlag = true;
            }
            return(result);
        }