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
|
|
|
|
|
2016-04-13 00:31:28 +03:00
|
|
|
#include "core/basic_types.h"
|
2016-04-05 01:09:46 +04:00
|
|
|
|
|
|
|
class FileLoader;
|
|
|
|
|
|
|
|
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.
|
|
|
|
explicit Result(const Creator &creator);
|
2017-02-21 16:45:56 +03:00
|
|
|
static std::unique_ptr<Result> create(uint64 queryId, const MTPBotInlineResult &mtpData);
|
2016-04-05 01:09:46 +04:00
|
|
|
Result(const Result &other) = delete;
|
|
|
|
Result &operator=(const Result &other) = delete;
|
|
|
|
|
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
|
|
|
|
2016-04-10 15:13:37 +04:00
|
|
|
void forget();
|
2016-04-06 00:24:27 +04:00
|
|
|
void openFile();
|
2016-04-05 01:09:46 +04:00
|
|
|
void cancelFile();
|
|
|
|
|
|
|
|
bool hasThumbDisplay() const;
|
|
|
|
|
2017-07-12 22:14:20 +03:00
|
|
|
void addToHistory(History *history, MTPDmessage::Flags flags, MsgId msgId, UserId fromId, MTPint mtpDate, 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
|
|
|
|
bool getLocationCoords(LocationCoords *outLocation) const;
|
|
|
|
QString getLayoutTitle() const;
|
|
|
|
QString getLayoutDescription() const;
|
|
|
|
|
2016-09-29 00:33:05 +03:00
|
|
|
~Result();
|
|
|
|
|
2016-04-05 01:09:46 +04:00
|
|
|
private:
|
2016-04-10 15:13:37 +04:00
|
|
|
void createPhoto();
|
2016-04-09 12:29:34 +04:00
|
|
|
void createDocument();
|
2016-09-28 19:23:25 +03:00
|
|
|
void createGame();
|
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 {
|
|
|
|
uint64 queryId;
|
|
|
|
Type type;
|
|
|
|
};
|
|
|
|
|
2016-04-06 00:24:27 +04:00
|
|
|
uint64 _queryId = 0;
|
|
|
|
QString _id;
|
|
|
|
Type _type = Type::Unknown;
|
|
|
|
QString _title, _description, _url, _thumb_url;
|
|
|
|
QString _content_type, _content_url;
|
|
|
|
int _width = 0;
|
|
|
|
int _height = 0;
|
|
|
|
int _duration = 0;
|
|
|
|
|
|
|
|
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
|
|
|
|
2017-02-21 16:45:56 +03:00
|
|
|
std::unique_ptr<MTPReplyMarkup> _mtpKeyboard;
|
2016-04-06 12:00:37 +04:00
|
|
|
|
2016-04-06 00:24:27 +04:00
|
|
|
ImagePtr _thumb, _locationThumb;
|
|
|
|
|
2017-02-21 16:45:56 +03:00
|
|
|
std::unique_ptr<internal::SendData> sendData;
|
2016-04-05 01:09:46 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace InlineBots
|