(args: string[])
| 3854 | |
| 3855 | private parseAddConfigArgs(args: string[]): { |
| 3856 | tag: string; |
| 3857 | url: string; |
| 3858 | key: string; |
| 3859 | type?: ProviderType; |
| 3860 | } { |
| 3861 | const rawArgs = args.slice(2); |
| 3862 | let urlIndex = -1; |
| 3863 | for (let i = rawArgs.length - 2; i >= 1; i--) { |
| 3864 | const trailingCount = rawArgs.length - i - 1; |
| 3865 | if (trailingCount > 2) continue; |
| 3866 | if (!isHttpUrl(rawArgs[i])) continue; |
| 3867 | urlIndex = i; |
| 3868 | break; |
| 3869 | } |
| 3870 | |
| 3871 | requireUser(urlIndex > 0, "参数格式错误"); |
| 3872 | |
| 3873 | const tag = rawArgs.slice(0, urlIndex).join(" ").trim(); |
| 3874 | const url = rawArgs[urlIndex]; |
| 3875 | const tail = rawArgs.slice(urlIndex + 1); |
| 3876 | requireUser( |
| 3877 | !!tag && (tail.length === 1 || tail.length === 2), |
| 3878 | "参数格式错误", |
| 3879 | ); |
| 3880 | |
| 3881 | return { |
| 3882 | tag, |
| 3883 | url, |
| 3884 | key: tail[0], |
| 3885 | type: tail[1] ? this.parseProviderType(tail[1]) : undefined, |
| 3886 | }; |
| 3887 | } |
| 3888 | |
| 3889 | private async addConfig( |
| 3890 | msg: Api.Message, |
| 3891 | args: string[], |
no test coverage detected