2016-04-05 01:09:46 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-05 01:09:46 +04:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-05 01:09:46 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2020-05-27 18:31:39 +04:00
|
|
|
#include "data/data_cloud_file.h"
|
2020-11-12 18:46:17 +03:00
|
|
|
#include "api/api_common.h"
|
2021-06-14 09:21:56 +03:00
|
|
|
#include "media/view/media_view_open_common.h"
|
2022-02-11 07:40:11 +03:00
|
|
|
#include "ui/effects/message_sending_animation_common.h"
|
2020-05-27 18:31:39 +04:00
|
|
|
|
2016-04-05 01:09:46 +04:00
|
|
|
class FileLoader;
|
2019-09-13 09:06:02 +03:00
|
|
|
class History;
|
2020-11-12 18:46:17 +03:00
|
|
|
class UserData;
|
2021-10-02 15:28:21 +04:00
|
|
|
struct HistoryMessageMarkupData;
|
2019-06-21 14:27:46 +02:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
class LocationPoint;
|
|
|
|
} // namespace Data
|
2016-04-05 01:09:46 +04:00
|
|
|
|
|
|
|
namespace InlineBots {
|
|
|
|
|
|
|
|
namespace Layout {
|
|
|
|
class ItemBase;
|
|
|
|
} // namespace Layout
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
class SendData;
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
class Result {
|
|
|
|
private:
|
|
|
|
// See http://stackoverflow.com/a/8147326
|
|
|
|
struct Creator;
|
|
|
|
|
|
|
|
public:
|
2017-02-21 16:45:56 +03:00
|
|
|
// Constructor is public only for std::make_unique<>() to work.
|
2016-04-05 01:09:46 +04:00
|
|
|
// You should use create() static method instead.
|
2020-05-28 17:51:18 +04:00
|
|
|
Result(not_null<Main::Session*> session, const Creator &creator);
|
|
|
|
|
|
|
|
static std::unique_ptr<Result> Create(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
uint64 queryId,
|
|
|
|
const MTPBotInlineResult &mtpData);
|
2016-04-05 01:09:46 +04:00
|
|
|
|
2016-04-06 00:24:27 +04:00
|
|
|
uint64 getQueryId() const {
|
|
|
|
return _queryId;
|
|
|
|
}
|
|
|
|
QString getId() const {
|
|
|
|
return _id;
|
|
|
|
}
|
2016-04-05 01:09:46 +04:00
|
|
|
|
2016-04-06 00:24:27 +04:00
|
|
|
// This is real SendClickHandler::onClick implementation for the specified
|
|
|
|
// inline bot result. If it returns true you need to send this result.
|
|
|
|
bool onChoose(Layout::ItemBase *layout);
|
2016-04-05 01:09:46 +04:00
|
|
|
|
2021-06-14 09:21:56 +03:00
|
|
|
Media::View::OpenRequest openRequest();
|
2016-04-05 01:09:46 +04:00
|
|
|
void cancelFile();
|
|
|
|
|
|
|
|
bool hasThumbDisplay() const;
|
|
|
|
|
2019-08-09 20:19:23 +01:00
|
|
|
void addToHistory(
|
|
|
|
History *history,
|
2021-07-28 14:55:02 +03:00
|
|
|
MessageFlags flags,
|
2019-08-09 20:19:23 +01:00
|
|
|
MsgId msgId,
|
2020-09-01 10:44:18 +04:00
|
|
|
PeerId fromId,
|
2021-07-28 14:55:02 +03:00
|
|
|
TimeId date,
|
2019-08-09 20:19:23 +01:00
|
|
|
UserId viaBotId,
|
|
|
|
MsgId replyToId,
|
|
|
|
const QString &postAuthor) const;
|
2017-06-11 20:33:20 +02:00
|
|
|
QString getErrorOnSend(History *history) const;
|
2016-04-05 01:09:46 +04:00
|
|
|
|
|
|
|
// interface for Layout:: usage
|
2019-06-21 14:27:46 +02:00
|
|
|
std::optional<Data::LocationPoint> getLocationPoint() const;
|
2016-04-05 01:09:46 +04:00
|
|
|
QString getLayoutTitle() const;
|
|
|
|
QString getLayoutDescription() const;
|
|
|
|
|
2016-09-29 00:33:05 +03:00
|
|
|
~Result();
|
|
|
|
|
2016-04-05 01:09:46 +04:00
|
|
|
private:
|
2020-06-08 13:06:50 +04:00
|
|
|
void createGame(not_null<Main::Session*> session);
|
2018-03-04 23:04:13 +03:00
|
|
|
QSize thumbBox() const;
|
|
|
|
MTPWebDocument adjustAttributes(const MTPWebDocument &document);
|
|
|
|
MTPVector<MTPDocumentAttribute> adjustAttributes(
|
|
|
|
const MTPVector<MTPDocumentAttribute> &document,
|
|
|
|
const MTPstring &mimeType);
|
2016-04-09 12:29:34 +04:00
|
|
|
|
2016-04-06 00:24:27 +04:00
|
|
|
enum class Type {
|
|
|
|
Unknown,
|
|
|
|
Photo,
|
|
|
|
Video,
|
|
|
|
Audio,
|
|
|
|
Sticker,
|
|
|
|
File,
|
|
|
|
Gif,
|
|
|
|
Article,
|
|
|
|
Contact,
|
2016-04-11 14:59:01 +04:00
|
|
|
Geo,
|
2016-04-06 00:24:27 +04:00
|
|
|
Venue,
|
2016-09-28 19:23:25 +03:00
|
|
|
Game,
|
2016-04-06 00:24:27 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
friend class internal::SendData;
|
|
|
|
friend class Layout::ItemBase;
|
2016-04-05 01:09:46 +04:00
|
|
|
struct Creator {
|
2020-05-28 17:51:18 +04:00
|
|
|
uint64 queryId = 0;
|
|
|
|
Type type = Type::Unknown;
|
2016-04-05 01:09:46 +04:00
|
|
|
};
|
|
|
|
|
2020-05-28 17:51:18 +04:00
|
|
|
not_null<Main::Session*> _session;
|
2016-04-06 00:24:27 +04:00
|
|
|
uint64 _queryId = 0;
|
|
|
|
QString _id;
|
|
|
|
Type _type = Type::Unknown;
|
2018-03-04 23:04:13 +03:00
|
|
|
QString _title, _description, _url;
|
|
|
|
QString _content_url;
|
2016-04-06 00:24:27 +04:00
|
|
|
DocumentData *_document = nullptr;
|
|
|
|
PhotoData *_photo = nullptr;
|
2016-09-28 19:23:25 +03:00
|
|
|
GameData *_game = nullptr;
|
2016-04-06 00:24:27 +04:00
|
|
|
|
2021-10-02 15:28:21 +04:00
|
|
|
std::unique_ptr<HistoryMessageMarkupData> _replyMarkup;
|
2016-04-06 12:00:37 +04:00
|
|
|
|
2020-05-27 18:31:39 +04:00
|
|
|
Data::CloudImage _thumbnail;
|
|
|
|
Data::CloudImage _locationThumbnail;
|
2016-04-06 00:24:27 +04:00
|
|
|
|
2017-02-21 16:45:56 +03:00
|
|
|
std::unique_ptr<internal::SendData> sendData;
|
2016-04-05 01:09:46 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-11-12 18:46:17 +03:00
|
|
|
struct ResultSelected {
|
|
|
|
not_null<Result*> result;
|
|
|
|
not_null<UserData*> bot;
|
2022-03-25 18:13:30 +04:00
|
|
|
PeerData *recipientOverride = nullptr;
|
2020-11-12 18:46:17 +03:00
|
|
|
Api::SendOptions options;
|
2022-02-11 07:40:11 +03:00
|
|
|
Ui::MessageSendingAnimationFrom messageSendingFrom;
|
2021-06-14 09:21:56 +03:00
|
|
|
// Open in OverlayWidget;
|
|
|
|
bool open = false;
|
2020-11-12 18:46:17 +03:00
|
|
|
};
|
|
|
|
|
2016-04-05 01:09:46 +04:00
|
|
|
} // namespace InlineBots
|