messages.GetPollVotes
Get poll results for non-anonymous polls
Example
const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result = await client.invoke(
new Api.messages.GetPollVotes({
peer: "username",
id: 43,
limit: 100,
option: Buffer.from("arbitrary data here"),
offset: "some string here",
})
);
console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";
const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});
(async function run() {
await client.connect(); // This assumes you have already authenticated with .start()
const result: Api.messages.VotesList = await client.invoke(
new Api.messages.GetPollVotes({
peer: "username",
id: 43,
limit: 100,
option: Buffer.from("arbitrary data here"),
offset: "some string here",
})
);
console.log(result); // prints the result
})();
Parameters
Name | Type | Description |
---|---|---|
flags | # | Flags, see TL conditional fields |
peer | InputPeer | Chat where the poll was sent |
id | int | Message ID |
option | flags.0?bytes | Get only results for the specified poll option |
offset | flags.1?string | Offset for results, taken from the next_offset field of messages.votesList, initially an empty string. Note: if no more results are available, the method call will return an empty next_offset ; thus, avoid providing the next_offset returned in messages.votesList if it is empty, to avoid an infinite loop. |
limit | int | Number of results to return |
Result
Possible errors
Code | Type | Description |
---|---|---|
403 | BROADCAST_FORBIDDEN | Participants of polls in channels should stay anonymous. |
400 | MSG_ID_INVALID | Invalid message ID provided. |
403 | POLL_VOTE_REQUIRED | Cast a vote in the poll before calling this method. |
Can bots use this method?
No
Related pages
messages.votesList
How users voted in a poll