Improve Game constructor.
This commit is contained in:
parent
895d7f68d8
commit
6fad8e897f
@ -22,12 +22,15 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
Game::Game(Td *td, tl_object_ptr<telegram_api::game> &&game, DialogId owner_dialog_id)
|
||||
Game::Game(Td *td, UserId bot_user_id, tl_object_ptr<telegram_api::game> &&game, FormattedText text,
|
||||
DialogId owner_dialog_id)
|
||||
: Game(td, std::move(game->title_), std::move(game->description_), std::move(game->photo_),
|
||||
std::move(game->document_), owner_dialog_id) {
|
||||
id_ = game->id_;
|
||||
access_hash_ = game->access_hash_;
|
||||
bot_user_id_ = bot_user_id.is_valid() ? bot_user_id : UserId();
|
||||
short_name_ = game->short_name_;
|
||||
text_ = std::move(text);
|
||||
}
|
||||
|
||||
Game::Game(Td *td, string title, string description, tl_object_ptr<telegram_api::Photo> &&photo,
|
||||
@ -65,14 +68,6 @@ bool Game::is_empty() const {
|
||||
return short_name_.empty();
|
||||
}
|
||||
|
||||
void Game::set_bot_user_id(UserId bot_user_id) {
|
||||
if (bot_user_id.is_valid()) {
|
||||
bot_user_id_ = bot_user_id;
|
||||
} else {
|
||||
bot_user_id_ = UserId();
|
||||
}
|
||||
}
|
||||
|
||||
UserId Game::get_bot_user_id() const {
|
||||
return bot_user_id_;
|
||||
}
|
||||
@ -83,10 +78,6 @@ vector<FileId> Game::get_file_ids(const Td *td) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Game::set_text(FormattedText &&text) {
|
||||
text_ = std::move(text);
|
||||
}
|
||||
|
||||
const FormattedText &Game::get_text() const {
|
||||
return text_;
|
||||
}
|
||||
|
@ -44,23 +44,22 @@ class Game {
|
||||
public:
|
||||
Game() = default;
|
||||
|
||||
Game(Td *td, tl_object_ptr<telegram_api::game> &&game, DialogId owner_dialog_id);
|
||||
Game(Td *td, UserId bot_user_id, tl_object_ptr<telegram_api::game> &&game, FormattedText text,
|
||||
DialogId owner_dialog_id);
|
||||
|
||||
// for inline results
|
||||
Game(Td *td, string title, string description, tl_object_ptr<telegram_api::Photo> &&photo,
|
||||
tl_object_ptr<telegram_api::Document> &&document, DialogId owner_dialog_id);
|
||||
|
||||
// for outgoing messages
|
||||
Game(UserId bot_user_id, string short_name);
|
||||
|
||||
bool is_empty() const;
|
||||
|
||||
void set_bot_user_id(UserId bot_user_id);
|
||||
|
||||
UserId get_bot_user_id() const;
|
||||
|
||||
vector<FileId> get_file_ids(const Td *td) const;
|
||||
|
||||
void set_text(FormattedText &&text);
|
||||
|
||||
const FormattedText &get_text() const;
|
||||
|
||||
tl_object_ptr<td_api::game> get_game_object(Td *td, bool skip_bot_commands) const;
|
||||
|
@ -4171,14 +4171,11 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
|
||||
case telegram_api::messageMediaGame::ID: {
|
||||
auto message_game = move_tl_object_as<telegram_api::messageMediaGame>(media);
|
||||
|
||||
auto m = make_unique<MessageGame>(Game(td, std::move(message_game->game_), owner_dialog_id));
|
||||
auto m =
|
||||
make_unique<MessageGame>(Game(td, via_bot_user_id, std::move(message_game->game_), message, owner_dialog_id));
|
||||
if (m->game.is_empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
m->game.set_bot_user_id(via_bot_user_id);
|
||||
m->game.set_text(std::move(message));
|
||||
|
||||
return std::move(m);
|
||||
}
|
||||
case telegram_api::messageMediaInvoice::ID:
|
||||
|
Loading…
Reference in New Issue
Block a user