Ejemplo n.º 1
0
        public bool SetPetPic(MsgInformationEx MsgDTO, object[] param)
        {
            var osPerson = OSPerson.GetPerson(MsgDTO.FromQQ);

            if (osPerson.Golds < 300)
            {
                MsgSender.PushMsg(MsgDTO, $"你的金币余额不足({osPerson.Golds.CurencyFormat()}/{300.CurencyFormat()})");
                return(false);
            }

            if (!WaiterSvc.WaitForConfirm_Gold(MsgDTO, 300))
            {
                MsgSender.PushMsg(MsgDTO, "操作取消!");
                return(false);
            }

            var info = WaiterSvc.WaitForInformation(MsgDTO, "请上传图片(不能超过300KB)!",
                                                    information => information.FromGroup == MsgDTO.FromGroup && information.FromQQ == MsgDTO.FromQQ &&
                                                    !string.IsNullOrEmpty(Utility.ParsePicGuid(information.Msg)), 10);

            if (info == null)
            {
                MsgSender.PushMsg(MsgDTO, "操作取消!");
                return(false);
            }

            var bindai = BindAiSvc[MsgDTO.BindAi];

            var picGuid    = Utility.ParsePicGuid(info.Msg);
            var imageCache = Utility.ReadImageCacheInfo(picGuid, bindai.ImagePath);

            if (imageCache == null)
            {
                MsgSender.PushMsg(MsgDTO, "未读取到图片!");
                return(false);
            }

            var fileName = $"PetPic-{MsgDTO.FromQQ}.{imageCache.type}";

            if (!Utility.DownloadImage(imageCache.url, CachePath + fileName))
            {
                MsgSender.PushMsg(MsgDTO, "图片下载失败,请稍后再试!");
                return(false);
            }

            var picFile = new FileInfo(CachePath + fileName);

            if (picFile.Length / 1024 > 300)
            {
                MsgSender.PushMsg(MsgDTO, "图片过大,请选择较小的图片重新上传!", true);
                picFile.Delete();
                return(false);
            }

            osPerson.Golds -= 300;
            osPerson.Update();

            MsgSender.PushMsg(MsgDTO, "上传成功!待审核通过后方可生效!");
            var review = new PicReviewRecord()
            {
                GroupNum = MsgDTO.FromGroup,
                QQNum    = MsgDTO.FromQQ,
                Usage    = "宠物头像",
                PicName  = picFile.Name
            };

            PicReviewSvc.AddReview(review);

            return(true);
        }
Ejemplo n.º 2
0
        public override void Initialization()
        {
            base.Initialization();

            PicReviewSvc.Register("宠物头像", SetPetPicCallBack);
        }
Ejemplo n.º 3
0
 public bool PicReview(MsgInformationEx MsgDTO, object[] param)
 {
     PicReviewSvc.Review(MsgDTO);
     return(true);
 }