( target: TargetChat, identifier: string, )
| 1215 | |
| 1216 | const candidates = /^-?\d+$/.test(trimmed) ? [Number(trimmed)] : [trimmed]; |
| 1217 | |
| 1218 | for (const candidate of candidates) { |
| 1219 | try { |
| 1220 | const entity = await client.getEntity(candidate as any); |
| 1221 | if (entity instanceof Api.User) { |
| 1222 | return entity; |
| 1223 | } |
| 1224 | } catch { |
| 1225 | // Ignore and continue to target-specific fallback. |
| 1226 | } |
| 1227 | } |
| 1228 | |
| 1229 | return target.isChannel |
| 1230 | ? await findUserInChannelParticipants(target, trimmed) |
| 1231 | : await findUserInChatParticipants(target, trimmed); |
| 1232 | } |
| 1233 | |
| 1234 | async function handleSeatAction( |
| 1235 | msg: Api.Message, |
| 1236 | action: "lock" | "unlock", |
| 1237 | rawText: string, |
| 1238 | ): Promise<void> { |
| 1239 | const remainder = getTextAfterTokens(rawText, 2); |
| 1240 | const { identifiers, targetArg } = parseSeatActionArgs(remainder); |
| 1241 | |
| 1242 | if (identifiers.length === 0) { |
| 1243 | await msg.edit({ |
| 1244 | text: `❌ 参数不足\n\n用法:\n<code>${htmlEscape( |
| 1245 | commandName, |
| 1246 | )} ${action} 用户1,用户2 [对话id/@username]</code>`, |
| 1247 | parseMode: "html", |
no test coverage detected