Exemplo n.º 1
0
        public static IntPtr CQ_getImage(int authCode, IntPtr file)
        {
            string filename = file.ToString(GB18030);
            string path     = $"data\\image\\{filename}.cqimg";

            if (File.Exists(path))
            {
                IniConfig ini = new IniConfig(path);
                ini.Load();
                if (ini.Object.ContainsKey("image") is false)
                {
                    return(Marshal.StringToHGlobalAnsi(string.Empty));
                }
                string        picurl = ini.Object["image"]["url"];
                HttpWebClient http   = new HttpWebClient {
                    TimeOut = 10000
                };
                http.DownloadFile(picurl, $"data\\image\\{filename}.jpg");
                FileInfo fileInfo = new FileInfo($"data\\image\\{filename}.jpg");
                return(Marshal.StringToHGlobalAnsi(fileInfo.FullName));
            }
            else
            {
                return(Marshal.StringToHGlobalAnsi(string.Empty));
            }
        }
Exemplo n.º 2
0
        public SearchPageViewModel()
        {
            ViewModelManager.SearchPageViewModel = this;
            SearchProgressVisibility             = Visibility.Visible;
            DataVisibility      = Visibility.Hidden;
            NoResultVisibility  = Visibility.Hidden;
            ClickBackCommand    = new DelegateCommand(new Action(() => PageManager.SearchPage.NavigationService.GoBack()));
            ClickNeteaseCommand = new DelegateCommand <object>(new Action <object>(ClickNeteaseExecute));
            ClickKugouCommand   = new DelegateCommand <object>(new Action <object>(ClickKugouExecute));
            ClickTencentCommand = new DelegateCommand <object>(new Action <object>(ClickTencentExecute));
            PrePlayCommand      = new DelegateCommand <object>(new Action <object>(PrePlayExecute));

            //搜索选项加载
            IniConfig ini = new IniConfig("Config.ini");

            ini.Load();
            try
            {
                SearchOption = ini.GetObject <SearchOptionModel>();
            }
            catch (ArgumentException)
            {
                SearchOption = new SearchOptionModel {
                    Kugou = true, Netease = true, Tencent = true
                };
                ini.SetObject(SearchOption);
                ini.Save();
            }
        }
