| 1019 | const firstToken = tokens[0] || ""; |
| 1020 | if (!/^[1-9]\d*$/.test(firstToken)) { |
| 1021 | return {}; |
| 1022 | } |
| 1023 | |
| 1024 | const targetArg = tokens.slice(1).join(" ").trim(); |
| 1025 | return { |
| 1026 | limit: Number(firstToken), |
| 1027 | targetArg: targetArg || undefined, |
| 1028 | }; |
| 1029 | } |
| 1030 | |
| 1031 | function isCreatorUser(user: Api.User): boolean { |
| 1032 | const participant = (user as any).participant; |
| 1033 | return ( |
| 1034 | participant instanceof Api.ChatParticipantCreator || |
| 1035 | participant instanceof Api.ChannelParticipantCreator |
| 1036 | ); |
| 1037 | } |
| 1038 | |
| 1039 | async function demoteAdminInTarget( |
| 1040 | target: TargetChat, |
| 1041 | user: Api.User, |
| 1042 | ): Promise<void> { |
| 1043 | const client = await getGlobalClient(); |
| 1044 | if (!client) throw new Error("Telegram 客户端未初始化"); |