1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2026
//
// 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/AiComposeTone.h"
#include "td/telegram/CustomEmojiId.h"
#include "td/telegram/MessageEntity.h"
#include "td/telegram/MessageFullId.h"
#include "td/telegram/RichMessage.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/Promise.h"
#include "td/utils/Status.h"
namespace td {
class Td;
class TranslationManager final : public Actor {
public:
TranslationManager(Td *td, ActorShared<> parent);
void on_authorization_success();
static Status check_tone(string &tone);
static telegram_api::object_ptr<telegram_api::InputAiComposeTone> clone_input_ai_compose_tone(
const telegram_api::object_ptr<telegram_api::InputAiComposeTone> &input_tone);
struct InputText {
FormattedText text_;
bool skip_bot_commands_ = true;
int32 max_media_timestamp_ = -1;
};
void translate_text(td_api::object_ptr<td_api::formattedText> &&text, const string &to_language_code, string tone,
Promise<td_api::object_ptr<td_api::formattedText>> &&promise);
void translate_text(InputText &&text, MessageFullId message_full_id, const string &to_language_code, string tone,
Promise<td_api::object_ptr<td_api::formattedText>> &&promise);
struct InputRichMessage {
RichMessage message_;
bool skip_bot_commands_ = true;
};
void translate_rich_message(td_api::object_ptr<td_api::inputRichMessage> &&message, const string &to_language_code,
string tone, Promise<td_api::object_ptr<td_api::richMessage>> &&promise);
void translate_rich_message(InputRichMessage &&input_rich_message, MessageFullId message_full_id,
const string &to_language_code, string tone,
Promise<td_api::object_ptr<td_api::richMessage>> &&promise);
void do_translate_rich_message(RichMessage &&rich_message, MessageFullId message_full_id,
const string &to_language_code, string tone,
Promise<vector<telegram_api::object_ptr<telegram_api::richMessage>>> &&promise);
void compose_message_with_ai(td_api::object_ptr<td_api::formattedText> &&text,
const string &translate_to_language_code, string tone, bool emojify,
Promise<td_api::object_ptr<td_api::formattedText>> &&promise);
void do_compose_rich_message_with_ai(bool has_message, TranslationManager::InputRichMessage &&message,
const string &translate_to_language_code,
telegram_api::object_ptr<telegram_api::InputAiComposeTone> &&input_tone,
bool emojify, bool proofread,
Promise<td_api::object_ptr<td_api::richMessage>> &&promise);
void compose_rich_message_with_ai(td_api::object_ptr<td_api::inputRichMessage> &&message,
const string &translate_to_language_code, string tone, const string &custom_prompt,
bool emojify, Promise<td_api::object_ptr<td_api::richMessage>> &&promise);
void create_rich_message_with_ai(const string &prompt, const string &language_code, bool emojify,
Promise<td_api::object_ptr<td_api::richMessage>> &&promise);
void proofread_message_with_ai(td_api::object_ptr<td_api::formattedText> &&text,
Promise<td_api::object_ptr<td_api::fixedText>> &&promise);
void proofread_rich_message_with_ai(td_api::object_ptr<td_api::inputRichMessage> &&message,
Promise<td_api::object_ptr<td_api::richMessage>> &&promise);
void reload_ai_compose_tones(Promise<Unit> &&promise);
void on_get_ai_compose_tones(telegram_api::object_ptr<telegram_api::aicompose_Tones> &&tones_ptr);
void create_tone(const string &title, CustomEmojiId custom_emoji_id, const string &prompt, bool show_creator,
Promise<td_api::object_ptr<td_api::textCompositionStyle>> &&promise);
void update_tone(const string &name, const string &title, CustomEmojiId custom_emoji_id, const string &prompt,
bool show_creator, Promise<td_api::object_ptr<td_api::textCompositionStyle>> &&promise);
void delete_tone(const string &name, Promise<Unit> &&promise);
void search_tone(const string &name, Promise<td_api::object_ptr<td_api::textCompositionStyle>> &&promise);
void get_tone_example(const string &name, int32 num,
Promise<td_api::object_ptr<td_api::textCompositionStyleExample>> &&promise);
void add_tone(const string &name, Promise<Unit> &&promise);
void remove_tone(const string &name, Promise<Unit> &&promise);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:
void start_up() final;
void tear_down() final;
Result<InputText> get_input_text(td_api::object_ptr<td_api::formattedText> &&text) const;
Result<InputRichMessage> get_input_rich_message(td_api::object_ptr<td_api::inputRichMessage> &&text) const;
void on_get_translated_texts(vector<telegram_api::object_ptr<telegram_api::textWithEntities>> texts,
bool skip_bot_commands, int32 max_media_timestamp,
Promise<td_api::object_ptr<td_api::formattedText>> &&promise);
void on_get_translated_rich_messages(vector<telegram_api::object_ptr<telegram_api::richMessage>> rich_messages,
bool skip_bot_commands,
Promise<td_api::object_ptr<td_api::richMessage>> &&promise);
void do_create_tone(const string &title, CustomEmojiId custom_emoji_id, const string &prompt, bool show_creator,
Promise<td_api::object_ptr<td_api::textCompositionStyle>> &&promise);
void do_update_tone(const string &name, const string &title, CustomEmojiId custom_emoji_id, const string &prompt,
bool show_creator, Promise<td_api::object_ptr<td_api::textCompositionStyle>> &&promise);
static string get_ai_compose_tones_key();
void send_update_text_composition_styles() const;
Td *td_;
ActorShared<> parent_;
AiComposeTones ai_compose_tones_;
};
} // namespace td
|