2020-10-01 18:28:10 +02:00
|
|
|
//
|
2021-01-01 13:57:46 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021
|
2020-10-01 18:28:10 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/MessageContentType.h"
|
|
|
|
#include "td/telegram/secret_api.h"
|
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class DialogAction {
|
|
|
|
enum class Type : int32 {
|
|
|
|
Cancel,
|
|
|
|
Typing,
|
|
|
|
RecordingVideo,
|
|
|
|
UploadingVideo,
|
|
|
|
RecordingVoiceNote,
|
|
|
|
UploadingVoiceNote,
|
|
|
|
UploadingPhoto,
|
|
|
|
UploadingDocument,
|
|
|
|
ChoosingLocation,
|
|
|
|
ChoosingContact,
|
|
|
|
StartPlayingGame,
|
|
|
|
RecordingVideoNote,
|
2020-11-23 17:50:03 +01:00
|
|
|
UploadingVideoNote,
|
2021-01-20 23:50:21 +01:00
|
|
|
SpeakingInVoiceChat,
|
2021-08-19 21:43:38 +02:00
|
|
|
ImportingMessages,
|
2021-09-15 16:11:44 +02:00
|
|
|
ChoosingSticker,
|
2021-09-19 20:40:07 +02:00
|
|
|
WatchingAnimations,
|
2021-09-17 14:51:42 +02:00
|
|
|
ClickingAnimatedEmoji
|
2020-10-01 18:28:10 +02:00
|
|
|
};
|
|
|
|
Type type_ = Type::Cancel;
|
|
|
|
int32 progress_ = 0;
|
2021-09-15 16:11:44 +02:00
|
|
|
string emoji_;
|
2020-10-01 18:28:10 +02:00
|
|
|
|
|
|
|
DialogAction(Type type, int32 progress);
|
|
|
|
|
2020-10-01 18:35:54 +02:00
|
|
|
void init(Type type);
|
|
|
|
|
|
|
|
void init(Type type, int32 progress);
|
|
|
|
|
2021-09-15 16:11:44 +02:00
|
|
|
void init(Type type, string emoji);
|
|
|
|
|
2021-09-17 14:51:42 +02:00
|
|
|
void init(Type type, int32 message_id, string emoji, string data);
|
|
|
|
|
2021-09-15 16:11:44 +02:00
|
|
|
static bool is_valid_emoji(string &emoji);
|
|
|
|
|
2020-10-01 18:35:54 +02:00
|
|
|
public:
|
|
|
|
DialogAction() = default;
|
|
|
|
|
2021-09-28 16:31:00 +02:00
|
|
|
explicit DialogAction(td_api::object_ptr<td_api::ChatAction> &&action);
|
2020-10-01 18:28:10 +02:00
|
|
|
|
2021-09-28 16:31:00 +02:00
|
|
|
explicit DialogAction(telegram_api::object_ptr<telegram_api::SendMessageAction> &&action);
|
2020-10-01 18:28:10 +02:00
|
|
|
|
|
|
|
tl_object_ptr<telegram_api::SendMessageAction> get_input_send_message_action() const;
|
|
|
|
|
|
|
|
tl_object_ptr<secret_api::SendMessageAction> get_secret_input_send_message_action() const;
|
|
|
|
|
|
|
|
td_api::object_ptr<td_api::ChatAction> get_chat_action_object() const;
|
|
|
|
|
2021-05-31 20:51:48 +02:00
|
|
|
bool is_canceled_by_message_of_type(MessageContentType message_content_type) const;
|
2020-10-01 18:28:10 +02:00
|
|
|
|
|
|
|
static DialogAction get_uploading_action(MessageContentType message_content_type, int32 progress);
|
|
|
|
|
2020-10-01 18:30:07 +02:00
|
|
|
static DialogAction get_typing_action();
|
|
|
|
|
2020-12-04 15:06:37 +01:00
|
|
|
static DialogAction get_speaking_action();
|
|
|
|
|
2021-01-26 01:13:09 +01:00
|
|
|
int32 get_importing_messages_action_progress() const;
|
|
|
|
|
2021-09-19 20:40:07 +02:00
|
|
|
string get_watching_animations_emoji() const;
|
2021-09-19 00:52:56 +02:00
|
|
|
|
2021-09-17 14:51:42 +02:00
|
|
|
struct ClickingAnimateEmojiInfo {
|
|
|
|
int32 message_id;
|
|
|
|
string emoji;
|
|
|
|
string data;
|
|
|
|
};
|
|
|
|
ClickingAnimateEmojiInfo get_clicking_animated_emoji_action_info() const;
|
|
|
|
|
2020-10-01 18:35:54 +02:00
|
|
|
friend bool operator==(const DialogAction &lhs, const DialogAction &rhs) {
|
2021-09-15 16:11:44 +02:00
|
|
|
return lhs.type_ == rhs.type_ && lhs.progress_ == rhs.progress_ && lhs.emoji_ == rhs.emoji_;
|
2020-10-01 18:35:54 +02:00
|
|
|
}
|
2020-10-01 18:28:10 +02:00
|
|
|
|
2020-10-01 18:35:54 +02:00
|
|
|
friend StringBuilder &operator<<(StringBuilder &string_builder, const DialogAction &action);
|
|
|
|
};
|
2020-10-01 18:28:10 +02:00
|
|
|
|
|
|
|
inline bool operator!=(const DialogAction &lhs, const DialogAction &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const DialogAction &action);
|
|
|
|
|
|
|
|
} // namespace td
|