Add updatePoll for bots.
GitOrigin-RevId: b655c57e6643cef05654f3b73467a50c6bd0ac5d
This commit is contained in:
parent
8c8fd71029
commit
93d5cc1a45
@ -2533,6 +2533,9 @@ updateNewCustomEvent event:string = Update;
|
|||||||
//@description A new incoming query; for bots only @id The query identifier @data JSON-serialized query data @timeout Query timeout
|
//@description A new incoming query; for bots only @id The query identifier @data JSON-serialized query data @timeout Query timeout
|
||||||
updateNewCustomQuery id:int64 data:string timeout:int32 = Update;
|
updateNewCustomQuery id:int64 data:string timeout:int32 = Update;
|
||||||
|
|
||||||
|
//@description Information about a poll was updated; for bots only @poll New data about the poll
|
||||||
|
updatePoll poll:poll = Update;
|
||||||
|
|
||||||
|
|
||||||
//@description Contains a list of updated @updates List of updates
|
//@description Contains a list of updated @updates List of updates
|
||||||
updates updates:vector<Update> = Updates;
|
updates updates:vector<Update> = Updates;
|
||||||
|
Binary file not shown.
@ -411,6 +411,10 @@ vector<int32> PollManager::get_vote_percentage(const vector<int32> &voter_counts
|
|||||||
td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id) const {
|
td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id) const {
|
||||||
auto poll = get_poll(poll_id);
|
auto poll = get_poll(poll_id);
|
||||||
CHECK(poll != nullptr);
|
CHECK(poll != nullptr);
|
||||||
|
return get_poll_object(poll_id, poll);
|
||||||
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, const Poll *poll) const {
|
||||||
vector<td_api::object_ptr<td_api::pollOption>> poll_options;
|
vector<td_api::object_ptr<td_api::pollOption>> poll_options;
|
||||||
auto it = pending_answers_.find(poll_id);
|
auto it = pending_answers_.find(poll_id);
|
||||||
int32 voter_count_diff = 0;
|
int32 voter_count_diff = 0;
|
||||||
@ -834,6 +838,8 @@ vector<PollManager::PollOption> PollManager::get_poll_options(
|
|||||||
|
|
||||||
PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll> &&poll_server,
|
PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll> &&poll_server,
|
||||||
tl_object_ptr<telegram_api::pollResults> &&poll_results) {
|
tl_object_ptr<telegram_api::pollResults> &&poll_results) {
|
||||||
|
bool is_bot = td_->auth_manager_->is_bot();
|
||||||
|
bool need_update_poll = poll_id.is_valid() && is_bot;
|
||||||
if (!poll_id.is_valid() && poll_server != nullptr) {
|
if (!poll_id.is_valid() && poll_server != nullptr) {
|
||||||
poll_id = PollId(poll_server->id_);
|
poll_id = PollId(poll_server->id_);
|
||||||
}
|
}
|
||||||
@ -958,6 +964,11 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll
|
|||||||
if (is_changed) {
|
if (is_changed) {
|
||||||
notify_on_poll_update(poll_id);
|
notify_on_poll_update(poll_id);
|
||||||
save_poll(poll, poll_id);
|
save_poll(poll, poll_id);
|
||||||
|
|
||||||
|
if (need_update_poll) {
|
||||||
|
send_closure(G()->td(), &Td::send_update,
|
||||||
|
td_api::make_object<td_api::updatePoll>(get_poll_object(poll_id, poll)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return poll_id;
|
return poll_id;
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,8 @@ class PollManager : public Actor {
|
|||||||
|
|
||||||
Poll *get_poll_force(PollId poll_id);
|
Poll *get_poll_force(PollId poll_id);
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::poll> get_poll_object(PollId poll_id, const Poll *poll) const;
|
||||||
|
|
||||||
void on_get_poll_results(PollId poll_id, uint64 generation, Result<tl_object_ptr<telegram_api::Updates>> result);
|
void on_get_poll_results(PollId poll_id, uint64 generation, Result<tl_object_ptr<telegram_api::Updates>> result);
|
||||||
|
|
||||||
void do_set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector<string> &&options, uint64 logevent_id,
|
void do_set_poll_answer(PollId poll_id, FullMessageId full_message_id, vector<string> &&options, uint64 logevent_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user