コード例 #1
0
 public void CQStartup(object sender, CQStartupEventArgs e)
 {
     MainSave.AppDirectory   = e.CQApi.AppDirectory;
     MainSave.CQApi          = e.CQApi;
     MainSave.CQLog          = e.CQLog;
     MainSave.ImageDirectory = CommonHelper.GetAppImageDirectory();
     MainSave.CookiePath     = Path.Combine(e.CQApi.AppDirectory, "Cookies.json");
     MainSave.ConfigPath     = Path.Combine(e.CQApi.AppDirectory, "Config.json");
     //这里写处理逻辑
     MainSave.Instances.Add(new SignMain());//这里需要将指令实例化填在这里
     if (File.Exists(MainSave.ConfigPath))
     {
         MainSave.AppConfig = AppConfig.LoadConfig();
     }
     else
     {
         MainSave.AppConfig = new AppConfig();
         AppConfig.SaveConfig();
     }
     if (File.Exists(MainSave.CookiePath))
     {
         MainSave.CookieList = CookieObject.LoadObject();
     }
     else
     {
         MainSave.CookieList = new List <CookieObject>();
         CookieObject.SaveObject();
     }
     ApiHelper.StartSignJob();
 }
コード例 #2
0
ファイル: SignMain.cs プロジェクト: Hellobaka/GenshinSignBot
            public string GetReply(string msg)
            {
                switch (Order)
                {
                case StepOrder.Non:
                    Order = StepOrder.InputCookie;
                    return("感谢你使用原神签到机,首先请输入你的米游社Cookie,不知道如何获取请询问Bot管理员");

                case StepOrder.InputCookie:
                    if (string.IsNullOrWhiteSpace(msg))
                    {
                        return("无效回复,请输入米游社Cookie,需要重置进度请输入 #进度重置");
                    }
                    var result = ApiHelper.GetRoleByCookie(msg);
                    if (result.retcode == 0)
                    {
                        RoleInfo.Cookie = msg;
                        RawRoleInfo     = result;
                        var ls = RawRoleInfo.data.list;
                        if (ls.Length == 0)
                        {
                            Order    = StepOrder.Done;
                            RoleInfo = null;
                            return("未检索到角色,请先去米游社绑定你的原神角色");
                        }
                        else if (ls.Length == 1)
                        {
                            Order = StepOrder.Done;
                            var role = ls[0];
                            RoleInfo.NickName = role.nickname;
                            RoleInfo.UID      = Convert.ToInt64(role.game_uid);
                            RoleInfo.Region   = role.region;
                            MainSave.CookieList.Add(RoleInfo);
                            CookieObject.SaveObject();
                            return($"UID: {ApiHelper.GetUIDMark(RoleInfo.UID)} 昵称: {RoleInfo.NickName} 绑定成功!\n每天会帮你进行签到的ヽ( ̄▽ ̄)ノ");
                        }
                        else
                        {
                            Order = StepOrder.SelectCharacter;
                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine("检索到多个角色,请输入序号来确认角色");
                            int Characterindex = 1;
                            foreach (var item in ls)
                            {
                                sb.AppendLine($"{Characterindex}. UID:{item.game_uid} 昵称:{item.nickname}");
                            }
                            return(sb.ToString());
                        }
                    }
                    else
                    {
                        return("Cookie校验失败,请确认获取方式是否正确");
                    }

                case StepOrder.SelectCharacter:
                    if (int.TryParse(msg, out int index))
                    {
                        Order = StepOrder.Done;
                        var role = RawRoleInfo.data.list[index];
                        RoleInfo.NickName = role.nickname;
                        RoleInfo.UID      = Convert.ToInt64(role.game_uid);
                        RoleInfo.Region   = role.region;
                        MainSave.CookieList.Add(RoleInfo);
                        CookieObject.SaveObject();
                        return($"UID: {ApiHelper.GetUIDMark(RoleInfo.UID)} 昵称: {RoleInfo.NickName} 绑定成功!\n每天会帮你进行签到的ヽ( ̄▽ ̄)ノ");
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("请输入数字序号,需要重置进度请输入 #进度重置");
                        int Characterindex = 1;
                        foreach (var item in RawRoleInfo.data.list)
                        {
                            sb.AppendLine($"{Characterindex}. UID:{item.game_uid} 昵称:{item.nickname}");
                        }
                        return(sb.ToString());
                    }

                case StepOrder.Done:
                default:
                    return("");
                }
            }