tgsnake
Version:
Telegram MTProto framework for nodejs.
57 lines (56 loc) • 2.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParticipants = getParticipants;
const platform_node_js_1 = require("../../platform.node.js");
async function getParticipants(client, chatId, more = {}) {
var { offset, limit, query, filter } = Object.assign({
offset: 0,
limit: 200,
query: '',
filter: 'all',
}, more);
const { _client } = client;
const peer = await _client.resolvePeer(chatId);
if (peer instanceof platform_node_js_1.Raw.InputPeerChat) {
const results = await _client.invoke(new platform_node_js_1.Raw.messages.GetFullChat({
chatId: peer.chatId,
}));
return results.fullChat.participants;
}
if (peer instanceof platform_node_js_1.Raw.InputPeerChannel) {
let _filter = new platform_node_js_1.Raw.ChannelParticipantsSearch({
q: query,
});
switch (filter) {
case 'recents':
_filter = new platform_node_js_1.Raw.ChannelParticipantsRecent();
break;
case 'administrators':
_filter = new platform_node_js_1.Raw.ChannelParticipantsAdmins();
break;
case 'kicked':
_filter = new platform_node_js_1.Raw.ChannelParticipantsKicked({ q: query });
break;
case 'bots':
_filter = new platform_node_js_1.Raw.ChannelParticipantsBots();
break;
case 'banned':
_filter = new platform_node_js_1.Raw.ChannelParticipantsBanned({ q: query });
break;
case 'contacts':
_filter = new platform_node_js_1.Raw.ChannelParticipantsContacts({ q: query });
break;
case 'mentions':
_filter = new platform_node_js_1.Raw.ChannelParticipantsMentions({ q: query });
break;
default:
}
return await _client.invoke(new platform_node_js_1.Raw.channels.GetParticipants({
channel: peer,
filter: _filter,
offset: offset,
limit: limit,
hash: BigInt(0),
}));
}
}