(remainder: string)
| 1107 | if (tokens.length > 1) { |
| 1108 | const targetArg = tokens[tokens.length - 1]; |
| 1109 | const targetlessIdentifiers = parseUserIdentifiers( |
| 1110 | tokens.slice(0, -1).join(" "), |
| 1111 | ); |
| 1112 | if (targetlessIdentifiers) { |
| 1113 | return { |
| 1114 | identifiers: targetlessIdentifiers, |
| 1115 | targetArg, |
| 1116 | }; |
| 1117 | } |
| 1118 | } |
| 1119 | |
| 1120 | return { identifiers: [] }; |
| 1121 | } |
| 1122 | |
| 1123 | async function findUserInChatParticipants( |
| 1124 | target: TargetChat, |
| 1125 | identifier: string, |
| 1126 | ): Promise<Api.User | undefined> { |
| 1127 | const client = await getGlobalClient(); |
| 1128 | if (!client) throw new Error("Telegram 客户端未初始化"); |
| 1129 | |
| 1130 | const isNumeric = /^-?\d+$/.test(identifier); |
| 1131 | const username = isNumeric ? "" : identifier.replace(/^@/, "").toLowerCase(); |
| 1132 | const participants = await client.getParticipants(target.entity, { |
| 1133 | showTotal: false, |
| 1134 | ...(username ? { search: username } : {}), |
| 1135 | }); |
| 1136 |
no test coverage detected