Exemplo n.º 3
0
        private void ExtraConfig_Load(object sender, EventArgs e)
        {
            string path = CQSave.AppDirectory + "Config.ini";

            ini = new IniConfig(path);
            ini.Load();
            checkBox_TextGacha.Checked = (ini.Object["ExtraConfig"]["TextGacha"].GetValueOrDefault("0")) == "1" ? true : false;
            checkBox_Sql.Checked       = (ini.Object["ExtraConfig"]["ExecuteSql"].GetValueOrDefault("0")) == "1" ? true : false;
            radioButton_Picjpg.Checked = (ini.Object["ExtraConfig"]["ImageFormat"].GetValueOrDefault("jpg") == "jpg") ? true : false;
            radioButton_Picpng.Checked = (ini.Object["ExtraConfig"]["ImageFormat"].GetValueOrDefault("jpg") == "png") ? true : false;

            checkBox_SwBP1.Checked        = (ini.Object["ExtraConfig"]["SwitchBP1"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwBP10.Checked       = (ini.Object["ExtraConfig"]["SwitchBP10"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwJZA1.Checked       = (ini.Object["ExtraConfig"]["SwitchJZA1"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwJZA10.Checked      = (ini.Object["ExtraConfig"]["SwitchJZA10"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwJZB1.Checked       = (ini.Object["ExtraConfig"]["SwitchJZB1"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwJZB10.Checked      = (ini.Object["ExtraConfig"]["SwitchJZB10"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwKC1.Checked        = (ini.Object["ExtraConfig"]["SwitchKC1"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwKC10.Checked       = (ini.Object["ExtraConfig"]["SwitchKC10"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwQueDiamond.Checked = (ini.Object["ExtraConfig"]["SwitchQueDiamond"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwResSign.Checked    = (ini.Object["ExtraConfig"]["SwitchResSign"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwGetHelp.Checked    = (ini.Object["ExtraConfig"]["SwitchGetHelp"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwGetPool.Checked    = (ini.Object["ExtraConfig"]["SwitchGetPool"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwKaKin.Checked      = (ini.Object["ExtraConfig"]["SwitchKaKin"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwOpenGroup.Checked  = (ini.Object["ExtraConfig"]["SwitchOpenGroup"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwCloseGroup.Checked = (ini.Object["ExtraConfig"]["SwitchCloseGroup"].GetValueOrDefault("1") == "1") ? true : false;
            checkBox_SwOpenAdmin.Checked  = (ini.Object["ExtraConfig"]["SwitchOpenAdmin"].GetValueOrDefault("1") == "1") ? true : false;

            flag = true;
        }
Exemplo n.º 4
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            string    path = $@"{MainSave.AppDirectory}Config.ini";
            IniConfig ini  = new IniConfig(path);

            ini.Load();
            foreach (var uiitem in stackpanel_1.Children)
            {
                var textboxTemp = uiitem as TextBox;
                try
                {
                    if (uiitem.GetType().Name == "TextBox")
                    {
                        textboxTemp.Text = ini.Object["OrderDIY"][textboxTemp.Name.Replace("text_", "")].GetValueOrDefault("")
                                           .Replace(@"\n", "\n");
                    }
                }
                catch { }
            }
            foreach (var uiitem in stackpanel_AnwDIY.Children)
            {
                var textboxTemp = uiitem as TextBox;
                try
                {
                    if (uiitem.GetType().Name == "TextBox")
                    {
                        textboxTemp.Text = ini.Object["AnswerDIY"][textboxTemp.Name.Replace("text_", "")].GetValueOrDefault("")
                                           .Replace(@"\n", "\n");
                    }
                }
                catch { }
            }
        }
Exemplo n.º 5
0
        public static void Init()
        {
            if (!File.Exists("data.db"))
            {
                SqlSugarClient conn = new SqlSugarClient(new ConnectionConfig()
                {
                    ConnectionString      = "Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\data.db;",
                    DbType                = SqlSugar.DbType.Sqlite,
                    InitKeyType           = InitKeyType.Attribute,
                    IsAutoCloseConnection = true,
                });
                conn.CodeFirst.InitTables <CustomListModel>();
                conn.CodeFirst.InitTables <CustomTitleModel>();
                conn.CodeFirst.InitTables <DefaultListModel>();
                conn.CodeFirst.InitTables <MusicInfoModel>();
                conn.CodeFirst.InitTables <LocalListModel>();
                conn.CodeFirst.InitTables <SearchHistoryModel>();
                conn.CodeFirst.InitTables <PlatformListModel>();
                conn.CodeFirst.InitTables <PlatformInfoModel>();
                conn.Dispose();
            }
            IniConfig ini = new IniConfig("Config.ini");

            ini.Load();
            bool result = ini.Object["System"].TryGetValue("DownloadPath", out IValue v);

            if (!result || v?.ToString() == string.Empty)
            {
                DownloadManager.MusicDownloadPath = AppDomain.CurrentDomain.BaseDirectory + "Download\\";
            }
            else
            {
                DownloadManager.MusicDownloadPath = v.ObjToString();
            }
        }
Exemplo n.º 6
0
        public static void loadConfig(CQEventArgs e)
        {
            String iniFile = e.CQApi.AppDirectory + "config.ini";

            if (!File.Exists(iniFile))
            {
                File.Create(iniFile).Close();
                IniConfig iniConfig = new IniConfig(iniFile);
                iniConfig.Object["Master"] = new ISection("Master")
                {
                    { "MasterQQ", 0 }
                };
                iniConfig.Save();
                e.CQLog.Info("工会战排刀器", "生成了config.ini,请更新其中的信息。");
            }
            else
            {
                IniConfig iniConfig = new IniConfig(iniFile);
                try {
                    iniConfig.Load();
                    iniConfig.Object["Master"].TryGetValue("MasterQQ", out IValue value);
                    e.CQLog.Info("Debug", value.ToString());
                    ConfigHandler.master_qq = value.ToInt64();
                    e.CQLog.Info("工会战排刀器", "配置已加载,master是" + master_qq.ToString());
                } catch {
                    e.CQLog.Error("工会战排刀器", "读取config.ini时发生错误");
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取CQ码中的图片网址
        /// </summary>
        /// <param name="imageCQCode">需要解析的图片CQ码</param>
        /// <returns></returns>
        public static string GetImageURL(string imageCQCode)
        {
            string    path  = MainSave.ImageDirectory + CQCode.Parse(imageCQCode)[0].Items["file"] + ".cqimg";
            IniConfig image = new IniConfig(path);

            image.Load();
            return(image.Object["image"]["url"].ToString());
        }
Exemplo n.º 8
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            IniConfig ini = new IniConfig(Common.CQApi.AppDirectory + "config.ini");

            ini.Load();
            ini.Object["System"]["Master"] = txtMaster.Text;
            ini.Save();
            MessageBox.Show("保存成功!");
        }
Exemplo n.º 9
0
        void Init()
        {
            textBox_KuochongUpS.Text = Texts.Text_UpS;
            textBox_KuochongUpA.Text = Texts.Text_UpA;
            listBox_Kuochong.Items.Add(Texts.Text_A1);
            listBox_Kuochong.Items.Add(Texts.Text_A2);
            listBox_Kuochong.Items.Add(Texts.Text_A3);

            textBox_JZAUpWeapon.Text   = Texts.Text_UpAWeapon;
            textBox_JZAStigmataUp.Text = Texts.Text_UpAStigmata;
            listBox_JZAWeapon.Items.Add(Texts.Text_AWeapon1);
            listBox_JZAWeapon.Items.Add(Texts.Text_AWeapon2);
            listBox_JZAWeapon.Items.Add(Texts.Text_AWeapon3);
            listBox_JZAWeapon.Items.Add(Texts.Text_AWeapon4);
            listBox_JZAWeapon.Items.Add(Texts.Text_AWeapon5);
            listBox_JZAWeapon.Items.Add(Texts.Text_AWeapon6);
            listBox_JZAStigmata.Items.Add(Texts.Text_AStigmata1);
            listBox_JZAStigmata.Items.Add(Texts.Text_AStigmata2);
            listBox_JZAStigmata.Items.Add(Texts.Text_AStigmata3);
            listBox_JZAStigmata.Items.Add(Texts.Text_AStigmata4);

            textBox_JZBUpWeapon.Text   = Texts.Text_UpBWeapon;
            textBox_JZBUpStigmata.Text = Texts.Text_UpBStigmata;
            listBox_JZBWeapon.Items.Add(Texts.Text_BWeapon1);
            listBox_JZBWeapon.Items.Add(Texts.Text_BWeapon2);
            listBox_JZBWeapon.Items.Add(Texts.Text_BWeapon3);
            listBox_JZBWeapon.Items.Add(Texts.Text_BWeapon4);
            listBox_JZBWeapon.Items.Add(Texts.Text_BWeapon5);
            listBox_JZBWeapon.Items.Add(Texts.Text_BWeapon6);
            listBox_JZBStigmata.Items.Add(Texts.Text_BStigmata1);
            listBox_JZBStigmata.Items.Add(Texts.Text_BStigmata2);
            listBox_JZBStigmata.Items.Add(Texts.Text_BStigmata3);
            listBox_JZBStigmata.Items.Add(Texts.Text_BStigmata4);

            IniConfig BPConfig = new IniConfig(Path.Combine(MainSave.AppDirectory, "概率", "标配概率.txt"));

            BPConfig.Load();
            int count = Convert.ToInt32(BPConfig.Object["详情_S"]["Count"].GetValueOrDefault("0"));

            for (int i = 0; i < count; i++)
            {
                listBox_BPS.Items.Add(BPConfig.Object["详情_S"][$"Index{i + 1}"].GetValueOrDefault(""));
            }
            count = Convert.ToInt32(BPConfig.Object["详情_A"]["Count"].GetValueOrDefault("0"));
            for (int i = 0; i < count; i++)
            {
                listBox_BPA.Items.Add(BPConfig.Object["详情_A"][$"Index{i + 1}"].GetValueOrDefault(""));
            }
            count = Convert.ToInt32(BPConfig.Object["详情_B"]["Count"].GetValueOrDefault("0"));
            for (int i = 0; i < count; i++)
            {
                listBox_BPB.Items.Add(BPConfig.Object["详情_B"][$"Index{i + 1}"].GetValueOrDefault(""));
            }
            checkBox_BPAt.Checked    = (BPConfig.Object["设置"]["ResultAt"].GetValueOrDefault("0") == "1") ? true : false;
            checkBox_BPBaodi.Checked = (BPConfig.Object["设置"]["Baodi"].GetValueOrDefault("1") == "1") ? true : false;
        }
Exemplo n.º 10
0
        private void AnswerDIY_Load(object sender, EventArgs e)
        {
            string path = $@"{MainSave.AppDirectory}Config.ini";

            ini = new IniConfig(path);
            ini.Load();
            textBox_OrderKC1.Text   = ini.Object["Order"]["KC1"].GetValueOrDefault("#扩充单抽");
            textBox_OrderKC10.Text  = ini.Object["Order"]["KC10"].GetValueOrDefault("#扩充十连");
            textBox_OrderJZA1.Text  = ini.Object["Order"]["JZA1"].GetValueOrDefault("#精准单抽A");
            textBox_OrderJZA10.Text = ini.Object["Order"]["JZA10"].GetValueOrDefault("#精准十连A");
            textBox_OrderJZB1.Text  = ini.Object["Order"]["JZB1"].GetValueOrDefault("#精准单抽B");
            textBox_OrderJZB10.Text = ini.Object["Order"]["JZB10"].GetValueOrDefault("#精准十连B");
            textBox_OrderBP1.Text   = ini.Object["Order"]["BP1"].GetValueOrDefault("#标配单抽");
            textBox_OrderBP10.Text  = ini.Object["Order"]["BP10"].GetValueOrDefault("#标配十连");

            textBox_OrderCloseGacha.Text   = ini.Object["Order"]["CloseGacha"].GetValueOrDefault("#抽卡关闭");
            textBox_OrderOpenGacha.Text    = ini.Object["Order"]["OpenGacha"].GetValueOrDefault("#抽卡开启");
            textBox_OrderRegiter.Text      = ini.Object["Order"]["Register"].GetValueOrDefault("#抽卡注册");
            textBox_OrderSign.Text         = ini.Object["Order"]["Sign"].GetValueOrDefault("#打扫甲板");
            textBox_OrderSignReset.Text    = ini.Object["Order"]["SignReset"].GetValueOrDefault("#甲板积灰");
            textBox_OrderQueryDiamond.Text = ini.Object["Order"]["QueryDiamond"].GetValueOrDefault("#我的水晶");
            textBox_OrderHelp.Text         = ini.Object["Order"]["Help"].GetValueOrDefault("#抽卡帮助");
            textBox_OrderGetPool.Text      = ini.Object["Order"]["GetPool"].GetValueOrDefault("#获取池子");

            textBox_AnsKC1.Text   = ini.Object["Answer"]["KC1"].GetValueOrDefault("少女祈祷中……");
            textBox_AnsKC10.Text  = ini.Object["Answer"]["KC10"].GetValueOrDefault("少女祈祷中……");
            textBox_AnsJZA1.Text  = ini.Object["Answer"]["JZA1"].GetValueOrDefault("少女祈祷中……");
            textBox_AnsJZA10.Text = ini.Object["Answer"]["JZA10"].GetValueOrDefault("少女祈祷中……");
            textBox_AnsJZB1.Text  = ini.Object["Answer"]["JZB1"].GetValueOrDefault("少女祈祷中……");
            textBox_AnsJZB10.Text = ini.Object["Answer"]["JZB10"].GetValueOrDefault("少女祈祷中……");
            textBox_AnsBP1.Text   = ini.Object["Answer"]["BP1"].GetValueOrDefault("少女祈祷中……");
            textBox_AnsBP10.Text  = ini.Object["Answer"]["BP10"].GetValueOrDefault("少女祈祷中……");

            textBox_AnsRegister.Text     = ini.Object["Answer"]["Register"].GetValueOrDefault("<@>欢迎上舰,这是你的初始资源(<#>水晶)");
            textBox_AnsMutiRegister.Text = ini.Object["Answer"]["MutiRegister"].GetValueOrDefault("重复注册是不行的哦");
            textBox_AnsSign1.Text        = ini.Object["Answer"]["Sign1"].GetValueOrDefault("大姐你回来了,天气这么好一起多逛逛吧");
            textBox_AnsSign2.Text        = ini.Object["Answer"]["Sign2"].GetValueOrDefault("<@>这是你今天清扫甲板的报酬,拿好(<#>水晶)");
            textBox_AnsMutiSign.Text     = ini.Object["Answer"]["MutiSign"].GetValueOrDefault("今天的甲板挺亮的,擦一遍就行了");
            textBox_AnsQueryDiamond.Text = ini.Object["Answer"]["QueryDiamond"].GetValueOrDefault("<@>你手头还有<#>水晶");
            textBox_AnsNoReg.Text        = ini.Object["Answer"]["NoReg"].GetValueOrDefault("<@>不是清洁工吧?来输入#抽卡注册 来上舰");
            textBox_AnsLowDiamond.Text   = ini.Object["Answer"]["LowDiamond"].GetValueOrDefault("<@>水晶不足,无法进行抽卡,你还剩余<#>水晶");
            textBox_AnsHelp.Text         = ini.Object["Answer"]["Help"].GetValueOrDefault(@"水银抽卡人 给你抽卡的自信(~ ̄▽ ̄)~ \n合成图片以及发送图片需要一些时间,请耐心等待\n单抽是没有保底的\n#抽卡注册\n#我的水晶\n#打扫甲板(签到)\n#甲板积灰(重置签到,管理员限定)\n#氪金 目标账号或者at 数量(管理员限定 暂不支持自定义修改)\n#获取池子\n\n#精准单抽(A/B)大小写随意\n#扩充单抽\n#精准十连(A/B)大小写随意\n#扩充十连\n#标配单抽\n#标配十连\n#抽卡开启(在后台群后面可接群号)\n#抽卡关闭(在后台群后面可接群号)\n#置抽卡管理(示例:#置抽卡管理,群号,QQ或者at)\n#更换池子 查询公告的关键字\n#抽干家底 扩充或者精准A/B")
                                           .Replace("\\", @"\");

            textBox_SignReset1.Text = ini.Object["Answer"]["Reset1"].GetValueOrDefault("贝贝龙来甲板找女王♂van,把甲板弄脏了,大家又得打扫一遍");
            textBox_SignReset2.Text = ini.Object["Answer"]["Reset2"].GetValueOrDefault("草履虫非要给鸭子做饭,厨房爆炸了,黑紫色的东西撒了一甲板,把甲板弄脏了,大家又得打扫一遍");
            textBox_SignReset3.Text = ini.Object["Answer"]["Reset3"].GetValueOrDefault("你和女武神们被从深渊扔了回来,来自深渊的炉灰把甲板弄脏了,大家又得打扫一遍");
            textBox_SignReset4.Text = ini.Object["Answer"]["Reset4"].GetValueOrDefault("由于神秘东方村庄的诅咒,你抽卡的泪水把甲板弄脏了,大家又得打扫一遍");
            textBox_SignReset5.Text = ini.Object["Answer"]["Reset5"].GetValueOrDefault("理律疯狂在甲板上逮虾户,把甲板弄脏了,大家又得打扫一遍");
            textBox_SignReset6.Text = ini.Object["Answer"]["Reset6"].GetValueOrDefault("希儿到处找不到鸭子,里人格暴走,把甲板弄脏了,大家又得打扫一遍");

            textBox_ResisterMin.Text = ini.Object["GetDiamond"]["RegisterMin"].GetValueOrDefault("0");
            textBox_RegisterMax.Text = ini.Object["GetDiamond"]["RegisterMax"].GetValueOrDefault("14000");
            textBox_SignMin.Text     = ini.Object["GetDiamond"]["SignMin"].GetValueOrDefault("0");
            textBox_SignMax.Text     = ini.Object["GetDiamond"]["SignMax"].GetValueOrDefault("14000");
        }
Exemplo n.º 11
0
        public LoginWindow()
        {
            IniConfig ini = new IniConfig(Directory.GetCurrentDirectory() + "\\bot.config.ini");

            ini.Load();
            ini.Clear();
            ini.Save();
            ResizeMode = ResizeMode.CanMinimize;
            InitializeComponent();
        }
Exemplo n.º 12
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            File.WriteAllText(CQSave.AppDirectory + "AbyssHelper.json", JsonConvert.SerializeObject(abyssTimers));
            AbyssTimerHelper.Start();
            IniConfig ini = new IniConfig(CQSave.AppDirectory + "Config.ini"); ini.Load();

            ini.Object["ExtraConfig"]["TimerInterval"] = textBox_timerInterval.Text;
            ini.Save();
            MessageBox.Show("保存成功");
        }
Exemplo n.º 13
0
        void ReadConfig()
        {
            string path = $@"{CQSave.AppDirectory}\Config.ini";

            ini = new IniConfig(path);
            ini.Load();
            order_KC1   = ini.Object["Order"]["KC1"].GetValueOrDefault("#扩充单抽");
            order_KC10  = ini.Object["Order"]["KC10"].GetValueOrDefault("#扩充十连");
            order_JZA1  = ini.Object["Order"]["JZA1"].GetValueOrDefault("#精准单抽A");
            order_JZA10 = ini.Object["Order"]["JZA10"].GetValueOrDefault("#精准十连A");
            order_JZB1  = ini.Object["Order"]["JZB1"].GetValueOrDefault("#精准单抽B");
            order_JZB10 = ini.Object["Order"]["JZB10"].GetValueOrDefault("#精准十连B");
            order_BP1   = ini.Object["Order"]["BP1"].GetValueOrDefault("#标配单抽");
            order_BP10  = ini.Object["Order"]["BP10"].GetValueOrDefault("#标配十连");

            order_register     = ini.Object["Order"]["Register"].GetValueOrDefault("#抽卡注册");
            order_sign         = ini.Object["Order"]["Sign"].GetValueOrDefault("#打扫甲板");
            order_signreset    = ini.Object["Order"]["SignReset"].GetValueOrDefault("#甲板积灰");
            order_querydiamond = ini.Object["Order"]["QueryDiamond"].GetValueOrDefault("#我的水晶");
            order_help         = ini.Object["Order"]["Help"].GetValueOrDefault("#抽卡帮助");
            order_getpool      = ini.Object["Order"]["GetPool"].GetValueOrDefault("#获取池子");

            KC1   = ini.Object["Answer"]["KC1"].GetValueOrDefault("少女祈祷中……");
            KC10  = ini.Object["Answer"]["KC10"].GetValueOrDefault("少女祈祷中……");
            JZA1  = ini.Object["Answer"]["JZA1"].GetValueOrDefault("少女祈祷中……");
            JZA10 = ini.Object["Answer"]["JZA10"].GetValueOrDefault("少女祈祷中……");
            JZB1  = ini.Object["Answer"]["JZB1"].GetValueOrDefault("少女祈祷中……");
            JZB10 = ini.Object["Answer"]["JZB10"].GetValueOrDefault("少女祈祷中……");
            BP1   = ini.Object["Answer"]["BP1"].GetValueOrDefault("少女祈祷中……");
            BP10  = ini.Object["Answer"]["BP10"].GetValueOrDefault("少女祈祷中……");

            register     = ini.Object["Answer"]["Register"].GetValueOrDefault("<@>欢迎上舰,这是你的初始资源(<#>)水晶");
            mutiRegister = ini.Object["Answer"]["MutiRegister"].GetValueOrDefault("重复注册是不行的哦");
            sign1        = ini.Object["Answer"]["Sign1"].GetValueOrDefault("大姐你回来了,天气这么好一起多逛逛吧");
            sign2        = ini.Object["Answer"]["Sign2"].GetValueOrDefault("<@>这是你今天清扫甲板的报酬,拿好(<#>水晶)");
            mutiSign     = ini.Object["Answer"]["MutiSign"].GetValueOrDefault("今天的甲板挺亮的,擦一遍就行了");
            noReg        = ini.Object["Answer"]["NoReg"].GetValueOrDefault("<@>不是清洁工吧?来输入#抽卡注册 来上舰");
            lowDiamond   = ini.Object["Answer"]["LowDiamond"].GetValueOrDefault("<@>水晶不足,无法进行抽卡,你还剩余<#>水晶");
            queryDiamond = ini.Object["Answer"]["QueryDiamond"].GetValueOrDefault("<@>你手头还有<#>水晶");
            help         = ini.Object["Answer"]["Help"].GetValueOrDefault(@"水银抽卡人 给你抽卡的自信(~ ̄▽ ̄)~ \n合成图片以及发送图片需要一些时间,请耐心等待\n单抽是没有保底的\n#抽卡注册\n#我的水晶\n#打扫甲板(签到)\n#甲板积灰(重置签到,管理员限定)\n#氪金 目标账号或者at 数量(管理员限定 暂不支持自定义修改)\n#获取池子\n\n#精准单抽(A/B)大小写随意\n#扩充单抽\n#精准十连(A/B)大小写随意\n#扩充十连\n#标配单抽\n#标配十连\n#抽卡开启(在后台群后面可接群号)\n#抽卡关闭(在后台群后面可接群号)\n#置抽卡管理(示例:#置抽卡管理,群号,QQ或者at)\n#更换池子 查询公告的关键字")
                           .Replace("\\", @"\");

            reset1 = ini.Object["Answer"]["Reset1"].GetValueOrDefault("贝贝龙来甲板找女王♂van,把甲板弄脏了,大家又得打扫一遍");
            reset2 = ini.Object["Answer"]["Reset2"].GetValueOrDefault("草履虫非要给鸭子做饭,厨房爆炸了,黑紫色的东西撒了一甲板,把甲板弄脏了,大家又得打扫一遍");
            reset3 = ini.Object["Answer"]["Reset3"].GetValueOrDefault("你和女武神们被从深渊扔了回来,来自深渊的炉灰把甲板弄脏了,大家又得打扫一遍");
            reset4 = ini.Object["Answer"]["Reset4"].GetValueOrDefault("由于神秘东方村庄的诅咒,你抽卡的泪水把甲板弄脏了,大家又得打扫一遍");
            reset5 = ini.Object["Answer"]["Reset5"].GetValueOrDefault("理律疯狂在甲板上逮虾户,把甲板弄脏了,大家又得打扫一遍");
            reset6 = ini.Object["Answer"]["Reset6"].GetValueOrDefault("希儿到处找不到鸭子,里人格暴走,把甲板弄脏了,大家又得打扫一遍");

            registermin = Convert.ToInt32(ini.Object["GetDiamond"]["RegisterMin"].GetValueOrDefault("0"));
            registermax = Convert.ToInt32(ini.Object["GetDiamond"]["RegisterMax"].GetValueOrDefault("14000"));
            signmin     = Convert.ToInt32(ini.Object["GetDiamond"]["SignMin"].GetValueOrDefault("0"));
            signmax     = Convert.ToInt32(ini.Object["GetDiamond"]["SignMax"].GetValueOrDefault("14000"));
        }
Exemplo n.º 14
0
        public static bool IsOpen()
        {
            IniConfig ini = new IniConfig(Common.CQApi.AppDirectory + "config.ini");

            ini.Load();
            try
            {
                return(ini.Object["System"]["Open"]);
            }
            catch { return(false); }
        }
Exemplo n.º 15
0
        public static bool IsMaster(long uid)
        {
            IniConfig ini = new IniConfig(Common.CQApi.AppDirectory + "config.ini");

            ini.Load();
            try
            {
                return(ini.Object["System"]["Master"].ToString().Contains(uid.ToString()));
            }
            catch { return(false); }
        }
Exemplo n.º 16
0
        public MainWindow()
        {
            InitializeComponent();
            IniConfig ini = new IniConfig(Common.CQApi.AppDirectory + "config.ini");

            ini.Load();
            try
            {
                txtMaster.Text = ini.Object["System"]["Master"];
            }
            catch { }
        }
Exemplo n.º 17
0
        public static string Close(long uid)
        {
            if (!IsMaster(uid))
            {
                return("不是主人!");
            }
            IniConfig ini = new IniConfig(Common.CQApi.AppDirectory + "config.ini");

            ini.Load();
            ini.Object["System"]["Open"] = false;
            ini.Save();
            return("关闭成功!");
        }
Exemplo n.º 18
0
        public FunctionResult Progress(QMGroupMessageEventArgs e)
        {
            FunctionResult result = new FunctionResult
            {
                result   = QMEventHandlerTypes.Intercept,
                SendFlag = true
            };
            SendText sendText = new SendText();

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

            bool exist = SQLHelper.IDExist(e);

            if (!exist)
            {
                sendText.MsgToSend.Add(PublicArgs.noReg.Replace("<@>", $"[@{e.FromQQ.Id}]"));
                return(result);
            }
            int diamond = SQLHelper.GetDiamond(e);

            if (diamond < 280)
            {
                sendText.MsgToSend.Add(PublicArgs.lowDiamond.Replace("<@>", $"[@{e.FromQQ.Id}]")
                                       .Replace("<#>", diamond.ToString()));
                return(result);
            }
            QMApi.CurrentApi.SendGroupMessage(e.RobotQQ, e.FromGroup, PublicArgs.JZA1
                                              .Replace("<@>", $"[@{e.FromQQ.Id}]").Replace("<#>", diamond.ToString()));
            List <GachaResult> ls = new List <GachaResult>
            {
                MainGacha.BP_GachaMain(),
                               MainGacha.BP_GachaSub()
            };

            SQLHelper.AddItem2Repositories(ls, e);
            CombinePng cp = new CombinePng();

            SQLHelper.SubDiamond(e, 280);
            SQLHelper.AddCount_Gacha(e, 1);

            IniConfig ini = new IniConfig($@"{MainSave.AppDirectory}概率\标配概率.txt");

            ini.Load();
            sendText.MsgToSend.Add(ini.Object["详情"]["ResultAt"].GetValueOrDefault("0") == "1"
                ? $"[@{e.FromQQ.Id}]" : ""
                                   + Save.AppConfig.Object["ExtraConfig"]["TextGacha"].GetValueOrDefault("0") == "1"
                ? Helper.TextGacha(ls) : $"[pic=" +
                                   $"{cp.MakePic(ls, PublicArgs.PoolName.标配, diamond - 280, e.FromQQ.Id, e.FromGroup.Id)}]");
            return(result);
        }
Exemplo n.º 19
0
        public void CQStartup(object sender, CQStartupEventArgs e)
        {
            try
            {
                CQSave.cq_start       = e;
                CQSave.AppDirectory   = e.CQApi.AppDirectory;
                CQSave.ImageDirectory = GetAppImageDirectory();
                CQSave.CQLog          = e.CQLog;
                CQSave.CQApi          = e.CQApi;
                ini = new IniConfig(e.CQApi.AppDirectory + "Config.ini");
                ini.Load();
                string temp = ini.Object["OCR"]["app_id"].GetValueOrDefault("");
                if (temp == "")
                {
                    ini.Object["OCR"]["app_id"]  = new IValue("");
                    ini.Object["OCR"]["app_key"] = new IValue("");
                }
                ini.Save();

                if (!File.Exists($@"{e.CQApi.AppDirectory}装备卡\框\抽卡背景.png"))
                {
                    e.CQLog.Warning("错误", "数据包未安装,插件无法运行,请仔细阅读论坛插件说明安装数据包,之后重启酷Q");
                }
                else
                {
                    if (!File.Exists($@"{e.CQApi.AppDirectory}data.db"))
                    {
                        Event_GroupMessage.CreateDB($@"{e.CQApi.AppDirectory}data.db");
                        e.CQLog.WriteLine(Native.Sdk.Cqp.Enum.CQLogLevel.Info, "已创建数据库");
                    }
                    else
                    {
                        FileInfo info = new FileInfo($@"{e.CQApi.AppDirectory}data.db");
                        if (info.Length == 0)
                        {
                            File.Delete($@"{e.CQApi.AppDirectory}data.db");
                            Event_GroupMessage.CreateDB($@"{e.CQApi.AppDirectory}data.db");
                            e.CQLog.WriteLine(Native.Sdk.Cqp.Enum.CQLogLevel.Info, "已创建数据库");
                            return;
                        }
                        Event_GroupMessage.CheckDB($@"{e.CQApi.AppDirectory}data.db", e);
                    }
                }
                AbyssTimerHelper.Start();
            }
            catch (Exception exc)
            {
                e.CQLog.Info("Error", exc.Message, exc.StackTrace);
            }
        }
Exemplo n.º 20
0
        private void AbyssHelper_Load(object sender, EventArgs e)
        {
            if (QMApi.CurrentApi != null)
            {
                var group = QMApiV2.GetGroupList(MainSave.RobotQQ);
                foreach (var item in (JArray)group["join"])
                {
                    grouplist.Add(Convert.ToInt64(item["gc"].ToString()));
                    checkedListBox_Group.Items.Add($"{item["gn"]}({item["gc"]})");
                }
            }
            else
            {
                Random rd = new Random();
                for (int i = 0; i < 10; i++)
                {
                    long groupid = rd.Next();
                    grouplist.Add(groupid);
                    checkedListBox_Group.Items.Add($"名称{i + 1}({groupid})");
                }
            }
            IniConfig ini = new IniConfig(MainSave.AppDirectory + "Config.ini"); ini.Load();

            textBox_timerInterval.Text = ini.Object["ExtraConfig"]["TimerInterval"].GetValueOrDefault("20");
            if (File.Exists(MainSave.AppDirectory + "AbyssHelper.json"))
            {
                abyssTimers = JsonConvert.DeserializeObject <List <AbyssTimer> >(File.ReadAllText(MainSave.AppDirectory + "AbyssHelper.json"));
            }

            foreach (var item in abyssTimers)
            {
                string grouptext = string.Empty;
                int    count     = 0;
                foreach (var group in item.GroupList)
                {
                    count++;
                    grouptext += group + (count == item.GroupList.Count ? "" : ",");
                    if (grouplist.IndexOf(group) != -1)
                    {
                        checkedListBox_Group.SetItemChecked(grouplist.IndexOf(group), true);
                    }
                }
                dataGridView_Details.Rows.Add(item.Enabled, comboBox_Week.Items[item.DayofWeek].ToString()
                                              , $"{item.Hour}:{item.Minute}", item.RemindText, grouptext);
            }
        }
Exemplo n.º 21
0
        public string BotLogin(string token)
        {
            string Rtn = null;

            try
            {
                //SSL/TLS连接
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
                //建立Bot客户端
                var botClient = new TelegramBotClient(token);
                //获取Bot资料
                var bot_info = botClient.GetMeAsync();
                Console.WriteLine($"=====================\n" +
                                  $"Well done.Login success." +
                                  $"\nAccount:{bot_info.Result.Id}\n" +
                                  $"Name:{bot_info.Result.FirstName}" +
                                  $"\n=====================\n");
                //写入Config
                string     path = Directory.GetCurrentDirectory() + "\\botInfo.ini";
                FileStream fs   = new FileStream(path, FileMode.CreateNew, FileAccess.ReadWrite);
                if (File.Exists(path) == false)
                {
                    File.Create(path);
                    fs.Close();
                }
                else
                {
                    fs.Close();
                }
                IniConfig ini = new IniConfig(path);
                ini.Load();
                ini.Clear();
                ini.Object.Add(new ISection("BotAccount"));
                ini.Object["BotAccount"]["token"] = token;
                ini.Object["BotAccount"]["ID"]    = bot_info.Result.Id;
                ini.Object["BotAccount"]["Name"]  = bot_info.Result.FirstName;
                ini.Save();
                Rtn = "Login success.";
            }
            catch (Exception ex)
            {
                Rtn = ex.Message;
            }
            return(Rtn);
        }
Exemplo n.º 22
0
        public static void Start()
        {
            remindTimer.Elapsed -= RemindTimer_Elapsed;
            remindTimer.Stop();
            IniConfig ini = new IniConfig(MainSave.AppDirectory + "Config.ini"); ini.Load();

            if (File.Exists(MainSave.AppDirectory + "AbyssHelper.json"))
            {
                abyssTimers = JsonConvert.DeserializeObject <List <AbyssTimer> >(File.ReadAllText(MainSave.AppDirectory + "AbyssHelper.json"));
            }
            remindTimer.Interval = Convert.ToDouble(ini.Object["ExtraConfig"]["TimerInterval"].GetValueOrDefault("20")) * 1000;
            remindTimer.Elapsed += RemindTimer_Elapsed;
            if (abyssTimers.Count != 0)
            {
                remindTimer.Start();
                QMLog.CurrentApi.Info($"深渊提醒助手,定时生效,周期{remindTimer.Interval/1000}秒");
            }
        }
Exemplo n.º 23
0
 private void Login_Btn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
         ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
         var botClient = new TelegramBotClient(Bot_Token.Text);
         var bot_info  = botClient.GetMeAsync().Result;
         Login_Rtn.Foreground = new SolidColorBrush(Color.FromRgb(102, 204, 255));
         Login_Rtn.Text       = $"Welcome!\nHanaya.TgBot框架现在登录的是Bot账号 {bot_info.Id}\nBot名字为 {bot_info.FirstName}.";
         IniConfig ini = new IniConfig(Directory.GetCurrentDirectory() + "\\bot.config.ini");
         ini.Load();
         ini.Object.Add(new ISection("BotAccount"));
         ini.Object["BotAccount"]["token"] = Bot_Token.Text;
         ini.Object["BotAccount"]["ID"]    = bot_info.Id;
         ini.Object["BotAccount"]["Name"]  = bot_info.FirstName;
         ini.Save();
         MainWindow mainWindow = new MainWindow();
         Help_Login help       = new Help_Login();
         if (isOpen != false)
         {
             mainWindow.Show();
             help.Close();
             Close();
         }
         else
         {
             mainWindow.Show();
             Close();
         }
     }
     catch (AggregateException ex)
     {
         Login_Rtn.Text = "错误:System.AggregateException" + "\n请检查网络连接(国内连接Telegram需要代理)" + "\n以及检查Token是否正确\n" + ex.Message;
     }
     catch (WebException ex)
     {
         Login_Rtn.Text = "错误:System.Net.WebException\n" + ex.Message;
     }
     catch (Exception ex)
     {
         Login_Rtn.Text = "错误:System.Exception:请填写正确的Token(格式错误)\n" + ex.Message;
     }
 }
Exemplo n.º 24
0
        public static void Init()
        {
            try
            {
                IniConfig ini;
                ini = new IniConfig(Path.Combine(MainSave.AppDirectory, "Config.ini"));
                ini.Load();
                if (ini == null || ini.Object.Count == 0)
                {
                    ini.Object["OCR"].Add("app_id", "");
                    ini.Object["OCR"].Add("app_key", "");
                    ini.Save();
                }
                string temp = ini.Object["OCR"]["app_id"].GetValueOrDefault("");
                if (temp == "")
                {
                    ini.Object["OCR"]["app_id"]  = new IValue("");
                    ini.Object["OCR"]["app_key"] = new IValue("");
                }
                ini.Save();

                if (!File.Exists($@"{MainSave.AppDirectory}装备卡\框\抽卡背景.png"))
                {
                    QMLog.CurrentApi.Info("数据包未安装,插件无法运行,请仔细阅读论坛插件说明安装数据包,之后重载插件");
                }
                else
                {
                    SQLHelper.Init(Path.Combine(MainSave.AppDirectory, "data.db"));
                    if (!File.Exists(Path.Combine(MainSave.AppDirectory, "data.db")))
                    {
                        SQLHelper.CreateDB();
                    }
                }
                AbyssTimerHelper.Start();
                MainGacha.Init();
            }
            catch (Exception exc)
            {
                QMLog.CurrentApi.Info(exc.Message + exc.StackTrace);
            }
        }
Exemplo n.º 25
0
 private void Init()
 {
     ini.Load();
     try
     {
         Save.curentQQ       = ini.Object["Config"]["QQ"].GetValueOrDefault((long)0);
         Save.url            = ini.Object["Config"]["url"].GetValueOrDefault("http://127.0.0.1:8888/");
         Save.ReceiveSelfMsg = (bool)(ini.Object["Config"]["ReceiveSelfMsg"]?.ToBoolean());
     }
     catch
     {
         ini.Clear();
         ini.Object.Add(new ISection("Config"));
         ini.Object["Config"].Add("QQ", 0);
         ini.Object["Config"].Add("url", "http://127.0.0.1:8888/");
         ini.Object["Config"].Add("AutoLogin", false);
         ini.Object["Config"].Add("ReceiveSelfMsg", false);
         Save.curentQQ = 0;
         Save.url      = "";
         ini.Save();
     }
 }
        private void ImportGroupList_Load(object sender, EventArgs e)
        {
            cq = CQSave.cq_menu;
            string path = CQSave.AppDirectory + "Config.ini";

            ini = new IniConfig(path);
            ini.Load();
            var ls = cq.CQApi.GetGroupList();

            foreach (var item in ls)
            {
                dataGridView1.Rows.Add(item.Group.Id, item.Name.ToString());
            }
            Label_Status.Text = "就绪     |";
            Label_Text.Text   = $"已载入{ls.Count}个群...       ";

            int count = Convert.ToInt32(ini.Object["群控"]["Count"].GetValueOrDefault("0"));

            for (int i = 0; i < count; i++)
            {
                listBox_Group.Items.Add(ini.Object["群控"][$"Item{i}"].GetValueOrDefault("0"));
            }
            label_Count.Text = $"计数:{listBox_Group.Items.Count}个";
        }
Exemplo n.º 27
0
        //进行OCR
        public OCR_Result TXOCR()
        {
            string image = HttpTool.UrlEncode(Convert.ToBase64String(File.ReadAllBytes($"{MainSave.ImageDirectory}\\ocrtemp.jpg"))).Replace("%3d", "%3D").Replace("%2f", "%2F").Replace("%2b", "%2B");

            ini = new IniConfig(MainSave.AppDirectory + "Config.ini");
            ini.Load();
            string app_id    = ini.Object["OCR"]["app_id"].GetValueOrDefault("");
            string app_key   = ini.Object["OCR"]["app_key"].GetValueOrDefault("");
            string timestamp = GetTimeStamp().ToString();
            Random rd        = new Random();
            string noicestr  = rd.Next().ToString();
            string sign      = $"app_id={app_id}&image={image}&nonce_str={noicestr}&time_stamp={timestamp}&app_key={app_key}";

            sign = GetMD5(sign).ToUpper();
            string url  = $"https://api.ai.qq.com/fcgi-bin/ocr/ocr_generalocr";
            string data = $"app_id={app_id}&image={image}&nonce_str={noicestr}&time_stamp={timestamp}&sign={sign}";

            byte[] by = Encoding.UTF8.GetBytes(data);
            by = HttpWebClient.Post(url, by);
            string result = Encoding.UTF8.GetString(by);

            //richTextBox1.Text = result;
            return(JsonConvert.DeserializeObject <OCR_Result>(result));
        }
Exemplo n.º 28
0
 public static int CQ_sendGroupMsg(int authcode, long groupid, IntPtr msg)
 {
     string text = Marshal.PtrToStringAnsi(msg);
     string url = $@"{Save.url}v1/LuaApiCaller?qq={Save.curentQQ}&funcname=SendMsg&timeout=10";
     List<CQCode> cqCodeList = CQCode.Parse(text);
     JObject data = new JObject
     {
         {"toUser",groupid},
         {"sendToType",2},
         {"groupid",0},
         {"fileMd5","" }
     };
     bool Picflag = false, Atflag = false; ;
     foreach (var item in cqCodeList)
     {
         switch (item.Function)
         {
             case CQFunction.At://[CQ:at,qq=xxxx]
                 {
                     if (!data.ContainsKey("atUser"))
                     {
                         data.Add("atUser", Convert.ToInt64(item.Items["qq"]));
                     }
                     else if (data["atUser"].ToString() == "0")
                         data["atUser"] = Convert.ToInt64(item.Items["qq"]);
                     Atflag = true;
                     break;
                 }
             case CQFunction.Image:
                 {
                     if (!data.ContainsKey("content")) data.Add("content", "");
                     if (!data.ContainsKey("picBase64Buf")) data.Add("picBase64Buf", "");
                     if (!data.ContainsKey("picUrl")) data.Add("picUrl", "");
                     if (!data.ContainsKey("atUser")) data.Add("atUser", 0);
                     if (!data.ContainsKey("picUrl")) data.Add("picUrl", "");
                     if (item.Items.ContainsKey("url"))
                         data["picUrl"] = item.Items["url"];
                     else if (item.Items.ContainsKey("file"))
                     {
                         if (File.Exists("data\\image\\" + item.Items["file"] + ".cqimg"))
                         {
                             IniConfig ini = new IniConfig("data\\image\\" + item.Items["file"] + ".cqimg"); ini.Load();
                             data["picUrl"] = ini.Object["image"]["url"].ToString();
                             Picflag = true;
                             break;
                         }
                         string path = item.Items["file"], base64buf = string.Empty;
                         if (File.Exists(path))
                         {
                             base64buf = BinaryReaderExpand.ImageToBase64(path);
                         }
                         data["picBase64Buf"] = base64buf;
                     }
                     else if (item.Items.ContainsKey("md5"))
                     {
                         data["fileMd5"] = item.Items["file"];
                     }
                     Picflag = true;
                     break;
                 }
         }
     }
     string filtered = Regex.Replace(text, @"\[CQ.*\]", "");
     if (!string.IsNullOrEmpty(filtered)) data["content"] = filtered;
     if (Picflag)
         data.Add("sendMsgType", "PicMsg");
     else if (Atflag)
         data.Add("sendMsgType", "AtMsg");
     else
         data.Add("sendMsgType", "TextMsg");
     if (!data.ContainsKey("atUser")) data.Add("atUser", 0);
     Console.WriteLine($"发送消息,群号{groupid}");
     Console.WriteLine(msg);
     SendRequest(url, data.ToString());
     return 0;
 }
Exemplo n.º 29
0
        public Image GenerateCard(int fullstar, int emptystar, Gacha.GachaResult gr)
        {
            Image background = (gr.quality == 1) ? Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\框蓝.png") : Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\框.png");
            Image main       = null;

            try
            {
                switch (gr.type)
                {
                case "Character":
                    main       = Image.FromFile($@"{CQSave.AppDirectory}装备卡\角色卡\{gr.name}.png");
                    background = CombinImage(background, main, 5, 14, 196, 172);
                    break;

                case "debri":
                    main       = Image.FromFile($@"{CQSave.AppDirectory}装备卡\碎片\{gr.name}.png");
                    background = CombinImage(background, main, 5, 14, 196, 172);
                    break;

                case "Stigmata":
                    main       = Image.FromFile($@"{CQSave.AppDirectory}装备卡\圣痕卡\{gr.name}.png");
                    background = CombinImage(background, main, 5, 14, 196, 172);

                    break;

                case "Material":
                    main       = Image.FromFile($@"{CQSave.AppDirectory}装备卡\材料\{gr.name}.png");
                    background = CombinImage(background, main, 26, 17, 178, 170);
                    break;

                case "Weapon":
                    main       = Image.FromFile($@"{CQSave.AppDirectory}装备卡\武器\{gr.name}.png");
                    background = CombinImage(background, main, 5, 14, 196, 172);
                    break;
                }
            }
            catch
            {
                main       = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\ItemEmpty #1004496.png");
                background = CombinImage(background, main, 48, 13, 119, 172);
                ini        = new IniConfig(CQSave.AppDirectory + "Config.ini");
                ini.Load();
                long controlgroup = Convert.ToInt64(ini.Object["后台群"]["Id"].GetValueOrDefault("0"));
                if (controlgroup != 0)
                {
                    cq.CQApi.SendGroupMessage(controlgroup, $"发现图片缺失,请排查是否为命名错误 type={gr.type} name={gr.name}");
                }
            }

            if (gr.type == 抽卡.TypeS.Character.ToString())
            {
                Image img = null;
                switch (gr.class_)
                {
                case "SSS":
                    img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\Star_Avatar_5M.png");
                    break;

                case "SS":
                    img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\Star_Avatar_4M.png");
                    break;

                case "S":
                    img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\Star_Avatar_3M.png");
                    break;

                case "A":
                    img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\Star_Avatar_2M.png");
                    break;

                case "B":
                    img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\Star_Avatar_1M.png");
                    break;
                }
                //Image img = Image.FromFile((gr.class_ == "S") ? $@"{CQSave.AppDirectory}装备卡\框\Star_Avatar_3M.png" : $@"{CQSave.AppDirectory}装备卡\框\Star_Avatar_2M.png");
                background = CombinImage(background, img, 53, 160, 106, 91);
                return(background);
            }
            if (gr.type == 抽卡.TypeS.Material.ToString() || gr.type == 抽卡.TypeS.debri.ToString())
            {
                //Point p = new Point(106, 225);
                Point p     = new Point((gr.count.ToString().Length == 1) ? 88 : 85, 225);
                Font  font  = new Font("Impact", 25F);
                Color color = Color.FromArgb(67, 67, 67);
                background = AddSlimText2Image(background, "×", p, font, color, 0);
                p          = new Point((gr.count.ToString().Length == 1) ? 106 : 108, 228);
                font       = new Font("方正兰亭粗黑_GBK", 25F);
                background = AddSlimText2Image(background, $"{gr.count}", p, font, color, 0);
            }
            else
            {
                Point p     = new Point((gr.level.ToString().Length == 1) ? 94 : 92, 225);
                Font  font  = new Font("Impact", 25F);
                Color color = Color.FromArgb(67, 67, 67);
                background = AddText2Image(background, "Lv.", p, font, color, 0);
                p          = new Point((gr.level.ToString().Length == 1) ? 113 : 117, 228);
                font       = new Font("方正兰亭粗黑_GBK", 25F);
                background = AddSlimText2Image(background, $"{gr.level}", p, font, color, 0);
            }
            string str = "";

            for (int i = 0; i < fullstar; i++)
            {
                str += "1";
            }
            for (int i = 0; i < emptystar; i++)
            {
                str += "0";
            }
            if (gr.type == 抽卡.TypeS.debri.ToString())
            {
                return(background);
            }
            char[] ch   = str.ToCharArray();
            int    trap = 26;

            if (str.Length % 2 == 0)
            {
                int   x = 103 - (str.Length / 2) * trap; int y = 171;
                Image img = null;
                for (int i = 0; i < str.Length; i++)
                {
                    if (ch[i] == '1')
                    {
                        img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\StarBig #1916506.png");
                    }
                    else
                    {
                        img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\StarBigGray.png");
                    }
                    background = CombinImage(background, img, x, y, 33, 33);
                    x         += trap;
                }
            }
            else
            {
                int   x = 90 - (str.Length / 2) * trap; int y = 171;
                Image img = null;
                for (int i = 0; i < str.Length; i++)
                {
                    if (ch[i] == '1')
                    {
                        img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\StarBig #1916506.png");
                    }
                    else
                    {
                        img = Image.FromFile($@"{CQSave.AppDirectory}装备卡\框\StarBigGray.png");
                    }
                    background = CombinImage(background, img, x, y, 33, 33);
                    x         += trap;
                }
            }
            return(background);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 生成图片,返回图片CQ码路径
        /// </summary>
        /// <param name="cp">存放池子信息的对象</param>
        /// <param name="ls">抽卡结果数组</param>
        /// <param name="Diamond">目标水晶数目</param>
        /// <returns></returns>
        public string GeneratePic(PoolInfo cp, List <PoolContent> ls, int Diamond)
        {
            try
            {
                int x, y;
                x = 160;
                y = 190;
                //$@"{dir}\装备卡\框\抽卡背景.png"
                Image  background = Image.FromFile(cp.BackgroundImg);
                Image  img        = null;
                Random rd         = new Random();
                foreach (var item in ls)
                {
                    img        = GenerateCard(item);
                    background = CombinImage(background, img, x, y);
                    if (x < 1960)
                    {
                        x += 300;
                    }
                    else
                    {
                        if (y == 190)
                        {
                            x = 160;
                            y = 530;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                background = CombinImage(background, Image.FromFile(cp.InfoPicPath), 126, 960);
                //金币
                int   money      = rd.Next(100000, 100000000);
                Image img_1      = Money(money);
                int   Width_Gold = 1620 + (164 - img_1.Width) / 2;
                background = CombinImage(background, img_1, Width_Gold, Height_1);
                //水晶
                Image img_2         = this.Diamond(Diamond);
                int   Width_Diamond = 1975 + (111 - img_2.Width) / 2;
                background = CombinImage(background, img_2, Width_Diamond, Height_1);
                //体力
                int   ap_Max   = rd.Next(154, 165);
                int   ap       = rd.Next(0, ap_Max);
                Image img_3    = AP(ap, ap_Max);
                int   Width_AP = 1319 + (127 - img_3.Width) / 2;
                background = CombinImage(background, img_3, Width_AP, Height_1);
                //水印
                Point p     = new Point(1471, 813);
                Font  font  = new Font("汉仪丫丫体简", 15F);
                Color color = Color.FromArgb(0, 0, 0);
                background = AddText2Image(background, "Powered by @水银之翼", p, font, color);

                string name = GetDate();
                if (!Directory.Exists($@"{MainSave.ImageDirectory}\\装备结果"))
                {
                    Directory.CreateDirectory($@"{MainSave.ImageDirectory}\\装备结果");
                }

                ini = new IniConfig(dir + "\\Config.ini");
                ini.Load();
                if (ini.Object["ExtraConfig"]["ImageFormat"].GetValueOrDefault("jpg") == "jpg")
                {
                    background.Save($@"{MainSave.ImageDirectory}\\装备结果\{name}.jpg", ImageFormat.Jpeg);
                    return($"[pic=装备结果\\{name}.jpg]");
                }
                else
                {
                    background.Save($@"{dir}\\装备结果\{name}.png");
                    return($"[pic=装备结果\\{name}.png]");
                }
            }
            catch (Exception e)
            {
                QMLog.CurrentApi.Info($"抽卡图片生成,生成错误,错误信息:{e.Message}");
                return(null);
            }
        }