mirror of
https://github.com/PaiGramTeam/telegram-bot-api.git
synced 2024-11-16 12:51:24 +00:00
Improve log message.
This commit is contained in:
parent
6b137be127
commit
01ff608cfa
@ -2900,10 +2900,11 @@ class Client::TdOnResolveBotUsernameCallback : public TdQueryCallback {
|
|||||||
template <class OnSuccess>
|
template <class OnSuccess>
|
||||||
class Client::TdOnCheckMessageCallback : public TdQueryCallback {
|
class Client::TdOnCheckMessageCallback : public TdQueryCallback {
|
||||||
public:
|
public:
|
||||||
TdOnCheckMessageCallback(Client *client, int64 chat_id, bool allow_empty, Slice message_type, PromisedQueryPtr query,
|
TdOnCheckMessageCallback(Client *client, int64 chat_id, int64 message_id, bool allow_empty, Slice message_type,
|
||||||
OnSuccess on_success)
|
PromisedQueryPtr query, OnSuccess on_success)
|
||||||
: client_(client)
|
: client_(client)
|
||||||
, chat_id_(chat_id)
|
, chat_id_(chat_id)
|
||||||
|
, message_id_(message_id)
|
||||||
, allow_empty_(allow_empty)
|
, allow_empty_(allow_empty)
|
||||||
, message_type_(message_type)
|
, message_type_(message_type)
|
||||||
, query_(std::move(query))
|
, query_(std::move(query))
|
||||||
@ -2914,7 +2915,7 @@ class Client::TdOnCheckMessageCallback : public TdQueryCallback {
|
|||||||
if (result->get_id() == td_api::error::ID) {
|
if (result->get_id() == td_api::error::ID) {
|
||||||
auto error = move_object_as<td_api::error>(result);
|
auto error = move_object_as<td_api::error>(result);
|
||||||
if (error->code_ == 429) {
|
if (error->code_ == 429) {
|
||||||
LOG(WARNING) << "Failed to get " << message_type_;
|
LOG(WARNING) << "Failed to get message " << message_id_ << " in " << chat_id_ << ": " << message_type_;
|
||||||
}
|
}
|
||||||
if (allow_empty_) {
|
if (allow_empty_) {
|
||||||
return on_success_(chat_id_, 0, std::move(query_));
|
return on_success_(chat_id_, 0, std::move(query_));
|
||||||
@ -2925,12 +2926,14 @@ class Client::TdOnCheckMessageCallback : public TdQueryCallback {
|
|||||||
CHECK(result->get_id() == td_api::message::ID);
|
CHECK(result->get_id() == td_api::message::ID);
|
||||||
auto full_message_id = client_->add_message(move_object_as<td_api::message>(result));
|
auto full_message_id = client_->add_message(move_object_as<td_api::message>(result));
|
||||||
CHECK(full_message_id.chat_id == chat_id_);
|
CHECK(full_message_id.chat_id == chat_id_);
|
||||||
|
CHECK(full_message_id.message_id == message_id_);
|
||||||
on_success_(full_message_id.chat_id, full_message_id.message_id, std::move(query_));
|
on_success_(full_message_id.chat_id, full_message_id.message_id, std::move(query_));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Client *client_;
|
Client *client_;
|
||||||
int64 chat_id_;
|
int64 chat_id_;
|
||||||
|
int64 message_id_;
|
||||||
bool allow_empty_;
|
bool allow_empty_;
|
||||||
Slice message_type_;
|
Slice message_type_;
|
||||||
PromisedQueryPtr query_;
|
PromisedQueryPtr query_;
|
||||||
@ -3926,9 +3929,10 @@ void Client::check_message(Slice chat_id_str, int64 message_id, bool allow_empty
|
|||||||
return on_success(chat_id, 0, std::move(query));
|
return on_success(chat_id, 0, std::move(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
send_request(make_object<td_api::getMessage>(chat_id, message_id),
|
send_request(
|
||||||
std::make_unique<TdOnCheckMessageCallback<OnSuccess>>(
|
make_object<td_api::getMessage>(chat_id, message_id),
|
||||||
this, chat_id, allow_empty, message_type, std::move(query), std::move(on_success)));
|
std::make_unique<TdOnCheckMessageCallback<OnSuccess>>(
|
||||||
|
this, chat_id, message_id, allow_empty, message_type, std::move(query), std::move(on_success)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user