MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / findUserInChatParticipants

Function findUserInChatParticipants

admin_board/admin_board.ts:1135–1154  ·  view source on GitHub ↗
(
  target: TargetChat,
  identifier: string,
)

Source from the content-addressed store, hash-verified

1133 showTotal: false,
1134 ...(username ? { search: username } : {}),
1135 });
1136
1137 return participants.find((user): user is Api.User => {
1138 if (!(user instanceof Api.User)) return false;
1139 if (isNumeric) return String(user.id) === String(Number(identifier));
1140 return (user.username || "").toLowerCase() === username;
1141 });
1142}
1143
1144async function findUserInChannelParticipants(
1145 target: TargetChat,
1146 identifier: string,
1147): Promise<Api.User | undefined> {
1148 const client = await getGlobalClient();
1149 if (!client) throw new Error("Telegram 客户端未初始化");
1150
1151 const isNumeric = /^-?\d+$/.test(identifier);
1152 const username = isNumeric ? "" : identifier.replace(/^@/, "").toLowerCase();
1153
1154 if (username) {
1155 try {
1156 const users = await client.getParticipants(target.entity, {
1157 search: username,

Callers 1

resolveUserForSeatActionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected