2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2018-12-31 20:04:05 +01: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)
|
|
|
|
//
|
2021-09-18 23:47:05 +02:00
|
|
|
#include "td/telegram/Client.h"
|
|
|
|
#include "td/telegram/ClientActor.h"
|
|
|
|
#include "td/telegram/td_api_json.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-04-07 01:38:28 +02:00
|
|
|
#include "td/net/HttpQuery.h"
|
2018-04-06 15:24:29 +02:00
|
|
|
#include "td/net/HttpReader.h"
|
|
|
|
|
2021-09-18 23:47:05 +02:00
|
|
|
#include "td/actor/actor.h"
|
|
|
|
#include "td/actor/ConcurrentScheduler.h"
|
|
|
|
|
|
|
|
#include "memprof/memprof.h"
|
2019-12-24 01:55:36 +01:00
|
|
|
|
2021-01-01 13:59:53 +01:00
|
|
|
#include "td/utils/algorithm.h"
|
2018-04-23 22:33:51 +02:00
|
|
|
#include "td/utils/base64.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/buffer.h"
|
2021-05-17 16:33:26 +02:00
|
|
|
#include "td/utils/CombinedLog.h"
|
2019-02-12 22:26:36 +01:00
|
|
|
#include "td/utils/common.h"
|
2020-08-08 20:56:34 +02:00
|
|
|
#include "td/utils/crypto.h"
|
2020-10-11 13:45:22 +02:00
|
|
|
#include "td/utils/ExitGuard.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/FileLog.h"
|
2021-01-22 17:14:35 +01:00
|
|
|
#include "td/utils/filesystem.h"
|
2022-02-07 22:04:34 +01:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
2022-03-11 19:38:48 +01:00
|
|
|
#include "td/utils/FlatHashSet.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/format.h"
|
|
|
|
#include "td/utils/JsonBuilder.h"
|
|
|
|
#include "td/utils/logging.h"
|
|
|
|
#include "td/utils/misc.h"
|
2021-05-18 16:06:22 +02:00
|
|
|
#include "td/utils/NullLog.h"
|
2020-06-17 04:30:14 +02:00
|
|
|
#include "td/utils/OptionParser.h"
|
2021-11-18 14:25:37 +01:00
|
|
|
#include "td/utils/port/detail/ThreadIdGuard.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/port/FileFd.h"
|
2018-09-10 03:08:15 +02:00
|
|
|
#include "td/utils/port/PollFlags.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/port/signals.h"
|
|
|
|
#include "td/utils/port/Stat.h"
|
2018-08-17 15:41:51 +02:00
|
|
|
#include "td/utils/port/StdStreams.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/port/thread_local.h"
|
2019-04-26 02:18:00 +02:00
|
|
|
#include "td/utils/Random.h"
|
2018-02-09 18:02:01 +01:00
|
|
|
#include "td/utils/ScopeGuard.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Slice.h"
|
2021-05-17 14:21:11 +02:00
|
|
|
#include "td/utils/SliceBuilder.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/utils/Status.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
#include "td/utils/Time.h"
|
2021-05-18 16:40:37 +02:00
|
|
|
#include "td/utils/TsLog.h"
|
2021-01-22 17:14:35 +01:00
|
|
|
#include "td/utils/utf8.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
#ifndef USE_READLINE
|
|
|
|
#include "td/utils/find_boundary.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <atomic>
|
2018-09-10 20:45:34 +02:00
|
|
|
#include <cstdio>
|
2018-12-31 20:04:05 +01:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <ctime>
|
2018-01-24 16:45:57 +01:00
|
|
|
#include <iostream>
|
2018-12-31 20:04:05 +01:00
|
|
|
#include <limits>
|
2018-02-09 18:02:01 +01:00
|
|
|
#include <locale>
|
2020-08-01 20:57:03 +02:00
|
|
|
#include <memory>
|
2018-12-31 20:04:05 +01:00
|
|
|
#include <queue>
|
|
|
|
#include <tuple>
|
2020-12-25 22:43:38 +01:00
|
|
|
#include <utility>
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
#ifdef USE_READLINE
|
|
|
|
/* Standard readline include files. */
|
|
|
|
#include <readline/history.h>
|
|
|
|
#include <readline/readline.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2018-01-24 16:45:57 +01:00
|
|
|
static void dump_memory_usage() {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (is_memprof_on()) {
|
2019-02-21 16:58:20 +01:00
|
|
|
LOG(WARNING) << "Memory dump:";
|
2018-12-31 20:04:05 +01:00
|
|
|
clear_thread_locals();
|
2020-06-24 13:33:20 +02:00
|
|
|
std::vector<AllocInfo> alloc_info;
|
|
|
|
dump_alloc([&](const AllocInfo &info) { alloc_info.push_back(info); });
|
|
|
|
std::sort(alloc_info.begin(), alloc_info.end(),
|
|
|
|
[](const AllocInfo &lhs, const AllocInfo &rhs) { return lhs.size > rhs.size; });
|
2018-12-31 20:04:05 +01:00
|
|
|
size_t total_size = 0;
|
|
|
|
size_t other_size = 0;
|
|
|
|
int cnt = 0;
|
2020-06-24 13:33:20 +02:00
|
|
|
for (auto &info : alloc_info) {
|
2018-12-31 20:04:05 +01:00
|
|
|
if (cnt++ < 50) {
|
2019-09-15 05:19:46 +02:00
|
|
|
LOG(WARNING) << format::as_size(info.size) << format::as_array(info.backtrace);
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
other_size += info.size;
|
|
|
|
}
|
|
|
|
total_size += info.size;
|
|
|
|
}
|
2019-09-15 05:19:46 +02:00
|
|
|
LOG(WARNING) << tag("other", format::as_size(other_size));
|
|
|
|
LOG(WARNING) << tag("total", format::as_size(total_size));
|
2018-12-31 20:04:05 +01:00
|
|
|
LOG(WARNING) << tag("total traces", get_ht_size());
|
|
|
|
LOG(WARNING) << tag("fast_backtrace_success_rate", get_fast_backtrace_success_rate());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_READLINE
|
|
|
|
const char *prompt = "td_cli> ";
|
|
|
|
static int32 saved_point;
|
|
|
|
static string saved_line;
|
|
|
|
static std::atomic_flag readline_lock = ATOMIC_FLAG_INIT;
|
|
|
|
|
2018-01-24 16:45:57 +01:00
|
|
|
static void deactivate_readline() {
|
2018-12-31 20:04:05 +01:00
|
|
|
while (readline_lock.test_and_set(std::memory_order_acquire)) {
|
|
|
|
// spin
|
|
|
|
}
|
|
|
|
|
|
|
|
saved_point = rl_point;
|
|
|
|
saved_line = string(rl_line_buffer, rl_end);
|
|
|
|
|
|
|
|
rl_set_prompt("");
|
|
|
|
rl_replace_line("", 0);
|
|
|
|
rl_redisplay();
|
|
|
|
}
|
|
|
|
|
2018-01-24 16:45:57 +01:00
|
|
|
static void reactivate_readline() {
|
2018-12-31 20:04:05 +01:00
|
|
|
rl_set_prompt(prompt);
|
|
|
|
rl_replace_line(saved_line.c_str(), 0);
|
|
|
|
rl_point = saved_point;
|
|
|
|
rl_redisplay();
|
|
|
|
|
|
|
|
readline_lock.clear(std::memory_order_release);
|
|
|
|
}
|
|
|
|
|
2018-01-24 16:45:57 +01:00
|
|
|
static char *command_generator(const char *text, int state) {
|
2021-08-11 14:59:09 +02:00
|
|
|
static const vector<CSlice> commands{"GetHistory", "SetVerbosity", "SendVideo",
|
|
|
|
"SearchDocument", "GetChatMember", "GetSupergroupAdministrators",
|
|
|
|
"GetSupergroupBanned", "GetSupergroupMembers", "GetFile",
|
|
|
|
"DownloadFile", "CancelDownloadFile", "ImportContacts",
|
|
|
|
"RemoveContacts", "CreateSecretChat", "CreateNewSecretChat"};
|
2018-12-31 20:04:05 +01:00
|
|
|
static size_t cmd_i;
|
|
|
|
if (state == 0) {
|
|
|
|
cmd_i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (cmd_i < commands.size()) {
|
|
|
|
const char *a = commands[cmd_i++].c_str();
|
|
|
|
const char *b = text;
|
|
|
|
const char *c = b;
|
|
|
|
while (*c && to_lower(*c) == *c) {
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
bool only_lowercase = !is_alpha(*c);
|
|
|
|
while (*a && *b) {
|
|
|
|
if (*a == *b || (only_lowercase && *a == to_upper(*b))) {
|
|
|
|
b++;
|
|
|
|
}
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
if (*b == 0) {
|
|
|
|
// TODO call to strdup is completely wrong. Readline will try to call std::free() on the returned char*,
|
|
|
|
// which may be incompatible with the std::malloc() called by strdup
|
|
|
|
// It is especially likely to happen if Readline is used as dynamic library
|
|
|
|
// Unfortunately Readline doesn't provide memory allocation functions/memory deallocation callbacks to fix this
|
|
|
|
#if TD_MSVC
|
|
|
|
return _strdup(commands[cmd_i - 1].c_str());
|
|
|
|
#else
|
|
|
|
return strdup(commands[cmd_i - 1].c_str());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-24 16:45:57 +01:00
|
|
|
static char **tg_cli_completion(const char *text, int start, int end) {
|
2018-12-31 20:04:05 +01:00
|
|
|
char **matches = nullptr;
|
|
|
|
if (start == 0) {
|
|
|
|
matches = rl_completion_matches(text, command_generator);
|
|
|
|
}
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CliLog final : public LogInterface {
|
2021-05-17 15:18:19 +02:00
|
|
|
void do_append(int log_level, CSlice slice) final {
|
2018-12-31 20:04:05 +01:00
|
|
|
#ifdef USE_READLINE
|
|
|
|
deactivate_readline();
|
2018-08-17 15:41:51 +02:00
|
|
|
SCOPE_EXIT {
|
|
|
|
reactivate_readline();
|
|
|
|
};
|
2018-12-31 20:04:05 +01:00
|
|
|
#endif
|
2021-05-18 15:55:35 +02:00
|
|
|
default_log_interface->do_append(log_level, slice);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-17 16:33:26 +02:00
|
|
|
static CombinedLog combined_log;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct SendMessageInfo {
|
|
|
|
double start_time = 0;
|
|
|
|
double quick_ack_time = 0;
|
|
|
|
double ack_time = 0;
|
|
|
|
bool empty() const {
|
|
|
|
return quick_ack_time != 0 || ack_time != 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &sb, const SendMessageInfo &info) {
|
|
|
|
sb << format::cond(info.quick_ack_time != 0, tag("quick_ack", info.quick_ack_time - info.start_time));
|
|
|
|
sb << format::cond(info.ack_time != 0, tag("ack", info.ack_time - info.start_time));
|
|
|
|
return sb;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CliClient final : public Actor {
|
|
|
|
public:
|
2018-09-11 12:37:44 +02:00
|
|
|
CliClient(ConcurrentScheduler *scheduler, bool use_test_dc, bool get_chat_list, bool disable_network, int32 api_id,
|
|
|
|
string api_hash)
|
2018-09-11 09:31:05 +02:00
|
|
|
: scheduler_(scheduler)
|
|
|
|
, use_test_dc_(use_test_dc)
|
2018-12-31 20:04:05 +01:00
|
|
|
, get_chat_list_(get_chat_list)
|
|
|
|
, disable_network_(disable_network)
|
|
|
|
, api_id_(api_id)
|
2021-10-19 17:11:16 +02:00
|
|
|
, api_hash_(std::move(api_hash)) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void quit_instance() {
|
|
|
|
instance_->quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-07-03 22:51:36 +02:00
|
|
|
void start_up() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
yield();
|
|
|
|
}
|
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<uint64, SendMessageInfo> query_id_to_send_message_info_;
|
|
|
|
FlatHashMap<uint64, SendMessageInfo> message_id_to_send_message_info_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
struct User {
|
|
|
|
string first_name;
|
|
|
|
string last_name;
|
|
|
|
string username;
|
|
|
|
};
|
|
|
|
|
2022-02-11 17:27:32 +01:00
|
|
|
FlatHashMap<int64, unique_ptr<User>> users_;
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<string, int64> username_to_user_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-11-24 15:01:02 +01:00
|
|
|
vector<string> authentication_tokens_;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void register_user(const td_api::user &user) {
|
2022-02-11 17:27:32 +01:00
|
|
|
auto &new_user_ptr = users_[user.id_];
|
|
|
|
if (new_user_ptr == nullptr) {
|
|
|
|
new_user_ptr = make_unique<User>();
|
|
|
|
}
|
|
|
|
User &new_user = *new_user_ptr;
|
2018-12-31 20:04:05 +01:00
|
|
|
new_user.first_name = user.first_name_;
|
|
|
|
new_user.last_name = user.last_name_;
|
2022-10-12 20:04:18 +02:00
|
|
|
if (user.usernames_ != nullptr) {
|
|
|
|
for (auto &username : user.usernames_->active_usernames_) {
|
|
|
|
username_to_user_id_[to_lower(username)] = user.id_;
|
|
|
|
}
|
2022-02-09 22:59:52 +01:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
void print_user(Logger &log, int64 user_id, bool full = false) {
|
2022-02-11 17:27:32 +01:00
|
|
|
const User *user = users_[user_id].get();
|
|
|
|
CHECK(user != nullptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
log << user->first_name << " " << user->last_name << " #" << user_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void update_users(const td_api::users &users) {
|
2018-08-14 09:42:40 +02:00
|
|
|
Logger log{*log_interface, LogOptions::plain(), VERBOSITY_NAME(PLAIN)};
|
2018-12-31 20:04:05 +01:00
|
|
|
for (auto &user_id : users.user_ids_) {
|
|
|
|
if (user_id == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
print_user(log, user_id);
|
|
|
|
log << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<string, int64> username_to_supergroup_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
void register_supergroup(const td_api::supergroup &supergroup) {
|
2022-10-12 20:04:18 +02:00
|
|
|
if (supergroup.usernames_ != nullptr) {
|
|
|
|
for (auto &username : supergroup.usernames_->active_usernames_) {
|
|
|
|
username_to_supergroup_id_[to_lower(username)] = supergroup.id_;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void update_option(const td_api::updateOption &option) {
|
2020-09-24 23:46:16 +02:00
|
|
|
if (option.name_ == "my_id" && option.value_->get_id() == td_api::optionValueInteger::ID) {
|
2021-09-03 11:27:59 +02:00
|
|
|
my_id_ = static_cast<const td_api::optionValueInteger *>(option.value_.get())->value_;
|
2021-03-15 01:32:14 +01:00
|
|
|
LOG(INFO) << "Set my user identifier to " << my_id_;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-11-24 15:01:02 +01:00
|
|
|
if (option.name_ == "authentication_token" && option.value_->get_id() == td_api::optionValueString::ID) {
|
|
|
|
authentication_tokens_.insert(authentication_tokens_.begin(),
|
|
|
|
static_cast<const td_api::optionValueString *>(option.value_.get())->value_);
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-06-01 01:12:36 +02:00
|
|
|
int64 get_history_chat_id_ = 0;
|
|
|
|
int64 search_chat_id_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_get_messages(const td_api::messages &messages) {
|
2018-06-01 01:12:36 +02:00
|
|
|
if (get_history_chat_id_ != 0) {
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 last_message_id = 0;
|
2022-10-11 22:36:23 +02:00
|
|
|
int32 last_message_date = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
for (auto &m : messages.messages_) {
|
|
|
|
// LOG(PLAIN) << to_string(m);
|
|
|
|
if (m->content_->get_id() == td_api::messageText::ID) {
|
2019-09-15 05:19:46 +02:00
|
|
|
LOG(PLAIN) << oneline(static_cast<const td_api::messageText *>(m->content_.get())->text_->text_) << "\n";
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
last_message_id = m->id_;
|
2022-10-11 22:36:23 +02:00
|
|
|
last_message_date = m->date_;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-10-11 22:36:23 +02:00
|
|
|
if (last_message_id > 0 && last_message_date > 1660000000) {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatHistory>(get_history_chat_id_, last_message_id, 0, 100, false));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
2018-06-01 01:12:36 +02:00
|
|
|
get_history_chat_id_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-01 01:12:36 +02:00
|
|
|
if (search_chat_id_ != 0) {
|
2018-01-10 17:59:38 +01:00
|
|
|
if (!messages.messages_.empty()) {
|
|
|
|
auto last_message_id = messages.messages_.back()->id_;
|
|
|
|
LOG(ERROR) << (last_message_id >> 20);
|
2020-12-26 19:12:09 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(search_chat_id_, "", nullptr, last_message_id, 0,
|
|
|
|
100, as_search_messages_filter("pvi"), 0));
|
2018-01-10 17:59:38 +01:00
|
|
|
} else {
|
2018-06-01 01:12:36 +02:00
|
|
|
search_chat_id_ = 0;
|
2018-01-10 17:59:38 +01:00
|
|
|
}
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void on_get_message(const td_api::message &message) {
|
|
|
|
if (message.sending_state_ != nullptr &&
|
|
|
|
message.sending_state_->get_id() == td_api::messageSendingStatePending::ID) {
|
2019-02-21 17:48:05 +01:00
|
|
|
// send_request(td_api::make_object<td_api::deleteMessages>(message.chat_id_, vector<int64>{message.id_}, true));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-01 01:12:36 +02:00
|
|
|
void on_get_file(const td_api::file &file) {
|
2018-06-01 02:05:46 +02:00
|
|
|
if (being_downloaded_files_.count(file.id_) == 0 && file.local_->is_downloading_active_) {
|
|
|
|
being_downloaded_files_[file.id_] = Time::now();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (being_downloaded_files_.count(file.id_) != 0 && !file.local_->is_downloading_active_) {
|
2018-06-01 01:12:36 +02:00
|
|
|
double elapsed_time = Time::now() - being_downloaded_files_[file.id_];
|
|
|
|
being_downloaded_files_.erase(file.id_);
|
|
|
|
if (file.local_->is_downloading_completed_) {
|
2018-06-01 02:05:46 +02:00
|
|
|
LOG(ERROR) << "File " << file.id_ << " was downloaded in " << elapsed_time << " seconds";
|
2018-06-01 01:12:36 +02:00
|
|
|
} else {
|
2018-06-01 02:05:46 +02:00
|
|
|
LOG(ERROR) << "File " << file.id_ << " has failed to download in " << elapsed_time << " seconds";
|
2018-06-01 01:12:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
struct FileGeneration {
|
|
|
|
int64 id = 0;
|
|
|
|
string destination;
|
|
|
|
string source;
|
2022-05-11 16:17:20 +02:00
|
|
|
int64 part_size = 0;
|
|
|
|
int64 local_size = 0;
|
|
|
|
int64 size = 0;
|
2018-11-21 11:56:14 +01:00
|
|
|
bool test_local_size_decrease = false;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
2018-06-01 01:12:36 +02:00
|
|
|
vector<FileGeneration> pending_file_generations_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void on_file_generation_start(const td_api::updateFileGenerationStart &update) {
|
|
|
|
FileGeneration file_generation;
|
|
|
|
file_generation.id = update.generation_id_;
|
|
|
|
file_generation.destination = update.destination_path_;
|
2018-10-31 19:11:02 +01:00
|
|
|
if (update.conversion_ == "#url#" || update.conversion_ == "url") {
|
2018-12-31 20:04:05 +01:00
|
|
|
// TODO: actually download
|
|
|
|
file_generation.source = "test.jpg";
|
|
|
|
file_generation.part_size = 1000000;
|
2018-03-18 11:45:59 +01:00
|
|
|
} else if (update.conversion_ == "skip") {
|
|
|
|
return;
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
file_generation.source = update.original_path_;
|
2022-05-11 16:17:20 +02:00
|
|
|
file_generation.part_size = to_integer<int64>(update.conversion_);
|
2018-11-21 11:56:14 +01:00
|
|
|
file_generation.test_local_size_decrease = !update.conversion_.empty() && update.conversion_.back() == 't';
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
auto r_stat = stat(file_generation.source);
|
|
|
|
if (r_stat.is_ok()) {
|
|
|
|
auto size = r_stat.ok().size_;
|
2022-05-11 16:17:20 +02:00
|
|
|
if (size <= 0 || size > (static_cast<int64>(4000) << 20)) {
|
2018-12-31 20:04:05 +01:00
|
|
|
r_stat = Status::Error(400, size == 0 ? Slice("File is empty") : Slice("File is too big"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (r_stat.is_ok()) {
|
|
|
|
file_generation.size = narrow_cast<int32>(r_stat.ok().size_);
|
|
|
|
if (file_generation.part_size <= 0) {
|
|
|
|
file_generation.part_size = file_generation.size;
|
|
|
|
}
|
2018-06-01 01:12:36 +02:00
|
|
|
pending_file_generations_.push_back(std::move(file_generation));
|
2018-12-31 20:04:05 +01:00
|
|
|
timeout_expired();
|
|
|
|
} else {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::finishFileGeneration>(
|
2018-12-31 20:04:05 +01:00
|
|
|
update.generation_id_, td_api::make_object<td_api::error>(400, r_stat.error().message().str())));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-28 15:25:51 +01:00
|
|
|
void on_update_authorization_state(td_api::object_ptr<td_api::AuthorizationState> &&state) {
|
2022-01-02 10:19:14 +01:00
|
|
|
authorization_state_ = std::move(state);
|
|
|
|
switch (authorization_state_->get_id()) {
|
2018-09-15 14:24:25 +02:00
|
|
|
case td_api::authorizationStateWaitTdlibParameters::ID: {
|
2022-09-07 21:19:08 +02:00
|
|
|
auto request = td_api::make_object<td_api::setTdlibParameters>();
|
2022-12-30 21:13:40 +01:00
|
|
|
// request->database_encryption_key_ = "!";
|
2022-09-07 21:19:08 +02:00
|
|
|
request->use_test_dc_ = use_test_dc_;
|
|
|
|
request->use_message_database_ = true;
|
|
|
|
request->use_chat_info_database_ = true;
|
|
|
|
request->use_secret_chats_ = true;
|
|
|
|
request->api_id_ = api_id_;
|
|
|
|
request->api_hash_ = api_hash_;
|
|
|
|
request->system_language_code_ = "en";
|
|
|
|
request->device_model_ = "Desktop";
|
|
|
|
request->application_version_ = "1.0";
|
2022-06-16 15:11:24 +02:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setOption>("use_pfs", td_api::make_object<td_api::optionValueBoolean>(true)));
|
2022-09-07 21:19:08 +02:00
|
|
|
send_request(std::move(request));
|
2018-09-15 14:24:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case td_api::authorizationStateReady::ID:
|
|
|
|
LOG(INFO) << "Logged in";
|
|
|
|
break;
|
|
|
|
case td_api::authorizationStateClosed::ID:
|
2022-03-03 19:11:34 +01:00
|
|
|
LOG(WARNING) << "Td closed";
|
2018-10-28 18:30:47 +01:00
|
|
|
td_client_.reset();
|
2018-09-15 14:24:25 +02:00
|
|
|
if (!close_flag_) {
|
|
|
|
create_td("ClientActor3");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-18 16:09:32 +01:00
|
|
|
static char get_delimiter(Slice str) {
|
2022-03-11 19:38:48 +01:00
|
|
|
FlatHashSet<char> chars;
|
2019-12-18 16:09:32 +01:00
|
|
|
for (auto c : trim(str)) {
|
2023-03-06 19:43:27 +01:00
|
|
|
if (!is_alnum(c) && c != '_' && c != '-' && c != '@' && c != '.' && c != '/' && c != '\0' &&
|
|
|
|
static_cast<uint8>(c) <= 127) {
|
2019-12-18 16:09:32 +01:00
|
|
|
chars.insert(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chars.empty()) {
|
|
|
|
return ' ';
|
|
|
|
}
|
|
|
|
if (chars.size() == 1) {
|
|
|
|
return *chars.begin();
|
|
|
|
}
|
|
|
|
LOG(ERROR) << "Failed to determine delimiter in \"" << str << '"';
|
|
|
|
return ' ';
|
|
|
|
}
|
|
|
|
|
2022-01-24 15:40:16 +01:00
|
|
|
static vector<Slice> autosplit(Slice str) {
|
|
|
|
return full_split(trim(str), get_delimiter(str));
|
|
|
|
}
|
|
|
|
|
|
|
|
static vector<string> autosplit_str(Slice str) {
|
|
|
|
return transform(autosplit(str), [](Slice slice) { return slice.str(); });
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
int64 as_chat_id(Slice str) const {
|
|
|
|
str = trim(str);
|
2021-02-20 20:01:12 +01:00
|
|
|
if (str == "me") {
|
|
|
|
return my_id_;
|
|
|
|
}
|
2021-11-28 09:49:46 +01:00
|
|
|
if (str == ".") {
|
|
|
|
return opened_chat_id_;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
if (str[0] == '@') {
|
2021-02-20 20:01:12 +01:00
|
|
|
str.remove_prefix(1);
|
|
|
|
}
|
|
|
|
if (is_alpha(str[0])) {
|
|
|
|
auto it = username_to_user_id_.find(to_lower(str));
|
2018-12-31 20:04:05 +01:00
|
|
|
if (it != username_to_user_id_.end()) {
|
|
|
|
return it->second;
|
|
|
|
}
|
2021-02-20 20:01:12 +01:00
|
|
|
auto it2 = username_to_supergroup_id_.find(to_lower(str));
|
2018-06-01 01:12:36 +02:00
|
|
|
if (it2 != username_to_supergroup_id_.end()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto supergroup_id = it2->second;
|
|
|
|
return static_cast<int64>(-1000'000'000'000ll) - supergroup_id;
|
|
|
|
}
|
|
|
|
LOG(ERROR) << "Can't resolve " << str;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return to_integer<int64>(str);
|
|
|
|
}
|
|
|
|
|
2023-04-03 16:28:51 +02:00
|
|
|
static int32 as_chat_folder_id(Slice str) {
|
2020-05-18 01:29:28 +02:00
|
|
|
return to_integer<int32>(trim(str));
|
|
|
|
}
|
|
|
|
|
2023-04-03 16:28:51 +02:00
|
|
|
static vector<int32> as_chat_folder_ids(Slice chat_folder_ids) {
|
|
|
|
return transform(autosplit(chat_folder_ids), as_chat_folder_id);
|
2020-05-19 01:41:07 +02:00
|
|
|
}
|
|
|
|
|
2019-08-27 16:23:01 +02:00
|
|
|
static td_api::object_ptr<td_api::ChatList> as_chat_list(string chat_list) {
|
|
|
|
if (!chat_list.empty() && chat_list.back() == 'a') {
|
|
|
|
return td_api::make_object<td_api::chatListArchive>();
|
|
|
|
}
|
2020-05-22 00:19:28 +02:00
|
|
|
if (chat_list.find('-') != string::npos) {
|
2023-04-03 16:28:51 +02:00
|
|
|
return td_api::make_object<td_api::chatListFolder>(as_chat_folder_id(chat_list.substr(chat_list.find('-') + 1)));
|
2020-05-22 00:19:28 +02:00
|
|
|
}
|
2019-08-27 16:23:01 +02:00
|
|
|
return td_api::make_object<td_api::chatListMain>();
|
|
|
|
}
|
|
|
|
|
2023-07-08 14:55:49 +02:00
|
|
|
static td_api::object_ptr<td_api::StoryList> as_story_list(string story_list) {
|
2023-07-28 16:33:47 +02:00
|
|
|
if (story_list.empty() || story_list.back() == 'e') {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (story_list.back() == 'a') {
|
2023-07-08 14:55:49 +02:00
|
|
|
return td_api::make_object<td_api::storyListArchive>();
|
|
|
|
}
|
2023-07-28 16:33:47 +02:00
|
|
|
return td_api::make_object<td_api::storyListMain>();
|
|
|
|
}
|
|
|
|
|
|
|
|
static td_api::object_ptr<td_api::BlockList> as_block_list(string block_list) {
|
|
|
|
if (block_list.empty()) {
|
2023-07-08 14:55:49 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2023-07-28 16:33:47 +02:00
|
|
|
if (block_list.back() == 's') {
|
|
|
|
return td_api::make_object<td_api::blockListStories>();
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::blockListMain>();
|
2023-07-08 14:55:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-18 16:09:32 +01:00
|
|
|
vector<int64> as_chat_ids(Slice chat_ids) const {
|
2022-01-24 15:40:16 +01:00
|
|
|
return transform(autosplit(chat_ids), [this](Slice str) { return as_chat_id(str); });
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int64 as_message_id(Slice str) {
|
2018-02-07 00:31:38 +01:00
|
|
|
str = trim(str);
|
|
|
|
if (!str.empty() && str.back() == 's') {
|
2018-05-03 10:57:19 +02:00
|
|
|
return to_integer<int64>(str) << 20;
|
2018-02-07 00:31:38 +01:00
|
|
|
}
|
|
|
|
return to_integer<int64>(str);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-12-18 16:09:32 +01:00
|
|
|
static vector<int64> as_message_ids(Slice message_ids) {
|
2022-01-24 15:40:16 +01:00
|
|
|
return transform(autosplit(message_ids), as_message_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-09-11 16:51:01 +02:00
|
|
|
static int64 as_message_thread_id(Slice str) {
|
|
|
|
return as_message_id(str);
|
|
|
|
}
|
|
|
|
|
2022-12-29 21:48:19 +01:00
|
|
|
static vector<int64> as_message_thread_ids(Slice str) {
|
|
|
|
return as_message_ids(str);
|
|
|
|
}
|
|
|
|
|
2020-10-14 20:47:20 +02:00
|
|
|
td_api::object_ptr<td_api::MessageSender> as_message_sender(Slice sender_id) const {
|
|
|
|
sender_id = trim(sender_id);
|
2023-06-03 21:12:45 +02:00
|
|
|
auto user_id = as_user_id(sender_id, true);
|
|
|
|
if (sender_id.empty() || user_id > 0) {
|
|
|
|
return td_api::make_object<td_api::messageSenderUser>(user_id);
|
2020-10-14 13:41:04 +02:00
|
|
|
} else {
|
2020-10-14 20:47:20 +02:00
|
|
|
return td_api::make_object<td_api::messageSenderChat>(as_chat_id(sender_id));
|
2020-10-14 13:41:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-20 22:24:36 +02:00
|
|
|
static int32 as_story_id(Slice str) {
|
|
|
|
return to_integer<int32>(trim(str));
|
|
|
|
}
|
|
|
|
|
2022-07-14 12:58:33 +02:00
|
|
|
static td_api::object_ptr<td_api::StickerFormat> as_sticker_format(string sticker_format) {
|
|
|
|
if (!sticker_format.empty() && sticker_format.back() == 'a') {
|
|
|
|
return td_api::make_object<td_api::stickerFormatTgs>();
|
2022-01-25 14:56:10 +01:00
|
|
|
}
|
2022-07-14 12:58:33 +02:00
|
|
|
if (!sticker_format.empty() && sticker_format.back() == 'v') {
|
|
|
|
return td_api::make_object<td_api::stickerFormatWebm>();
|
2022-01-25 14:56:10 +01:00
|
|
|
}
|
2022-07-14 12:58:33 +02:00
|
|
|
return td_api::make_object<td_api::stickerFormatWebp>();
|
|
|
|
}
|
|
|
|
|
|
|
|
static td_api::object_ptr<td_api::StickerType> as_sticker_type(string sticker_type) {
|
2022-07-14 15:42:27 +02:00
|
|
|
if (!sticker_type.empty() && sticker_type.back() == 'e') {
|
2022-07-19 13:51:29 +02:00
|
|
|
return td_api::make_object<td_api::stickerTypeCustomEmoji>();
|
2022-07-14 15:42:27 +02:00
|
|
|
}
|
2022-07-14 13:38:25 +02:00
|
|
|
if (!sticker_type.empty() && sticker_type.back() == 'm') {
|
|
|
|
return td_api::make_object<td_api::stickerTypeMask>();
|
|
|
|
}
|
|
|
|
return Random::fast_bool() ? nullptr : td_api::make_object<td_api::stickerTypeRegular>();
|
|
|
|
}
|
|
|
|
|
|
|
|
static td_api::object_ptr<td_api::maskPosition> as_mask_position(string sticker_type) {
|
2022-01-26 15:53:38 +01:00
|
|
|
if (!sticker_type.empty() && sticker_type.back() == 'm') {
|
2022-01-25 14:56:10 +01:00
|
|
|
auto position = td_api::make_object<td_api::maskPosition>(td_api::make_object<td_api::maskPointEyes>(),
|
|
|
|
Random::fast(-5, 5), Random::fast(-5, 5), 1.0);
|
2022-07-14 13:38:25 +02:00
|
|
|
return Random::fast_bool() ? nullptr : std::move(position);
|
2022-01-25 14:56:10 +01:00
|
|
|
}
|
2022-07-14 13:38:25 +02:00
|
|
|
return nullptr;
|
2022-01-25 14:56:10 +01:00
|
|
|
}
|
|
|
|
|
2020-12-25 23:25:00 +01:00
|
|
|
static int32 as_limit(Slice str, int32 default_limit = 10) {
|
|
|
|
if (str.empty()) {
|
|
|
|
return default_limit;
|
|
|
|
}
|
|
|
|
return to_integer<int32>(trim(str));
|
|
|
|
}
|
|
|
|
|
2023-06-03 21:12:45 +02:00
|
|
|
int64 as_user_id(Slice str, bool expect_error = false) const {
|
2018-12-31 20:04:05 +01:00
|
|
|
str = trim(str);
|
2021-02-20 20:01:12 +01:00
|
|
|
if (str == "me") {
|
|
|
|
return my_id_;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
if (str[0] == '@') {
|
2021-02-20 20:01:12 +01:00
|
|
|
str.remove_prefix(1);
|
|
|
|
}
|
|
|
|
if (is_alpha(str[0])) {
|
|
|
|
auto it = username_to_user_id_.find(to_lower(str));
|
2018-12-31 20:04:05 +01:00
|
|
|
if (it != username_to_user_id_.end()) {
|
|
|
|
return it->second;
|
|
|
|
}
|
2023-06-03 21:12:45 +02:00
|
|
|
if (!expect_error) {
|
|
|
|
LOG(ERROR) << "Can't find user " << str;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2021-09-03 11:27:59 +02:00
|
|
|
return to_integer<int64>(str);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
vector<int64> as_user_ids(Slice user_ids) const {
|
2022-01-24 15:40:16 +01:00
|
|
|
return transform(autosplit(user_ids), [this](Slice str) { return as_user_id(str); });
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
static int64 as_basic_group_id(Slice str) {
|
2019-01-07 16:37:53 +01:00
|
|
|
str = trim(str);
|
2021-09-03 11:27:59 +02:00
|
|
|
auto result = to_integer<int64>(str);
|
2019-01-07 16:37:53 +01:00
|
|
|
if (result < 0) {
|
|
|
|
return -result;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 as_supergroup_id(Slice str) const {
|
2019-01-07 16:37:53 +01:00
|
|
|
str = trim(str);
|
2020-03-04 01:10:50 +01:00
|
|
|
if (str[0] == '@') {
|
2021-02-20 20:01:12 +01:00
|
|
|
str.remove_prefix(1);
|
|
|
|
}
|
|
|
|
if (is_alpha(str[0])) {
|
2021-02-22 16:06:18 +01:00
|
|
|
auto it = username_to_supergroup_id_.find(to_lower(str));
|
|
|
|
if (it == username_to_supergroup_id_.end()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return it->second;
|
2020-03-04 01:10:50 +01:00
|
|
|
}
|
2019-01-07 16:37:53 +01:00
|
|
|
auto result = to_integer<int64>(str);
|
2021-10-19 17:11:16 +02:00
|
|
|
auto shift = static_cast<int64>(-1000000000000ll);
|
2019-01-07 16:37:53 +01:00
|
|
|
if (result <= shift) {
|
2021-09-03 11:27:59 +02:00
|
|
|
return shift - result;
|
2019-01-07 16:37:53 +01:00
|
|
|
}
|
2021-09-03 11:27:59 +02:00
|
|
|
return result;
|
2019-01-07 16:37:53 +01:00
|
|
|
}
|
|
|
|
|
2019-02-11 18:57:35 +01:00
|
|
|
static int32 as_secret_chat_id(Slice str) {
|
2019-01-07 16:37:53 +01:00
|
|
|
str = trim(str);
|
|
|
|
auto result = to_integer<int64>(str);
|
2021-10-19 17:11:16 +02:00
|
|
|
auto shift = static_cast<int64>(-2000000000000ll);
|
2019-01-07 16:37:53 +01:00
|
|
|
if (result <= shift + std::numeric_limits<int32>::max()) {
|
|
|
|
return static_cast<int32>(result - shift);
|
|
|
|
}
|
|
|
|
return static_cast<int32>(result);
|
|
|
|
}
|
|
|
|
|
2019-10-08 17:19:35 +02:00
|
|
|
static int32 as_file_id(Slice str) {
|
|
|
|
return to_integer<int32>(trim(str));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-10-08 17:19:35 +02:00
|
|
|
static td_api::object_ptr<td_api::InputFile> as_input_file_id(Slice str) {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputFileId>(as_file_id(str));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::InputFile> as_local_file(string path) {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputFileLocal>(trim(std::move(path)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::InputFile> as_remote_file(string id) {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputFileRemote>(trim(std::move(id)));
|
2018-04-23 22:33:51 +02:00
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::InputFile> as_generated_file(string original_path, string conversion,
|
2022-05-11 16:17:20 +02:00
|
|
|
int64 expected_size = 0) {
|
2021-10-19 17:11:16 +02:00
|
|
|
return td_api::make_object<td_api::inputFileGenerated>(trim(std::move(original_path)), trim(std::move(conversion)),
|
|
|
|
expected_size);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-01-24 15:40:16 +01:00
|
|
|
static td_api::object_ptr<td_api::InputFile> as_input_file(Slice str) {
|
2019-10-08 17:19:35 +02:00
|
|
|
str = trim(str);
|
2019-02-08 15:54:23 +01:00
|
|
|
if ((str.size() >= 20 && is_base64url(str)) || begins_with(str, "http")) {
|
2022-01-24 15:40:16 +01:00
|
|
|
return as_remote_file(str.str());
|
2018-04-23 22:33:51 +02:00
|
|
|
}
|
2021-09-03 11:27:59 +02:00
|
|
|
auto r_file_id = to_integer_safe<int32>(str);
|
|
|
|
if (r_file_id.is_ok()) {
|
2018-04-23 22:33:51 +02:00
|
|
|
return as_input_file_id(str);
|
|
|
|
}
|
|
|
|
if (str.find(';') < str.size()) {
|
|
|
|
auto res = split(str, ';');
|
2022-01-24 15:40:16 +01:00
|
|
|
return as_generated_file(res.first.str(), res.second.str());
|
2018-04-23 22:33:51 +02:00
|
|
|
}
|
2022-01-24 15:40:16 +01:00
|
|
|
return as_local_file(str.str());
|
2018-04-23 22:33:51 +02:00
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::inputThumbnail> as_input_thumbnail(td_api::object_ptr<td_api::InputFile> input_file,
|
|
|
|
int32 width = 0, int32 height = 0) {
|
2018-06-01 00:22:27 +02:00
|
|
|
return td_api::make_object<td_api::inputThumbnail>(std::move(input_file), width, height);
|
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::inputThumbnail> as_input_thumbnail(const string &thumbnail, int32 width = 0,
|
|
|
|
int32 height = 0) {
|
2019-10-18 15:03:42 +02:00
|
|
|
return as_input_thumbnail(as_input_file(thumbnail), width, height);
|
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::inputThumbnail> as_input_thumbnail(const string &original_path,
|
|
|
|
const string &conversion, int32 width = 0,
|
|
|
|
int32 height = 0) {
|
2019-10-18 15:03:42 +02:00
|
|
|
return as_input_thumbnail(as_generated_file(original_path, conversion), width, height);
|
|
|
|
}
|
|
|
|
|
2022-04-22 13:44:53 +02:00
|
|
|
struct CallId {
|
|
|
|
int32 call_id = 0;
|
|
|
|
|
|
|
|
operator int32() const {
|
|
|
|
return call_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, CallId &arg) const {
|
|
|
|
arg.call_id = to_integer<int32>(trim(args));
|
2018-05-14 21:00:38 +02:00
|
|
|
}
|
|
|
|
|
2022-04-22 13:50:52 +02:00
|
|
|
struct GroupCallId {
|
|
|
|
int32 group_call_id = 0;
|
|
|
|
|
|
|
|
operator int32() const {
|
|
|
|
return group_call_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, GroupCallId &arg) const {
|
|
|
|
arg.group_call_id = to_integer<int32>(trim(args));
|
2020-11-27 13:31:00 +01:00
|
|
|
}
|
|
|
|
|
2018-05-14 21:00:38 +02:00
|
|
|
static int32 as_proxy_id(string str) {
|
|
|
|
return to_integer<int32>(trim(std::move(str)));
|
|
|
|
}
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static td_api::object_ptr<td_api::location> as_location(const string &latitude, const string &longitude,
|
|
|
|
const string &accuracy) {
|
2019-02-18 01:27:35 +01:00
|
|
|
if (trim(latitude).empty() && trim(longitude).empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-10-17 21:47:47 +02:00
|
|
|
return td_api::make_object<td_api::location>(to_double(latitude), to_double(longitude), to_double(accuracy));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-08-30 10:45:27 +02:00
|
|
|
static td_api::object_ptr<td_api::ReactionType> as_reaction_type(Slice type) {
|
2022-08-16 21:42:29 +02:00
|
|
|
type = trim(type);
|
|
|
|
if (type.empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
auto r_custom_emoji_id = to_integer_safe<int64>(type);
|
|
|
|
if (r_custom_emoji_id.is_ok()) {
|
|
|
|
return td_api::make_object<td_api::reactionTypeCustomEmoji>(r_custom_emoji_id.ok());
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::reactionTypeEmoji>(type.str());
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
static bool as_bool(string str) {
|
2019-10-08 17:19:35 +02:00
|
|
|
str = to_lower(trim(str));
|
2018-12-31 20:04:05 +01:00
|
|
|
return str == "true" || str == "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2022-01-24 15:40:16 +01:00
|
|
|
static vector<T> to_integers(Slice integers) {
|
|
|
|
return transform(transform(autosplit(integers), trim<Slice>), to_integer<T>);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-12-26 18:58:30 +01:00
|
|
|
static void get_args(string &args, string &arg) {
|
2020-12-26 17:40:46 +01:00
|
|
|
if (&args != &arg) {
|
|
|
|
arg = std::move(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-26 18:58:30 +01:00
|
|
|
static void get_args(string &args, bool &arg) {
|
2020-12-26 17:40:46 +01:00
|
|
|
arg = as_bool(args);
|
|
|
|
}
|
|
|
|
|
2020-12-26 18:47:51 +01:00
|
|
|
struct SearchQuery {
|
2021-11-11 15:39:09 +01:00
|
|
|
int32 limit = 0;
|
2020-12-26 18:47:51 +01:00
|
|
|
string query;
|
|
|
|
};
|
|
|
|
|
2020-12-26 18:58:30 +01:00
|
|
|
static void get_args(string &args, SearchQuery &arg) {
|
2020-12-26 18:47:51 +01:00
|
|
|
string limit;
|
|
|
|
std::tie(limit, arg.query) = split(trim(args));
|
|
|
|
auto r_limit = to_integer_safe<int32>(limit);
|
|
|
|
if (r_limit.is_ok() && r_limit.ok() > 0) {
|
|
|
|
arg.limit = r_limit.ok();
|
|
|
|
} else {
|
|
|
|
arg.limit = 10;
|
|
|
|
arg.query = std::move(args);
|
|
|
|
}
|
|
|
|
args.clear();
|
|
|
|
}
|
|
|
|
|
2020-12-26 18:58:30 +01:00
|
|
|
static void get_args(string &args, int32 &arg) {
|
2020-12-26 18:47:51 +01:00
|
|
|
arg = to_integer<int32>(args);
|
|
|
|
}
|
|
|
|
|
2020-12-26 18:58:30 +01:00
|
|
|
static void get_args(string &args, int64 &arg) {
|
2020-12-26 18:47:51 +01:00
|
|
|
arg = to_integer<int64>(args);
|
2020-12-26 17:40:46 +01:00
|
|
|
}
|
|
|
|
|
2023-06-05 13:33:00 +02:00
|
|
|
static void get_args(string &args, double &arg) {
|
|
|
|
arg = to_double(args);
|
|
|
|
}
|
|
|
|
|
2021-12-31 12:20:34 +01:00
|
|
|
struct ChatId {
|
|
|
|
int64 chat_id = 0;
|
|
|
|
|
|
|
|
operator int64() const {
|
|
|
|
return chat_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, ChatId &arg) const {
|
|
|
|
arg.chat_id = as_chat_id(args);
|
|
|
|
}
|
|
|
|
|
2021-12-31 12:31:43 +01:00
|
|
|
struct MessageId {
|
|
|
|
int64 message_id = 0;
|
|
|
|
|
|
|
|
operator int64() const {
|
|
|
|
return message_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, MessageId &arg) const {
|
|
|
|
arg.message_id = as_message_id(args);
|
|
|
|
}
|
|
|
|
|
2022-10-27 13:19:04 +02:00
|
|
|
struct MessageThreadId {
|
|
|
|
int64 message_thread_id = 0;
|
|
|
|
|
|
|
|
operator int64() const {
|
|
|
|
return message_thread_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, MessageThreadId &arg) const {
|
|
|
|
arg.message_thread_id = as_message_thread_id(args);
|
|
|
|
}
|
|
|
|
|
2021-12-31 12:56:57 +01:00
|
|
|
struct UserId {
|
|
|
|
int64 user_id = 0;
|
|
|
|
|
|
|
|
operator int64() const {
|
|
|
|
return user_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, UserId &arg) const {
|
|
|
|
arg.user_id = as_user_id(args);
|
|
|
|
}
|
|
|
|
|
2023-04-03 16:28:51 +02:00
|
|
|
struct ChatFolderId {
|
|
|
|
int32 chat_folder_id = 0;
|
2023-03-30 16:23:26 +02:00
|
|
|
|
|
|
|
operator int32() const {
|
2023-04-03 16:28:51 +02:00
|
|
|
return chat_folder_id;
|
2023-03-30 16:23:26 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-04-03 16:28:51 +02:00
|
|
|
void get_args(string &args, ChatFolderId &arg) const {
|
|
|
|
arg.chat_folder_id = as_chat_folder_id(args);
|
2023-03-30 16:23:26 +02:00
|
|
|
}
|
|
|
|
|
2023-05-20 22:24:36 +02:00
|
|
|
struct StoryId {
|
|
|
|
int32 story_id = 0;
|
|
|
|
|
|
|
|
operator int32() const {
|
|
|
|
return story_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, StoryId &arg) const {
|
|
|
|
arg.story_id = as_story_id(args);
|
|
|
|
}
|
|
|
|
|
2022-02-19 00:42:18 +01:00
|
|
|
struct FileId {
|
|
|
|
int32 file_id = 0;
|
|
|
|
|
|
|
|
operator int32() const {
|
|
|
|
return file_id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, FileId &arg) const {
|
|
|
|
arg.file_id = as_file_id(args);
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:27:24 +02:00
|
|
|
struct MessageReplyTo {
|
|
|
|
int64 message_id = 0;
|
|
|
|
// or
|
|
|
|
int64 user_id = 0;
|
|
|
|
int32 story_id = 0;
|
|
|
|
|
2023-07-01 18:54:22 +02:00
|
|
|
static MessageReplyTo get_default() {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2023-06-08 16:27:24 +02:00
|
|
|
operator td_api::object_ptr<td_api::MessageReplyTo>() const {
|
|
|
|
if (message_id == 0 && user_id == 0 && story_id == 0) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (message_id != 0) {
|
|
|
|
return td_api::make_object<td_api::messageReplyToMessage>(-1, message_id);
|
|
|
|
} else {
|
|
|
|
return td_api::make_object<td_api::messageReplyToStory>(user_id, story_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, MessageReplyTo &arg) const {
|
|
|
|
if (!args.empty() && args != "0") {
|
|
|
|
if (args.find('_') == string::npos) {
|
|
|
|
arg.message_id = as_message_id(args);
|
|
|
|
} else {
|
|
|
|
string user_id;
|
|
|
|
string story_id;
|
|
|
|
std::tie(user_id, story_id) = split(args, '_');
|
|
|
|
arg.user_id = as_user_id(user_id);
|
|
|
|
arg.story_id = as_story_id(story_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-01 19:44:24 +02:00
|
|
|
struct ReportReason {
|
|
|
|
string report_reason;
|
|
|
|
|
|
|
|
operator td_api::object_ptr<td_api::ReportReason>() const {
|
|
|
|
return as_report_reason(report_reason);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, ReportReason &arg) const {
|
|
|
|
arg.report_reason = std::move(args);
|
|
|
|
}
|
|
|
|
|
2022-05-03 17:50:29 +02:00
|
|
|
struct InputInvoice {
|
|
|
|
int64 chat_id = 0;
|
|
|
|
int64 message_id = 0;
|
|
|
|
string invoice_name;
|
|
|
|
|
|
|
|
operator td_api::object_ptr<td_api::InputInvoice>() const {
|
|
|
|
if (invoice_name.empty()) {
|
|
|
|
return td_api::make_object<td_api::inputInvoiceMessage>(chat_id, message_id);
|
|
|
|
} else {
|
|
|
|
return td_api::make_object<td_api::inputInvoiceName>(invoice_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, InputInvoice &arg) const {
|
|
|
|
if (args.size() > 1 && args[0] == '#') {
|
|
|
|
arg.invoice_name = args;
|
|
|
|
} else {
|
|
|
|
string chat_id;
|
|
|
|
string message_id;
|
|
|
|
std::tie(chat_id, message_id) = split(args, get_delimiter(args));
|
2022-06-06 16:11:43 +02:00
|
|
|
arg.chat_id = as_chat_id(chat_id);
|
|
|
|
arg.message_id = as_message_id(message_id);
|
2022-05-03 17:50:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-23 11:53:23 +01:00
|
|
|
struct ChatPhotoSticker {
|
2023-01-20 15:31:33 +01:00
|
|
|
int64 sticker_set_id = 0;
|
|
|
|
int64 sticker_id = 0;
|
|
|
|
|
2023-01-23 11:53:23 +01:00
|
|
|
operator td_api::object_ptr<td_api::chatPhotoSticker>() const {
|
2023-01-20 15:31:33 +01:00
|
|
|
if (sticker_set_id != 0) {
|
2023-01-23 11:53:23 +01:00
|
|
|
return td_api::make_object<td_api::chatPhotoSticker>(
|
|
|
|
td_api::make_object<td_api::chatPhotoStickerTypeRegularOrMask>(sticker_set_id, sticker_id),
|
|
|
|
as_background_fill(0x7FFFFFFF));
|
2023-01-20 15:31:33 +01:00
|
|
|
} else {
|
2023-01-23 11:53:23 +01:00
|
|
|
return td_api::make_object<td_api::chatPhotoSticker>(
|
|
|
|
td_api::make_object<td_api::chatPhotoStickerTypeCustomEmoji>(sticker_id),
|
|
|
|
as_background_fill({0x000000, 0xFF0000, 0x00FF00, 0x0000FF}));
|
2023-01-20 15:31:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-01-23 11:53:23 +01:00
|
|
|
void get_args(string &args, ChatPhotoSticker &arg) const {
|
2023-01-20 15:31:33 +01:00
|
|
|
string sticker_set_id;
|
|
|
|
string sticker_id;
|
|
|
|
std::tie(sticker_set_id, sticker_id) = split(args, get_delimiter(args));
|
2023-01-29 22:35:14 +01:00
|
|
|
if (sticker_id.empty()) {
|
|
|
|
arg.sticker_id = to_integer<int64>(sticker_set_id);
|
|
|
|
} else {
|
|
|
|
arg.sticker_set_id = to_integer<int64>(sticker_set_id);
|
|
|
|
arg.sticker_id = to_integer<int64>(sticker_id);
|
|
|
|
}
|
2023-01-20 15:31:33 +01:00
|
|
|
}
|
|
|
|
|
2023-03-29 21:42:19 +02:00
|
|
|
struct InputChatPhoto {
|
2023-04-07 15:02:31 +02:00
|
|
|
enum class Type : int32 { Null, Previous, Static, Animation, Sticker };
|
2023-03-29 21:42:19 +02:00
|
|
|
Type type = Type::Null;
|
|
|
|
int64 profile_photo_id = 0;
|
|
|
|
string photo;
|
|
|
|
string main_frame_timestamp;
|
|
|
|
ChatPhotoSticker sticker;
|
|
|
|
|
|
|
|
operator td_api::object_ptr<td_api::InputChatPhoto>() const {
|
|
|
|
switch (type) {
|
|
|
|
case Type::Null:
|
|
|
|
return nullptr;
|
|
|
|
case Type::Previous:
|
|
|
|
return td_api::make_object<td_api::inputChatPhotoPrevious>(profile_photo_id);
|
|
|
|
case Type::Static:
|
|
|
|
return td_api::make_object<td_api::inputChatPhotoStatic>(as_input_file(photo));
|
|
|
|
case Type::Animation:
|
|
|
|
return td_api::make_object<td_api::inputChatPhotoAnimation>(as_input_file(photo),
|
|
|
|
to_double(main_frame_timestamp));
|
|
|
|
case Type::Sticker:
|
|
|
|
return td_api::make_object<td_api::inputChatPhotoSticker>(sticker);
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, InputChatPhoto &arg) const {
|
|
|
|
args = trim(args);
|
|
|
|
if (args.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (to_integer_safe<int64>(args).is_ok()) {
|
|
|
|
arg.type = InputChatPhoto::Type::Previous;
|
|
|
|
arg.profile_photo_id = to_integer<int64>(args);
|
|
|
|
} else if (args[0] == 'p') {
|
|
|
|
arg.type = InputChatPhoto::Type::Static;
|
|
|
|
arg.photo = args.substr(1);
|
|
|
|
} else if (args[0] == 'a') {
|
|
|
|
arg.type = InputChatPhoto::Type::Animation;
|
|
|
|
std::tie(arg.photo, arg.main_frame_timestamp) = split(args.substr(1), get_delimiter(args));
|
|
|
|
} else if (args[0] == 's') {
|
|
|
|
arg.type = InputChatPhoto::Type::Sticker;
|
|
|
|
args = args.substr(1);
|
|
|
|
get_args(args, arg.sticker);
|
|
|
|
} else {
|
|
|
|
LOG(ERROR) << "Invalid InputChatPhoto = " << args;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-10 18:41:54 +02:00
|
|
|
struct InputBackground {
|
|
|
|
string background_file;
|
|
|
|
// or
|
|
|
|
int64 background_id = 0;
|
2023-04-11 23:02:42 +02:00
|
|
|
// or
|
|
|
|
int64 message_id = 0;
|
2023-04-10 18:41:54 +02:00
|
|
|
|
|
|
|
operator td_api::object_ptr<td_api::InputBackground>() const {
|
|
|
|
if (!background_file.empty()) {
|
|
|
|
return td_api::make_object<td_api::inputBackgroundLocal>(as_input_file(background_file));
|
|
|
|
}
|
|
|
|
if (background_id != 0) {
|
|
|
|
return td_api::make_object<td_api::inputBackgroundRemote>(background_id);
|
|
|
|
}
|
2023-04-11 23:02:42 +02:00
|
|
|
if (message_id != 0) {
|
|
|
|
return td_api::make_object<td_api::inputBackgroundPrevious>(message_id);
|
|
|
|
}
|
2023-04-10 18:41:54 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, InputBackground &arg) const {
|
|
|
|
args = trim(args);
|
|
|
|
if (args.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (to_integer_safe<int64>(args).is_ok()) {
|
|
|
|
arg.background_id = to_integer<int64>(args);
|
2023-04-11 23:02:42 +02:00
|
|
|
} else if (args.back() == 's' && to_integer_safe<int32>(args.substr(0, args.size() - 1)).is_ok()) {
|
|
|
|
arg.message_id = as_message_id(args);
|
2023-04-10 18:41:54 +02:00
|
|
|
} else {
|
|
|
|
arg.background_file = std::move(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-10 19:22:10 +02:00
|
|
|
struct BackgroundType {
|
|
|
|
enum class Type : int32 { Null, Wallpaper, SolidPattern, GradientPattern, Fill };
|
|
|
|
Type type = Type::Null;
|
|
|
|
vector<int32> colors;
|
|
|
|
|
|
|
|
operator td_api::object_ptr<td_api::BackgroundType>() const {
|
|
|
|
switch (type) {
|
|
|
|
case Type::Null:
|
|
|
|
return nullptr;
|
|
|
|
case Type::Wallpaper:
|
|
|
|
return as_wallpaper_background(rand_bool(), rand_bool());
|
|
|
|
case Type::SolidPattern:
|
|
|
|
return as_solid_pattern_background(0xABCDef, 49, true);
|
|
|
|
case Type::GradientPattern:
|
|
|
|
return as_gradient_pattern_background(0xABCDEF, 0xFE, 51, rand_bool(), false);
|
|
|
|
case Type::Fill:
|
|
|
|
if (colors.size() == 1) {
|
|
|
|
return as_solid_background(colors[0]);
|
|
|
|
}
|
|
|
|
if (colors.size() == 2) {
|
|
|
|
return as_gradient_background(colors[0], colors[1]);
|
|
|
|
}
|
|
|
|
return as_freeform_gradient_background(colors);
|
|
|
|
default:
|
|
|
|
UNREACHABLE();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, BackgroundType &arg) const {
|
|
|
|
args = trim(args);
|
|
|
|
if (args.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (args == "w") {
|
|
|
|
arg.type = BackgroundType::Type::Wallpaper;
|
|
|
|
} else if (args == "sp") {
|
|
|
|
arg.type = BackgroundType::Type::SolidPattern;
|
|
|
|
} else if (args == "gp") {
|
|
|
|
arg.type = BackgroundType::Type::GradientPattern;
|
|
|
|
} else {
|
|
|
|
arg.type = BackgroundType::Type::Fill;
|
|
|
|
arg.colors = to_integers<int32>(args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-25 17:38:15 +02:00
|
|
|
struct PrivacyRules {
|
|
|
|
string rules_str;
|
|
|
|
|
|
|
|
operator td_api::object_ptr<td_api::userPrivacySettingRules>() const {
|
|
|
|
vector<td_api::object_ptr<td_api::UserPrivacySettingRule>> rules;
|
|
|
|
for (size_t i = 0; i < rules_str.size(); i++) {
|
|
|
|
auto arg = vector<int64>{to_integer<int64>(Slice(rules_str).substr(i + 1))};
|
|
|
|
if (rules_str[i] == 'a') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleAllowAll>());
|
|
|
|
} else if (rules_str[i] == 'A') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleRestrictAll>());
|
|
|
|
} else if (rules_str[i] == 'c') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleAllowContacts>());
|
|
|
|
} else if (rules_str[i] == 'C') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleRestrictContacts>());
|
|
|
|
} else if (rules_str[i] == 'u') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleAllowUsers>(std::move(arg)));
|
|
|
|
} else if (rules_str[i] == 'U') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleRestrictUsers>(std::move(arg)));
|
|
|
|
} else if (rules_str[i] == 'm') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleAllowChatMembers>(std::move(arg)));
|
|
|
|
} else if (rules_str[i] == 'M') {
|
|
|
|
rules.push_back(td_api::make_object<td_api::userPrivacySettingRuleRestrictChatMembers>(std::move(arg)));
|
|
|
|
} else if (!is_digit(rules_str[i]) && rules_str[i] != '-') {
|
|
|
|
LOG(ERROR) << "Invalid character " << rules_str[i] << " in privacy rules " << rules_str;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::userPrivacySettingRules>(std::move(rules));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, PrivacyRules &arg) const {
|
|
|
|
arg.rules_str = trim(args);
|
2023-05-25 20:10:02 +02:00
|
|
|
if (arg.rules_str.empty()) {
|
|
|
|
arg.rules_str = "a";
|
|
|
|
}
|
2023-05-25 17:38:15 +02:00
|
|
|
}
|
|
|
|
|
2023-07-18 15:00:06 +02:00
|
|
|
struct StoryPrivacySettings {
|
|
|
|
string settings;
|
2023-08-02 12:52:33 +02:00
|
|
|
vector<int64> user_ids;
|
2023-07-18 15:00:06 +02:00
|
|
|
|
|
|
|
operator td_api::object_ptr<td_api::StoryPrivacySettings>() const {
|
|
|
|
if (settings == "f" || settings == "cf") {
|
|
|
|
return td_api::make_object<td_api::storyPrivacySettingsCloseFriends>();
|
|
|
|
}
|
|
|
|
if (!settings.empty()) {
|
2023-08-02 12:50:44 +02:00
|
|
|
if (settings[0] == 'a' || settings[0] == 'e') {
|
2023-08-02 12:52:33 +02:00
|
|
|
return td_api::make_object<td_api::storyPrivacySettingsEveryone>(vector<int64>(user_ids));
|
2023-08-02 12:50:44 +02:00
|
|
|
}
|
2023-07-18 15:00:06 +02:00
|
|
|
if (settings[0] == 'c') {
|
2023-08-02 12:52:33 +02:00
|
|
|
return td_api::make_object<td_api::storyPrivacySettingsContacts>(vector<int64>(user_ids));
|
2023-07-18 15:00:06 +02:00
|
|
|
}
|
|
|
|
if (settings[0] == 'u') {
|
2023-08-02 12:52:33 +02:00
|
|
|
return td_api::make_object<td_api::storyPrivacySettingsSelectedContacts>(vector<int64>(user_ids));
|
2023-07-18 15:00:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::storyPrivacySettingsContacts>();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void get_args(string &args, StoryPrivacySettings &arg) const {
|
|
|
|
arg.settings = trim(args);
|
2023-08-02 12:52:33 +02:00
|
|
|
if (!arg.settings.empty() && arg.settings != "cf") {
|
|
|
|
arg.user_ids = as_user_ids(Slice(arg.settings).substr(1));
|
|
|
|
}
|
2023-07-18 15:00:06 +02:00
|
|
|
}
|
|
|
|
|
2020-12-26 17:40:46 +01:00
|
|
|
template <class FirstType, class SecondType, class... Types>
|
2021-12-31 12:20:34 +01:00
|
|
|
void get_args(string &args, FirstType &first_arg, SecondType &second_arg, Types &...other_args) const {
|
2020-12-26 17:40:46 +01:00
|
|
|
string arg;
|
|
|
|
std::tie(arg, args) = split(args);
|
|
|
|
get_args(arg, first_arg);
|
|
|
|
get_args(args, second_arg, other_args...);
|
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
void on_result(uint64 generation, uint64 id, td_api::object_ptr<td_api::Object> result) {
|
2020-04-18 00:55:54 +02:00
|
|
|
auto result_str = to_string(result);
|
|
|
|
if (result != nullptr) {
|
|
|
|
switch (result->get_id()) {
|
|
|
|
case td_api::stickerSets::ID: {
|
|
|
|
auto sticker_sets = static_cast<const td_api::stickerSets *>(result.get());
|
|
|
|
result_str = PSTRING() << "StickerSets { total_count = " << sticker_sets->total_count_
|
2022-02-11 16:02:11 +01:00
|
|
|
<< ", count = " << sticker_sets->sets_.size();
|
|
|
|
for (auto &sticker_set : sticker_sets->sets_) {
|
|
|
|
result_str += PSTRING() << ", " << sticker_set->name_;
|
|
|
|
}
|
|
|
|
result_str += " }";
|
2020-04-18 00:55:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-06-17 18:16:17 +02:00
|
|
|
case td_api::trendingStickerSets::ID: {
|
|
|
|
auto sticker_sets = static_cast<const td_api::trendingStickerSets *>(result.get());
|
|
|
|
result_str = PSTRING() << "TrendingStickerSets { is_premium = " << sticker_sets->is_premium_
|
|
|
|
<< ", total_count = " << sticker_sets->total_count_
|
|
|
|
<< ", count = " << sticker_sets->sets_.size();
|
|
|
|
for (auto &sticker_set : sticker_sets->sets_) {
|
|
|
|
result_str += PSTRING() << ", " << sticker_set->name_;
|
|
|
|
}
|
|
|
|
result_str += " }";
|
|
|
|
break;
|
|
|
|
}
|
2020-04-18 00:55:54 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-04 11:22:26 +02:00
|
|
|
if (id > 0 && combined_log.get_first_verbosity_level() < get_log_tag_verbosity_level("td_requests")) {
|
2020-04-18 00:55:54 +02:00
|
|
|
LOG(ERROR) << "Receive result [" << generation << "][id=" << id << "] " << result_str;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
auto as_json_str = json_encode<std::string>(ToJson(result));
|
2019-02-21 16:58:20 +01:00
|
|
|
// LOG(INFO) << "Receive result [" << generation << "][id=" << id << "] " << as_json_str;
|
2019-07-01 10:43:31 +02:00
|
|
|
//auto copy_as_json_str = as_json_str;
|
|
|
|
//auto as_json_value = json_decode(copy_as_json_str).move_as_ok();
|
|
|
|
//td_api::object_ptr<td_api::Object> object;
|
|
|
|
//from_json(object, as_json_value).ensure();
|
|
|
|
//CHECK(object != nullptr);
|
|
|
|
//auto as_json_str2 = json_encode<std::string>(ToJson(object));
|
|
|
|
//LOG_CHECK(as_json_str == as_json_str2) << "\n" << tag("a", as_json_str) << "\n" << tag("b", as_json_str2);
|
2019-02-21 16:58:20 +01:00
|
|
|
// LOG(INFO) << "Receive result [" << generation << "][id=" << id << "] " << as_json_str;
|
2018-09-15 14:24:25 +02:00
|
|
|
|
|
|
|
if (generation != generation_) {
|
2020-04-18 00:55:54 +02:00
|
|
|
LOG(INFO) << "Drop received from previous Client " << result_str;
|
2018-09-15 14:24:25 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
int32 result_id = result == nullptr ? 0 : result->get_id();
|
|
|
|
|
|
|
|
[&] {
|
|
|
|
if (id != 0) {
|
|
|
|
auto it = query_id_to_send_message_info_.find(id);
|
|
|
|
if (it == query_id_to_send_message_info_.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto info = it->second;
|
|
|
|
query_id_to_send_message_info_.erase(id);
|
|
|
|
|
|
|
|
if (result_id == td_api::message::ID) {
|
|
|
|
auto *message = static_cast<const td_api::message *>(result.get());
|
|
|
|
message_id_to_send_message_info_[message->id_] = info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
[&] {
|
|
|
|
if (result_id == td_api::updateMessageSendAcknowledged::ID) {
|
|
|
|
auto *message = static_cast<const td_api::updateMessageSendAcknowledged *>(result.get());
|
|
|
|
auto it = message_id_to_send_message_info_.find(message->message_id_);
|
|
|
|
if (it == message_id_to_send_message_info_.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto &info = it->second;
|
|
|
|
info.quick_ack_time = Time::now();
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
[&] {
|
|
|
|
if (result_id == td_api::updateMessageSendSucceeded::ID) {
|
|
|
|
auto *message = static_cast<const td_api::updateMessageSendSucceeded *>(result.get());
|
|
|
|
auto it = message_id_to_send_message_info_.find(message->old_message_id_);
|
|
|
|
if (it == message_id_to_send_message_info_.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto info = it->second;
|
|
|
|
message_id_to_send_message_info_.erase(it);
|
|
|
|
info.ack_time = Time::now();
|
|
|
|
LOG(INFO) << info;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
|
|
|
|
switch (result_id) {
|
|
|
|
case td_api::updateUser::ID:
|
|
|
|
register_user(*static_cast<const td_api::updateUser *>(result.get())->user_);
|
|
|
|
break;
|
|
|
|
case td_api::updateSupergroup::ID:
|
|
|
|
register_supergroup(*static_cast<const td_api::updateSupergroup *>(result.get())->supergroup_);
|
|
|
|
break;
|
|
|
|
case td_api::users::ID:
|
|
|
|
update_users(*static_cast<const td_api::users *>(result.get()));
|
|
|
|
break;
|
|
|
|
case td_api::updateOption::ID:
|
|
|
|
update_option(*static_cast<const td_api::updateOption *>(result.get()));
|
|
|
|
break;
|
|
|
|
case td_api::message::ID:
|
|
|
|
on_get_message(*static_cast<const td_api::message *>(result.get()));
|
|
|
|
break;
|
|
|
|
case td_api::messages::ID:
|
|
|
|
on_get_messages(*static_cast<const td_api::messages *>(result.get()));
|
|
|
|
break;
|
|
|
|
case td_api::updateFileGenerationStart::ID:
|
|
|
|
on_file_generation_start(*static_cast<const td_api::updateFileGenerationStart *>(result.get()));
|
|
|
|
break;
|
2018-09-15 14:24:25 +02:00
|
|
|
case td_api::updateAuthorizationState::ID:
|
2022-02-17 16:42:50 +01:00
|
|
|
LOG(WARNING) << result_str;
|
2022-12-28 15:25:51 +01:00
|
|
|
on_update_authorization_state(
|
2022-01-02 10:19:14 +01:00
|
|
|
std::move(static_cast<td_api::updateAuthorizationState *>(result.get())->authorization_state_));
|
2018-09-15 14:24:25 +02:00
|
|
|
break;
|
2018-12-31 20:04:05 +01:00
|
|
|
case td_api::updateChatLastMessage::ID: {
|
|
|
|
auto message = static_cast<const td_api::updateChatLastMessage *>(result.get())->last_message_.get();
|
|
|
|
if (message != nullptr && message->content_->get_id() == td_api::messageText::ID) {
|
2018-01-30 18:06:54 +01:00
|
|
|
// auto text = static_cast<const td_api::messageText *>(message->content_.get())->text_->text_;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-02-24 09:24:48 +01:00
|
|
|
case td_api::updateNewMessage::ID: {
|
|
|
|
auto message = static_cast<const td_api::updateNewMessage *>(result.get())->message_.get();
|
|
|
|
if (message != nullptr && message->content_->get_id() == td_api::messageText::ID) {
|
|
|
|
auto chat_id = message->chat_id_;
|
|
|
|
auto text = static_cast<const td_api::messageText *>(message->content_.get())->text_->text_;
|
2021-06-23 12:10:20 +02:00
|
|
|
if (text == "/start" && !message->is_outgoing_ && use_test_dc_) {
|
2021-02-24 09:24:48 +01:00
|
|
|
on_cmd(PSTRING() << "sm " << chat_id << " Hi!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2018-06-01 01:12:36 +02:00
|
|
|
case td_api::file::ID:
|
|
|
|
on_get_file(*static_cast<const td_api::file *>(result.get()));
|
|
|
|
break;
|
|
|
|
case td_api::updateFile::ID:
|
|
|
|
on_get_file(*static_cast<const td_api::updateFile *>(result.get())->file_);
|
|
|
|
break;
|
2018-11-20 10:09:52 +01:00
|
|
|
case td_api::updateConnectionState::ID:
|
2020-04-18 00:55:54 +02:00
|
|
|
LOG(WARNING) << result_str;
|
2018-11-20 10:09:52 +01:00
|
|
|
break;
|
2021-10-19 17:11:16 +02:00
|
|
|
default:
|
|
|
|
break;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
void on_error(uint64 generation, uint64 id, td_api::object_ptr<td_api::error> error) {
|
2021-09-04 11:22:26 +02:00
|
|
|
if (id > 0 && combined_log.get_first_verbosity_level() < get_log_tag_verbosity_level("td_requests")) {
|
2019-02-21 16:58:20 +01:00
|
|
|
LOG(ERROR) << "Receive error [" << generation << "][id=" << id << "] " << to_string(error);
|
2018-08-24 00:02:59 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2018-09-15 14:24:25 +02:00
|
|
|
void on_closed(uint64 generation) {
|
2019-02-21 16:58:20 +01:00
|
|
|
LOG(WARNING) << "Td with generation " << generation << " is closed";
|
2018-09-15 14:24:25 +02:00
|
|
|
closed_td_++;
|
|
|
|
if (closed_td_ == generation_) {
|
|
|
|
LOG(WARNING) << "Ready to stop";
|
|
|
|
ready_to_stop_ = true;
|
|
|
|
if (close_flag_) {
|
|
|
|
yield();
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void quit() {
|
2018-01-24 20:47:59 +01:00
|
|
|
if (close_flag_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
LOG(WARNING) << "QUIT";
|
2018-01-05 15:45:17 +01:00
|
|
|
close_flag_ = true;
|
2018-12-31 20:04:05 +01:00
|
|
|
dump_memory_usage();
|
2018-10-28 18:30:47 +01:00
|
|
|
td_client_.reset();
|
2018-09-11 00:20:41 +02:00
|
|
|
Scheduler::unsubscribe(stdin_.get_poll_info().get_pollable_fd_ref());
|
2018-12-31 20:04:05 +01:00
|
|
|
is_stdin_reader_stopped_ = true;
|
|
|
|
yield();
|
|
|
|
}
|
|
|
|
|
2018-09-10 17:09:08 +02:00
|
|
|
BufferedStdin stdin_;
|
2018-12-31 20:04:05 +01:00
|
|
|
static CliClient *instance_;
|
|
|
|
|
|
|
|
#ifdef USE_READLINE
|
|
|
|
/* Callback function called for each line when accept-line executed, EOF
|
|
|
|
* seen, or EOF character read. This sets a flag and returns; it could
|
|
|
|
* also call exit. */
|
2018-09-10 17:09:08 +02:00
|
|
|
static void static_add_cmd(char *line) {
|
2018-12-31 20:04:05 +01:00
|
|
|
/* Can use ^D (stty eof) to exit. */
|
|
|
|
if (line == nullptr) {
|
2019-02-21 16:58:20 +01:00
|
|
|
LOG(FATAL) << "Closed";
|
2018-12-31 20:04:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (*line) {
|
|
|
|
add_history(line);
|
|
|
|
}
|
|
|
|
instance_->add_cmd(line);
|
|
|
|
rl_free(line);
|
|
|
|
}
|
2018-09-10 17:09:08 +02:00
|
|
|
static int static_getc(FILE *) {
|
|
|
|
return instance_->stdin_getc();
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
#endif
|
|
|
|
|
2018-09-15 14:24:25 +02:00
|
|
|
uint64 generation_ = 0;
|
|
|
|
uint64 closed_td_ = 0;
|
|
|
|
void create_td(Slice name) {
|
|
|
|
if (ready_to_stop_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-03 19:11:34 +01:00
|
|
|
LOG(WARNING) << "Creating new Td " << name << " with generation " << generation_ + 1;
|
2021-07-04 04:58:54 +02:00
|
|
|
class TdCallbackImpl final : public TdCallback {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2018-09-15 14:24:25 +02:00
|
|
|
TdCallbackImpl(CliClient *client, uint64 generation) : client_(client), generation_(generation) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_result(uint64 id, td_api::object_ptr<td_api::Object> result) final {
|
2018-09-15 14:24:25 +02:00
|
|
|
client_->on_result(generation_, id, std::move(result));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-07-03 22:51:36 +02:00
|
|
|
void on_error(uint64 id, td_api::object_ptr<td_api::error> error) final {
|
2018-09-15 14:24:25 +02:00
|
|
|
client_->on_error(generation_, id, std::move(error));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-09-15 18:33:27 +02:00
|
|
|
TdCallbackImpl(const TdCallbackImpl &) = delete;
|
|
|
|
TdCallbackImpl &operator=(const TdCallbackImpl &) = delete;
|
|
|
|
TdCallbackImpl(TdCallbackImpl &&) = delete;
|
|
|
|
TdCallbackImpl &operator=(TdCallbackImpl &&) = delete;
|
2021-07-03 22:51:36 +02:00
|
|
|
~TdCallbackImpl() final {
|
2018-09-15 14:24:25 +02:00
|
|
|
client_->on_closed(generation_);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
CliClient *client_;
|
2018-09-15 14:24:25 +02:00
|
|
|
uint64 generation_;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
2018-09-15 14:24:25 +02:00
|
|
|
|
2020-07-30 16:28:56 +02:00
|
|
|
ClientActor::Options options;
|
|
|
|
options.net_query_stats = net_query_stats_;
|
|
|
|
|
|
|
|
td_client_ = create_actor<ClientActor>(name, make_unique<TdCallbackImpl>(this, ++generation_), std::move(options));
|
2020-10-04 00:30:59 +02:00
|
|
|
|
|
|
|
if (get_chat_list_) {
|
2021-08-11 14:59:09 +02:00
|
|
|
send_request(td_api::make_object<td_api::getChats>(nullptr, 10000));
|
2020-10-04 00:30:59 +02:00
|
|
|
}
|
|
|
|
if (disable_network_) {
|
|
|
|
send_request(td_api::make_object<td_api::setNetworkType>(td_api::make_object<td_api::networkTypeNone>()));
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void init_td() {
|
|
|
|
close_flag_ = false;
|
|
|
|
ready_to_stop_ = false;
|
2018-09-15 14:24:25 +02:00
|
|
|
generation_ = 0;
|
|
|
|
closed_td_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-09-15 14:24:25 +02:00
|
|
|
create_td("ClientActor1");
|
2018-05-22 13:09:58 +02:00
|
|
|
|
2018-09-15 14:24:25 +02:00
|
|
|
bool test_init = false;
|
2018-05-22 13:09:58 +02:00
|
|
|
if (test_init) {
|
2018-09-15 14:24:25 +02:00
|
|
|
create_td("ClientActor2");
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-05-22 13:09:58 +02:00
|
|
|
for (int i = 0; i < 4; i++) {
|
2018-10-28 18:30:47 +01:00
|
|
|
send_closure_later(td_client_, &ClientActor::request, std::numeric_limits<uint64>::max(),
|
2018-05-22 13:09:58 +02:00
|
|
|
td_api::make_object<td_api::setAlarm>(0.001 + 1000 * (i / 2)));
|
|
|
|
}
|
2018-05-15 22:04:27 +02:00
|
|
|
|
2018-09-17 19:48:05 +02:00
|
|
|
send_request(td_api::make_object<td_api::getStorageStatistics>(10));
|
|
|
|
send_request(td_api::make_object<td_api::getStorageStatisticsFast>());
|
|
|
|
|
2018-05-22 13:09:58 +02:00
|
|
|
send_request(td_api::make_object<td_api::getTextEntities>(
|
|
|
|
"@telegram /test_command https://telegram.org telegram.me @gif @test"));
|
2018-05-15 22:04:27 +02:00
|
|
|
|
2022-08-18 13:54:57 +02:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setOption>("xxx", td_api::make_object<td_api::optionValueBoolean>(true)));
|
|
|
|
send_request(td_api::make_object<td_api::setOption>("xxx", td_api::make_object<td_api::optionValueInteger>(1)));
|
|
|
|
send_request(td_api::make_object<td_api::setOption>("xxx", td_api::make_object<td_api::optionValueString>("2")));
|
|
|
|
send_request(td_api::make_object<td_api::setOption>("xxx", td_api::make_object<td_api::optionValueEmpty>()));
|
|
|
|
|
2018-05-22 13:09:58 +02:00
|
|
|
send_request(td_api::make_object<td_api::getOption>("use_pfs"));
|
|
|
|
send_request(td_api::make_object<td_api::setOption>(
|
|
|
|
"use_pfs", td_api::make_object<td_api::optionValueBoolean>(std::time(nullptr) / 86400 % 2 == 0)));
|
2019-01-17 21:12:31 +01:00
|
|
|
send_request(td_api::make_object<td_api::setOption>("notification_group_count_max",
|
|
|
|
td_api::make_object<td_api::optionValueInteger>(1)));
|
2018-05-22 13:09:58 +02:00
|
|
|
send_request(td_api::make_object<td_api::setOption>("use_storage_optimizer",
|
|
|
|
td_api::make_object<td_api::optionValueBoolean>(false)));
|
2019-02-14 16:25:31 +01:00
|
|
|
send_request(td_api::make_object<td_api::setOption>(
|
|
|
|
"use_pfs", td_api::make_object<td_api::optionValueBoolean>(std::time(nullptr) / 86400 % 2 == 0)));
|
2019-04-20 23:07:02 +02:00
|
|
|
send_request(td_api::make_object<td_api::setOption>("disable_contact_registered_notifications",
|
|
|
|
td_api::make_object<td_api::optionValueBoolean>(true)));
|
2018-05-16 21:35:27 +02:00
|
|
|
|
2018-05-22 13:09:58 +02:00
|
|
|
send_request(td_api::make_object<td_api::setNetworkType>(td_api::make_object<td_api::networkTypeWiFi>()));
|
|
|
|
send_request(td_api::make_object<td_api::getNetworkStatistics>());
|
|
|
|
send_request(td_api::make_object<td_api::getCountryCode>());
|
2019-01-17 21:12:31 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::addProxy>("1.1.1.1", 1111, true, td_api::make_object<td_api::proxyTypeSocks5>()));
|
|
|
|
send_request(td_api::make_object<td_api::addProxy>("1.1.1.1", 1112, false,
|
|
|
|
td_api::make_object<td_api::proxyTypeSocks5>()));
|
|
|
|
send_request(td_api::make_object<td_api::pingProxy>(0));
|
2018-05-16 21:35:27 +02:00
|
|
|
|
2022-09-07 21:19:08 +02:00
|
|
|
auto bad_request = td_api::make_object<td_api::setTdlibParameters>();
|
|
|
|
bad_request->database_directory_ = "/..";
|
|
|
|
bad_request->api_id_ = api_id_;
|
|
|
|
bad_request->api_hash_ = api_hash_;
|
|
|
|
send_request(std::move(bad_request));
|
2018-05-22 13:09:58 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void init() {
|
|
|
|
instance_ = this;
|
|
|
|
|
|
|
|
init_td();
|
|
|
|
|
|
|
|
#ifdef USE_READLINE
|
|
|
|
deactivate_readline();
|
2018-09-10 17:09:08 +02:00
|
|
|
rl_getc_function = static_getc;
|
|
|
|
rl_callback_handler_install(prompt, static_add_cmd);
|
2018-12-31 20:04:05 +01:00
|
|
|
rl_attempted_completion_function = tg_cli_completion;
|
|
|
|
reactivate_readline();
|
|
|
|
#endif
|
2018-09-11 00:20:41 +02:00
|
|
|
Scheduler::subscribe(stdin_.get_poll_info().extract_pollable_fd(this), PollFlags::Read());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
#ifndef USE_READLINE
|
|
|
|
size_t buffer_pos_ = 0;
|
|
|
|
Result<BufferSlice> process_stdin(ChainBufferReader *buffer) {
|
|
|
|
auto found = find_boundary(buffer->clone(), "\n", buffer_pos_);
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
return Status::Error("End of line not found");
|
|
|
|
}
|
|
|
|
|
|
|
|
auto data = buffer->cut_head(buffer_pos_).move_as_buffer_slice();
|
|
|
|
if (!data.empty() && data[data.size() - 1] == '\r') {
|
|
|
|
data.truncate(data.size() - 1);
|
|
|
|
}
|
2018-10-26 16:11:20 +02:00
|
|
|
buffer->advance(1);
|
2018-12-31 20:04:05 +01:00
|
|
|
buffer_pos_ = 0;
|
|
|
|
return std::move(data);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::formattedText> as_formatted_text(
|
2021-10-19 17:11:16 +02:00
|
|
|
const string &text, vector<td_api::object_ptr<td_api::textEntity>> entities = {}) {
|
2019-02-08 15:54:23 +01:00
|
|
|
if (entities.empty() && !text.empty()) {
|
2019-02-21 17:48:05 +01:00
|
|
|
auto parsed_text = execute(
|
2019-12-30 22:58:11 +01:00
|
|
|
td_api::make_object<td_api::parseTextEntities>(text, td_api::make_object<td_api::textParseModeMarkdown>(2)));
|
2018-06-19 01:31:34 +02:00
|
|
|
if (parsed_text->get_id() == td_api::formattedText::ID) {
|
|
|
|
return td_api::move_object_as<td_api::formattedText>(parsed_text);
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::formattedText>(text, std::move(entities));
|
2018-06-19 01:31:34 +02:00
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::formattedText> as_caption(
|
2021-10-19 17:11:16 +02:00
|
|
|
const string &caption, vector<td_api::object_ptr<td_api::textEntity>> entities = {}) {
|
2018-06-19 01:31:34 +02:00
|
|
|
return as_formatted_text(caption, std::move(entities));
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::NotificationSettingsScope> as_notification_settings_scope(Slice scope) {
|
2019-02-14 19:44:20 +01:00
|
|
|
if (scope.empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-01-29 12:40:56 +01:00
|
|
|
if (scope == "channels" || scope == "ch") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::notificationSettingsScopeChannelChats>();
|
2019-01-29 12:40:56 +01:00
|
|
|
}
|
|
|
|
if (scope == "chats" || scope == "groups" || as_bool(scope.str())) {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::notificationSettingsScopeGroupChats>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::notificationSettingsScopePrivateChats>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::UserPrivacySetting> as_user_privacy_setting(MutableSlice setting) {
|
2018-12-31 20:04:05 +01:00
|
|
|
setting = trim(setting);
|
|
|
|
to_lower_inplace(setting);
|
|
|
|
if (setting == "invite") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::userPrivacySettingAllowChatInvites>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (setting == "status") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::userPrivacySettingShowStatus>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (setting == "call") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::userPrivacySettingAllowCalls>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-02-07 19:53:54 +01:00
|
|
|
if (setting == "p2p") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::userPrivacySettingAllowPeerToPeerCalls>();
|
2019-02-07 19:53:54 +01:00
|
|
|
}
|
2019-05-14 02:18:34 +02:00
|
|
|
if (setting == "forward") {
|
|
|
|
return td_api::make_object<td_api::userPrivacySettingShowLinkInForwardedMessages>();
|
|
|
|
}
|
|
|
|
if (setting == "photo") {
|
|
|
|
return td_api::make_object<td_api::userPrivacySettingShowProfilePhoto>();
|
|
|
|
}
|
2019-09-03 20:16:10 +02:00
|
|
|
if (setting == "phone_number") {
|
|
|
|
return td_api::make_object<td_api::userPrivacySettingShowPhoneNumber>();
|
|
|
|
}
|
2023-05-04 16:03:37 +02:00
|
|
|
if (setting == "bio") {
|
|
|
|
return td_api::make_object<td_api::userPrivacySettingShowBio>();
|
|
|
|
}
|
2019-11-22 11:41:17 +01:00
|
|
|
if (setting == "find") {
|
|
|
|
return td_api::make_object<td_api::userPrivacySettingAllowFindingByPhoneNumber>();
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-12-26 19:12:09 +01:00
|
|
|
static td_api::object_ptr<td_api::SearchMessagesFilter> as_search_messages_filter(Slice filter) {
|
2018-12-31 20:04:05 +01:00
|
|
|
filter = trim(filter);
|
2020-12-26 19:12:09 +01:00
|
|
|
string lowered_filter = to_lower(filter);
|
|
|
|
filter = lowered_filter;
|
|
|
|
if (begins_with(filter, "search")) {
|
|
|
|
filter.remove_prefix(6);
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
if (filter == "an" || filter == "animation") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterAnimation>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "au" || filter == "audio") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterAudio>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "d" || filter == "document") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterDocument>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "p" || filter == "photo") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterPhoto>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "vi" || filter == "video") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterVideo>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "vo" || filter == "voice") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterVoiceNote>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-07-19 15:58:09 +02:00
|
|
|
if (filter == "pvi") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterPhotoAndVideo>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "u" || filter == "url") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterUrl>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "cp" || filter == "chatphoto") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterChatPhoto>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "vn" || filter == "videonote") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterVideoNote>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "vvn" || filter == "voicevideonote") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterVoiceAndVideoNote>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "m" || filter == "mention") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterMention>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (filter == "um" || filter == "umention") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::searchMessagesFilterUnreadMention>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2022-01-28 17:12:33 +01:00
|
|
|
if (filter == "ur" || filter == "ureaction") {
|
|
|
|
return td_api::make_object<td_api::searchMessagesFilterUnreadReaction>();
|
|
|
|
}
|
2020-05-01 23:50:51 +02:00
|
|
|
if (filter == "f" || filter == "failed") {
|
|
|
|
return td_api::make_object<td_api::searchMessagesFilterFailedToSend>();
|
|
|
|
}
|
2020-10-23 12:42:08 +02:00
|
|
|
if (filter == "pi" || filter == "pinned") {
|
|
|
|
return td_api::make_object<td_api::searchMessagesFilterPinned>();
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
if (!filter.empty()) {
|
|
|
|
LOG(ERROR) << "Unsupported message filter " << filter;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::ChatMembersFilter> as_chat_members_filter(MutableSlice filter) {
|
2018-07-20 02:00:17 +02:00
|
|
|
filter = trim(filter);
|
|
|
|
to_lower_inplace(filter);
|
|
|
|
if (filter == "a" || filter == "admin" || filter == "administrators") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatMembersFilterAdministrators>();
|
2018-07-20 02:00:17 +02:00
|
|
|
}
|
|
|
|
if (filter == "b" || filter == "banned") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatMembersFilterBanned>();
|
2018-07-20 02:00:17 +02:00
|
|
|
}
|
|
|
|
if (filter == "bot" || filter == "bots") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatMembersFilterBots>();
|
2018-07-20 02:00:17 +02:00
|
|
|
}
|
2019-05-12 20:49:21 +02:00
|
|
|
if (filter == "c" || filter == "contacts") {
|
|
|
|
return td_api::make_object<td_api::chatMembersFilterContacts>();
|
|
|
|
}
|
2018-07-20 02:00:17 +02:00
|
|
|
if (filter == "m" || filter == "members") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatMembersFilterMembers>();
|
2018-07-20 02:00:17 +02:00
|
|
|
}
|
2020-10-19 13:06:35 +02:00
|
|
|
if (begins_with(filter, "@")) {
|
|
|
|
return td_api::make_object<td_api::chatMembersFilterMention>(as_message_thread_id(filter.substr(1)));
|
|
|
|
}
|
2018-07-20 02:00:17 +02:00
|
|
|
if (filter == "r" || filter == "rest" || filter == "restricted") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatMembersFilterRestricted>();
|
2018-07-20 02:00:17 +02:00
|
|
|
}
|
|
|
|
if (!filter.empty()) {
|
|
|
|
LOG(ERROR) << "Unsupported chat member filter " << filter;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::SupergroupMembersFilter> as_supergroup_members_filter(MutableSlice filter,
|
|
|
|
const string &query,
|
|
|
|
Slice message_thread_id) {
|
2020-12-26 19:45:19 +01:00
|
|
|
filter = trim(filter);
|
|
|
|
to_lower_inplace(filter);
|
|
|
|
if (begins_with(filter, "get")) {
|
|
|
|
filter.remove_prefix(3);
|
|
|
|
}
|
|
|
|
if (begins_with(filter, "search")) {
|
|
|
|
filter.remove_prefix(6);
|
|
|
|
}
|
|
|
|
if (begins_with(filter, "supergroup")) {
|
|
|
|
filter.remove_prefix(10);
|
|
|
|
}
|
|
|
|
if (filter == "administrators") {
|
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterAdministrators>();
|
|
|
|
}
|
|
|
|
if (filter == "banned") {
|
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterBanned>(query);
|
|
|
|
}
|
|
|
|
if (filter == "bots") {
|
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterBots>();
|
|
|
|
}
|
|
|
|
if (filter == "contacts") {
|
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterContacts>(query);
|
|
|
|
}
|
|
|
|
if (filter == "members") {
|
|
|
|
if (query.empty()) {
|
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterRecent>();
|
|
|
|
} else {
|
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterSearch>(query);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filter == "restricted") {
|
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterRestricted>(query);
|
|
|
|
}
|
2022-10-26 12:57:16 +02:00
|
|
|
if (filter == "mentions") {
|
2020-12-26 19:45:19 +01:00
|
|
|
return td_api::make_object<td_api::supergroupMembersFilterMention>(query,
|
|
|
|
as_message_thread_id(message_thread_id));
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2020-12-26 19:01:57 +01:00
|
|
|
static bool rand_bool() {
|
|
|
|
return Random::fast_bool();
|
|
|
|
}
|
|
|
|
|
2023-04-03 16:28:51 +02:00
|
|
|
td_api::object_ptr<td_api::chatFolder> as_chat_folder(string filter, bool is_shareable = false) const {
|
2020-05-18 21:26:44 +02:00
|
|
|
string title;
|
2020-06-01 15:55:31 +02:00
|
|
|
string icon_name;
|
2020-05-18 21:26:44 +02:00
|
|
|
string pinned_chat_ids;
|
|
|
|
string included_chat_ids;
|
|
|
|
string excluded_chat_ids;
|
2020-12-26 18:58:30 +01:00
|
|
|
get_args(filter, title, icon_name, pinned_chat_ids, included_chat_ids, excluded_chat_ids);
|
2023-04-03 16:28:51 +02:00
|
|
|
return td_api::make_object<td_api::chatFolder>(
|
|
|
|
title, td_api::make_object<td_api::chatFolderIcon>(icon_name), is_shareable, as_chat_ids(pinned_chat_ids),
|
2023-03-31 12:34:47 +02:00
|
|
|
as_chat_ids(included_chat_ids), as_chat_ids(excluded_chat_ids), rand_bool(), rand_bool(), rand_bool(),
|
|
|
|
rand_bool(), rand_bool(), rand_bool(), rand_bool(), rand_bool());
|
2020-05-18 21:26:44 +02:00
|
|
|
}
|
|
|
|
|
2022-03-22 11:17:48 +01:00
|
|
|
static td_api::object_ptr<td_api::chatAdministratorRights> as_chat_administrator_rights(
|
|
|
|
bool can_manage_chat, bool can_change_info, bool can_post_messages, bool can_edit_messages,
|
|
|
|
bool can_delete_messages, bool can_invite_users, bool can_restrict_members, bool can_pin_messages,
|
2022-10-23 12:20:53 +02:00
|
|
|
bool can_manage_topics, bool can_promote_members, bool can_manage_video_chats, bool is_anonymous) {
|
2022-03-22 11:17:48 +01:00
|
|
|
return td_api::make_object<td_api::chatAdministratorRights>(
|
|
|
|
can_manage_chat, can_change_info, can_post_messages, can_edit_messages, can_delete_messages, can_invite_users,
|
2022-10-23 12:20:53 +02:00
|
|
|
can_restrict_members, can_pin_messages, can_manage_topics, can_promote_members, can_manage_video_chats,
|
|
|
|
is_anonymous);
|
2022-03-22 11:17:48 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::TopChatCategory> as_top_chat_category(MutableSlice category) {
|
2018-12-31 20:04:05 +01:00
|
|
|
category = trim(category);
|
|
|
|
to_lower_inplace(category);
|
|
|
|
if (!category.empty() && category.back() == 's') {
|
|
|
|
category.remove_suffix(1);
|
|
|
|
}
|
|
|
|
if (category == "bot") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::topChatCategoryBots>();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (category == "group") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::topChatCategoryGroups>();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (category == "channel") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::topChatCategoryChannels>();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (category == "inline") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::topChatCategoryInlineBots>();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (category == "call") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::topChatCategoryCalls>();
|
2019-09-03 20:16:10 +02:00
|
|
|
} else if (category == "forward") {
|
|
|
|
return td_api::make_object<td_api::topChatCategoryForwardChats>();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::topChatCategoryUsers>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::ChatAction> as_chat_action(MutableSlice action) {
|
2018-12-31 20:04:05 +01:00
|
|
|
action = trim(action);
|
|
|
|
to_lower_inplace(action);
|
|
|
|
if (action == "c" || action == "cancel") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionCancel>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "rvi" || action == "record_video") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionRecordingVideo>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "uvi" || action == "upload_video") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionUploadingVideo>(50);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "rvo" || action == "record_voice") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionRecordingVoiceNote>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "uvo" || action == "upload_voice") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionUploadingVoiceNote>(50);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "up" || action == "upload_photo") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionUploadingPhoto>(50);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "ud" || action == "upload_document") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionUploadingDocument>(50);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "fl" || action == "find_location") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionChoosingLocation>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "cc" || action == "choose_contact") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionChoosingContact>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "spg" || action == "start_play_game") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionStartPlayingGame>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "rvn" || action == "record_video_note") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionRecordingVideoNote>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (action == "uvn" || action == "upload_video_note") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionUploadingVideoNote>(50);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2021-08-19 21:43:38 +02:00
|
|
|
if (action == "cs" || action == "choose_sticker") {
|
|
|
|
return td_api::make_object<td_api::chatActionChoosingSticker>();
|
|
|
|
}
|
2021-09-19 20:40:07 +02:00
|
|
|
if (begins_with(action, "wa")) {
|
|
|
|
return td_api::make_object<td_api::chatActionWatchingAnimations>(action.substr(2).str());
|
2021-09-15 16:11:44 +02:00
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::chatActionTyping>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2023-08-01 19:44:24 +02:00
|
|
|
static td_api::object_ptr<td_api::ReportReason> as_report_reason(string reason) {
|
2020-12-26 19:53:39 +01:00
|
|
|
reason = trim(reason);
|
2021-02-20 01:55:09 +01:00
|
|
|
if (reason == "null") {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-12-26 19:53:39 +01:00
|
|
|
if (reason == "spam") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonSpam>();
|
2020-12-26 19:53:39 +01:00
|
|
|
}
|
|
|
|
if (reason == "violence") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonViolence>();
|
2020-12-26 19:53:39 +01:00
|
|
|
}
|
|
|
|
if (reason == "porno") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonPornography>();
|
2020-12-26 19:53:39 +01:00
|
|
|
}
|
|
|
|
if (reason == "ca") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonChildAbuse>();
|
2020-12-26 19:53:39 +01:00
|
|
|
}
|
|
|
|
if (reason == "copyright") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonCopyright>();
|
2020-12-26 19:53:39 +01:00
|
|
|
}
|
|
|
|
if (reason == "geo" || reason == "location") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonUnrelatedLocation>();
|
2020-12-26 19:53:39 +01:00
|
|
|
}
|
2021-01-21 22:55:42 +01:00
|
|
|
if (reason == "fake") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonFake>();
|
2021-01-21 22:55:42 +01:00
|
|
|
}
|
2022-02-18 14:12:39 +01:00
|
|
|
if (reason == "drugs") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonIllegalDrugs>();
|
2022-02-18 14:12:39 +01:00
|
|
|
}
|
|
|
|
if (reason == "pd") {
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonPersonalDetails>();
|
2022-02-18 14:12:39 +01:00
|
|
|
}
|
2023-06-22 12:47:52 +02:00
|
|
|
return td_api::make_object<td_api::reportReasonCustom>();
|
2020-12-26 19:53:39 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::NetworkType> as_network_type(MutableSlice type) {
|
2018-12-31 20:04:05 +01:00
|
|
|
type = trim(type);
|
|
|
|
to_lower_inplace(type);
|
|
|
|
if (type == "none") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::networkTypeNone>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (type == "mobile") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::networkTypeMobile>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (type == "roaming") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::networkTypeMobileRoaming>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (type == "wifi") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::networkTypeWiFi>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (type == "other") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::networkTypeOther>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2021-02-22 16:06:18 +01:00
|
|
|
td_api::object_ptr<td_api::SuggestedAction> as_suggested_action(Slice action) const {
|
2020-07-12 14:04:49 +02:00
|
|
|
if (action == "unarchive") {
|
|
|
|
return td_api::make_object<td_api::suggestedActionEnableArchiveAndMuteNewChats>();
|
|
|
|
}
|
2021-06-11 01:48:10 +02:00
|
|
|
if (action == "pass") {
|
|
|
|
return td_api::make_object<td_api::suggestedActionCheckPassword>();
|
|
|
|
}
|
2020-07-12 14:04:49 +02:00
|
|
|
if (action == "number") {
|
|
|
|
return td_api::make_object<td_api::suggestedActionCheckPhoneNumber>();
|
|
|
|
}
|
2021-12-23 18:00:41 +01:00
|
|
|
if (action == "checks") {
|
|
|
|
return td_api::make_object<td_api::suggestedActionViewChecksHint>();
|
2021-01-14 23:30:05 +01:00
|
|
|
}
|
2021-02-22 16:06:18 +01:00
|
|
|
if (begins_with(action, "giga")) {
|
|
|
|
return td_api::make_object<td_api::suggestedActionConvertToBroadcastGroup>(as_supergroup_id(action.substr(4)));
|
|
|
|
}
|
2021-11-26 14:22:39 +01:00
|
|
|
if (begins_with(action, "spass")) {
|
|
|
|
return td_api::make_object<td_api::suggestedActionSetPassword>(to_integer<int32>(action.substr(5)));
|
|
|
|
}
|
2020-07-12 14:04:49 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-09-07 14:18:43 +02:00
|
|
|
static td_api::object_ptr<td_api::EmailAddressAuthentication> as_email_address_authentication(Slice arg) {
|
|
|
|
if (begins_with(arg, "a ")) {
|
|
|
|
return td_api::make_object<td_api::emailAddressAuthenticationAppleId>(arg.substr(2).str());
|
|
|
|
} else if (begins_with(arg, "g ")) {
|
|
|
|
return td_api::make_object<td_api::emailAddressAuthenticationGoogleId>(arg.substr(2).str());
|
|
|
|
} else if (!arg.empty()) {
|
|
|
|
return td_api::make_object<td_api::emailAddressAuthenticationCode>(arg.str());
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::PassportElementType> as_passport_element_type(Slice passport_element_type) {
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "address" || passport_element_type == "a") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypeAddress>();
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "email" || passport_element_type == "e") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypeEmailAddress>();
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "phone" || passport_element_type == "p") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypePhoneNumber>();
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "pd") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypePersonalDetails>();
|
2018-04-06 15:24:29 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "dl") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypeDriverLicense>();
|
2018-04-23 22:33:51 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "ip") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypeInternalPassport>();
|
2018-04-27 14:38:02 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "ic") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypeIdentityCard>();
|
2018-04-23 22:33:51 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "ra") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypeRentalAgreement>();
|
2018-04-23 22:33:51 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "pr") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypePassportRegistration>();
|
2018-04-27 14:38:02 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "tr") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypeTemporaryRegistration>();
|
2018-04-27 14:38:02 +02:00
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::passportElementTypePassport>();
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2018-04-06 15:24:29 +02:00
|
|
|
|
2019-12-18 16:09:32 +01:00
|
|
|
static auto as_passport_element_types(Slice types) {
|
2022-01-24 15:40:16 +01:00
|
|
|
return transform(autosplit(types), as_passport_element_type);
|
2018-04-06 21:37:30 +02:00
|
|
|
}
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static td_api::object_ptr<td_api::InputPassportElement> as_input_passport_element(const string &passport_element_type,
|
|
|
|
const string &arg,
|
|
|
|
bool with_selfie) {
|
2018-04-23 22:33:51 +02:00
|
|
|
vector<td_api::object_ptr<td_api::InputFile>> input_files;
|
|
|
|
td_api::object_ptr<td_api::InputFile> selfie;
|
2018-04-11 16:21:24 +02:00
|
|
|
if (!arg.empty()) {
|
2022-01-24 15:40:16 +01:00
|
|
|
auto files = autosplit(arg);
|
2018-04-23 22:33:51 +02:00
|
|
|
CHECK(!files.empty());
|
|
|
|
if (with_selfie) {
|
|
|
|
selfie = as_input_file(files.back());
|
|
|
|
files.pop_back();
|
|
|
|
}
|
2021-10-19 17:11:16 +02:00
|
|
|
for (const auto &file : files) {
|
2018-04-23 22:33:51 +02:00
|
|
|
input_files.push_back(as_input_file(file));
|
|
|
|
}
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
if (passport_element_type == "address" || passport_element_type == "a") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementAddress>(
|
|
|
|
td_api::make_object<td_api::address>("US", "CA", "Los Angeles", "Washington", "", "90001"));
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (passport_element_type == "email" || passport_element_type == "e") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementEmailAddress>(arg);
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (passport_element_type == "phone" || passport_element_type == "p") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementPhoneNumber>(arg);
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (passport_element_type == "pd") {
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementPersonalDetails>(
|
|
|
|
td_api::make_object<td_api::personalDetails>("Mike", "Jr", "Towers", u8"Mike\u2708", u8"Jr\u26fd",
|
|
|
|
u8"Towers\u2757", td_api::make_object<td_api::date>(29, 2, 2000),
|
|
|
|
"male", "US", "GB"));
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (passport_element_type == "driver_license" || passport_element_type == "dl") {
|
2018-08-10 18:39:48 +02:00
|
|
|
if (input_files.size() >= 2) {
|
|
|
|
auto front_side = std::move(input_files[0]);
|
|
|
|
input_files.erase(input_files.begin());
|
|
|
|
auto reverse_side = std::move(input_files[0]);
|
|
|
|
input_files.erase(input_files.begin());
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementDriverLicense>(
|
|
|
|
td_api::make_object<td_api::inputIdentityDocument>(
|
|
|
|
"1234567890", td_api::make_object<td_api::date>(1, 3, 2029), std::move(front_side),
|
|
|
|
std::move(reverse_side), std::move(selfie), std::move(input_files)));
|
2018-04-27 14:38:02 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (passport_element_type == "identity_card" || passport_element_type == "ic") {
|
2018-08-10 18:39:48 +02:00
|
|
|
if (input_files.size() >= 2) {
|
|
|
|
auto front_side = std::move(input_files[0]);
|
|
|
|
input_files.erase(input_files.begin());
|
|
|
|
auto reverse_side = std::move(input_files[0]);
|
|
|
|
input_files.erase(input_files.begin());
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementIdentityCard>(
|
|
|
|
td_api::make_object<td_api::inputIdentityDocument>("1234567890", nullptr, std::move(front_side),
|
|
|
|
std::move(reverse_side), std::move(selfie),
|
|
|
|
std::move(input_files)));
|
2018-04-27 14:38:02 +02:00
|
|
|
}
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (passport_element_type == "internal_passport" || passport_element_type == "ip") {
|
2021-10-19 17:11:16 +02:00
|
|
|
if (!input_files.empty()) {
|
2018-08-10 18:39:48 +02:00
|
|
|
auto front_side = std::move(input_files[0]);
|
|
|
|
input_files.erase(input_files.begin());
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementInternalPassport>(
|
|
|
|
td_api::make_object<td_api::inputIdentityDocument>("1234567890", nullptr, std::move(front_side), nullptr,
|
|
|
|
std::move(selfie), std::move(input_files)));
|
2018-04-27 14:38:02 +02:00
|
|
|
}
|
2018-08-14 15:17:47 +02:00
|
|
|
} else if (passport_element_type == "rental_agreement" || passport_element_type == "ra") {
|
|
|
|
vector<td_api::object_ptr<td_api::InputFile>> translation;
|
|
|
|
if (selfie != nullptr) {
|
|
|
|
translation.push_back(std::move(selfie));
|
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
return td_api::make_object<td_api::inputPassportElementRentalAgreement>(
|
|
|
|
td_api::make_object<td_api::inputPersonalDocument>(std::move(input_files), std::move(translation)));
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
2018-04-11 16:21:24 +02:00
|
|
|
|
2018-08-01 15:52:07 +02:00
|
|
|
LOG(ERROR) << "Unsupported passport element type " << passport_element_type;
|
2018-04-11 16:21:24 +02:00
|
|
|
return nullptr;
|
2018-03-27 15:11:15 +02:00
|
|
|
}
|
|
|
|
|
2019-02-11 18:57:35 +01:00
|
|
|
static td_api::object_ptr<td_api::languagePackInfo> as_language_pack_info(const string &language_code,
|
|
|
|
const string &name,
|
|
|
|
const string &native_name) {
|
|
|
|
return td_api::make_object<td_api::languagePackInfo>(language_code, "test", name, native_name, "en", true, true,
|
2019-02-23 16:29:04 +01:00
|
|
|
true, true, -1, 5, 3, "abacaba");
|
2019-02-11 18:57:35 +01:00
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::MessageSchedulingState> as_message_scheduling_state(Slice date) {
|
|
|
|
date = trim(date);
|
2019-12-06 02:43:21 +01:00
|
|
|
if (date.empty()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-12-03 02:36:23 +01:00
|
|
|
auto send_date = to_integer<int32>(date);
|
|
|
|
if (send_date == -1) {
|
|
|
|
return td_api::make_object<td_api::messageSchedulingStateSendWhenOnline>();
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::messageSchedulingStateSendAtDate>(send_date);
|
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::themeParameters> as_theme_parameters() {
|
2022-06-20 15:15:09 +02:00
|
|
|
return td_api::make_object<td_api::themeParameters>(0, 1, -1, 256, 65536, 123456789, 65535);
|
2022-03-29 19:22:38 +02:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundFill> as_background_fill(int32 color) {
|
2019-12-22 21:02:36 +01:00
|
|
|
return td_api::make_object<td_api::backgroundFillSolid>(color);
|
2019-12-22 18:11:54 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundFill> as_background_fill(int32 top_color, int32 bottom_color) {
|
2019-12-22 21:02:36 +01:00
|
|
|
return td_api::make_object<td_api::backgroundFillGradient>(top_color, bottom_color, Random::fast(0, 7) * 45);
|
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundFill> as_background_fill(vector<int32> colors) {
|
2021-05-21 00:49:59 +02:00
|
|
|
return td_api::make_object<td_api::backgroundFillFreeformGradient>(std::move(colors));
|
|
|
|
}
|
|
|
|
|
2023-04-10 18:45:15 +02:00
|
|
|
static td_api::object_ptr<td_api::backgroundTypeWallpaper> as_wallpaper_background(bool is_blurred, bool is_moving) {
|
|
|
|
return td_api::make_object<td_api::backgroundTypeWallpaper>(is_blurred, is_moving);
|
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundType> as_solid_pattern_background(int32 color, int32 intensity,
|
|
|
|
bool is_moving) {
|
|
|
|
return as_gradient_pattern_background(color, color, intensity, false, is_moving);
|
2019-12-22 21:02:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundType> as_gradient_pattern_background(int32 top_color, int32 bottom_color,
|
|
|
|
int32 intensity, bool is_inverted,
|
|
|
|
bool is_moving) {
|
|
|
|
return td_api::make_object<td_api::backgroundTypePattern>(as_background_fill(top_color, bottom_color), intensity,
|
2021-09-14 11:53:59 +02:00
|
|
|
is_inverted, is_moving);
|
2019-12-22 21:02:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundType> as_freeform_gradient_pattern_background(vector<int32> colors,
|
|
|
|
int32 intensity,
|
|
|
|
bool is_inverted,
|
|
|
|
bool is_moving) {
|
|
|
|
return td_api::make_object<td_api::backgroundTypePattern>(as_background_fill(std::move(colors)), intensity,
|
2021-09-14 11:53:59 +02:00
|
|
|
is_inverted, is_moving);
|
2021-05-21 00:49:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundType> as_solid_background(int32 color) {
|
|
|
|
return td_api::make_object<td_api::backgroundTypeFill>(as_background_fill(color));
|
2019-12-22 21:02:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundType> as_gradient_background(int32 top_color, int32 bottom_color) {
|
|
|
|
return td_api::make_object<td_api::backgroundTypeFill>(as_background_fill(top_color, bottom_color));
|
2019-12-22 01:17:52 +01:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
static td_api::object_ptr<td_api::BackgroundType> as_freeform_gradient_background(vector<int32> colors) {
|
|
|
|
return td_api::make_object<td_api::backgroundTypeFill>(as_background_fill(std::move(colors)));
|
2021-05-21 00:49:59 +02:00
|
|
|
}
|
|
|
|
|
2022-10-12 14:03:47 +02:00
|
|
|
td_api::object_ptr<td_api::phoneNumberAuthenticationSettings> as_phone_number_authentication_settings() const {
|
2023-01-19 13:36:23 +01:00
|
|
|
return td_api::make_object<td_api::phoneNumberAuthenticationSettings>(false, true, false, false, nullptr,
|
2021-11-24 15:01:02 +01:00
|
|
|
vector<string>(authentication_tokens_));
|
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
static td_api::object_ptr<td_api::Object> execute(td_api::object_ptr<td_api::Function> f) {
|
2021-09-04 11:22:26 +02:00
|
|
|
if (combined_log.get_first_verbosity_level() < get_log_tag_verbosity_level("td_requests")) {
|
2018-10-24 17:42:40 +02:00
|
|
|
LOG(ERROR) << "Execute request: " << to_string(f);
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
auto res = ClientActor::execute(std::move(f));
|
2021-09-04 11:22:26 +02:00
|
|
|
if (combined_log.get_first_verbosity_level() < get_log_tag_verbosity_level("td_requests")) {
|
2018-10-24 17:42:40 +02:00
|
|
|
LOG(ERROR) << "Execute response: " << to_string(res);
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2019-12-03 02:36:23 +01:00
|
|
|
uint64 send_request(td_api::object_ptr<td_api::Function> f) {
|
2018-12-31 20:04:05 +01:00
|
|
|
static uint64 query_num = 1;
|
2018-10-28 18:30:47 +01:00
|
|
|
if (!td_client_.empty()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto id = query_num++;
|
2018-10-28 18:30:47 +01:00
|
|
|
send_closure_later(td_client_, &ClientActor::request, id, std::move(f));
|
2018-12-31 20:04:05 +01:00
|
|
|
return id;
|
|
|
|
} else {
|
|
|
|
LOG(ERROR) << "Failed to send: " << to_string(f);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-19 17:11:16 +02:00
|
|
|
static int32 get_log_tag_verbosity_level(const string &name) {
|
2021-09-04 11:22:26 +02:00
|
|
|
auto level = ClientActor::execute(td_api::make_object<td_api::getLogTagVerbosityLevel>(name));
|
|
|
|
if (level->get_id() == td_api::error::ID) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
CHECK(level->get_id() == td_api::logVerbosityLevel::ID);
|
|
|
|
return static_cast<const td_api::logVerbosityLevel *>(level.get())->verbosity_level_;
|
|
|
|
}
|
|
|
|
|
2021-12-31 12:20:34 +01:00
|
|
|
void send_message(int64 chat_id, td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
|
2023-06-08 16:27:24 +02:00
|
|
|
bool disable_notification = false, bool from_background = false,
|
2023-07-01 18:54:22 +02:00
|
|
|
MessageReplyTo message_reply_to = MessageReplyTo::get_default()) {
|
2019-02-21 17:48:05 +01:00
|
|
|
auto id = send_request(td_api::make_object<td_api::sendMessage>(
|
2023-06-08 16:27:24 +02:00
|
|
|
chat_id, message_thread_id_, message_reply_to,
|
2022-09-04 00:14:25 +02:00
|
|
|
td_api::make_object<td_api::messageSendOptions>(disable_notification, from_background, true, true,
|
2023-02-23 15:05:43 +01:00
|
|
|
as_message_scheduling_state(schedule_date_),
|
|
|
|
Random::fast(1, 1000)),
|
2019-12-06 01:08:11 +01:00
|
|
|
nullptr, std::move(input_message_content)));
|
2022-02-09 22:59:52 +01:00
|
|
|
if (id != 0) {
|
|
|
|
query_id_to_send_message_info_[id].start_time = Time::now();
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2020-08-09 14:14:30 +02:00
|
|
|
td_api::object_ptr<td_api::messageSendOptions> default_message_send_options() const {
|
2023-02-23 15:05:43 +01:00
|
|
|
return td_api::make_object<td_api::messageSendOptions>(
|
|
|
|
false, false, false, true, as_message_scheduling_state(schedule_date_), Random::fast(1, 1000));
|
2019-12-06 01:13:41 +01:00
|
|
|
}
|
|
|
|
|
2019-05-07 16:10:20 +02:00
|
|
|
void send_get_background_url(td_api::object_ptr<td_api::BackgroundType> &&background_type) {
|
|
|
|
send_request(td_api::make_object<td_api::getBackgroundUrl>("asd", std::move(background_type)));
|
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void on_cmd(string cmd) {
|
2023-04-27 13:13:32 +02:00
|
|
|
for (size_t i = 0; i < cmd.size();) {
|
|
|
|
// https://en.wikipedia.org/wiki/ANSI_escape_code#Terminal_input_sequences
|
|
|
|
if (cmd[i] == 27 && cmd[i + 1] == '[') {
|
|
|
|
// likely an ANSI escape code
|
2023-04-28 15:46:28 +02:00
|
|
|
auto j = i + 2;
|
2023-04-27 13:13:32 +02:00
|
|
|
if ('1' <= cmd[j] && cmd[j] <= '9') {
|
|
|
|
while ('0' <= cmd[j] && cmd[j] <= '9') {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ('A' <= cmd[j] && cmd[j] <= 'Z') {
|
|
|
|
// xterm sequence
|
|
|
|
cmd = cmd.substr(0, i) + cmd.substr(j + 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (cmd[j] == ';' && '1' <= cmd[j + 1] && cmd[j + 1] <= '9') {
|
|
|
|
j += 2;
|
|
|
|
while ('0' <= cmd[j] && cmd[j] <= '9') {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cmd[j] == '~') {
|
|
|
|
// vt sequence
|
|
|
|
cmd = cmd.substr(0, i) + cmd.substr(j + 1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2019-10-21 15:25:56 +02:00
|
|
|
td::remove_if(cmd, [](unsigned char c) { return c < 32; });
|
2018-12-31 20:04:05 +01:00
|
|
|
LOG(INFO) << "CMD:[" << cmd << "]";
|
|
|
|
|
|
|
|
string op;
|
|
|
|
string args;
|
|
|
|
std::tie(op, args) = split(cmd);
|
|
|
|
|
2021-12-04 23:00:28 +01:00
|
|
|
const int32 OP_BLOCK_COUNT = 10;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 op_not_found_count = 0;
|
|
|
|
|
|
|
|
if (op == "gas") {
|
2022-01-02 10:19:14 +01:00
|
|
|
LOG(ERROR) << to_string(authorization_state_);
|
2021-11-24 15:01:02 +01:00
|
|
|
} else if (op == "sap" || op == "sapn") {
|
|
|
|
send_request(
|
2022-10-12 14:03:47 +02:00
|
|
|
td_api::make_object<td_api::setAuthenticationPhoneNumber>(args, as_phone_number_authentication_settings()));
|
2022-09-06 13:04:39 +02:00
|
|
|
} else if (op == "sae" || op == "saea") {
|
|
|
|
send_request(td_api::make_object<td_api::setAuthenticationEmailAddress>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rac") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::resendAuthenticationCode>());
|
2022-09-07 20:27:23 +02:00
|
|
|
} else if (op == "sdek") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setDatabaseEncryptionKey>(args));
|
2022-09-06 16:17:39 +02:00
|
|
|
} else if (op == "caec") {
|
2022-09-07 14:18:43 +02:00
|
|
|
send_request(td_api::make_object<td_api::checkAuthenticationEmailCode>(as_email_address_authentication(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cac") {
|
2019-07-16 21:08:34 +02:00
|
|
|
send_request(td_api::make_object<td_api::checkAuthenticationCode>(args));
|
|
|
|
} else if (op == "ru") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string first_name;
|
|
|
|
string last_name;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, first_name, last_name);
|
2019-07-16 21:08:34 +02:00
|
|
|
send_request(td_api::make_object<td_api::registerUser>(first_name, last_name));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cap") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkAuthenticationPassword>(args));
|
2019-12-17 17:17:57 +01:00
|
|
|
} else if (op == "cabt") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkAuthenticationBotToken>(args));
|
2019-12-17 17:17:57 +01:00
|
|
|
} else if (op == "qr") {
|
|
|
|
send_request(td_api::make_object<td_api::requestQrCodeAuthentication>(as_user_ids(args)));
|
|
|
|
} else if (op == "cqr") {
|
|
|
|
send_request(td_api::make_object<td_api::confirmQrCodeAuthentication>(args));
|
2018-09-20 18:33:41 +02:00
|
|
|
} else if (op == "gcs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getCurrentState>());
|
2023-03-20 13:17:51 +01:00
|
|
|
} else if (op == "raea") {
|
|
|
|
send_request(td_api::make_object<td_api::resetAuthenticationEmailAddress>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rapr") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::requestAuthenticationPasswordRecovery>());
|
2021-06-28 21:33:08 +02:00
|
|
|
} else if (op == "caprc") {
|
2021-06-28 22:47:54 +02:00
|
|
|
string recovery_code = args;
|
|
|
|
send_request(td_api::make_object<td_api::checkAuthenticationPasswordRecoveryCode>(recovery_code));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rap") {
|
2021-06-28 22:47:54 +02:00
|
|
|
string recovery_code;
|
2021-06-28 18:47:23 +02:00
|
|
|
string new_password;
|
|
|
|
string new_hint;
|
2021-06-28 22:47:54 +02:00
|
|
|
get_args(args, recovery_code, new_password, new_hint);
|
|
|
|
send_request(td_api::make_object<td_api::recoverAuthenticationPassword>(recovery_code, new_password, new_hint));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "lo" || op == "LogOut" || op == "logout") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::logOut>());
|
2019-12-18 01:47:51 +01:00
|
|
|
} else if (op == "destroy") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::destroy>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "reset") {
|
2018-11-06 22:09:05 +01:00
|
|
|
td_client_.reset();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "close_td") {
|
2019-02-21 17:48:05 +01:00
|
|
|
// send_request(td_api::make_object<td_api::getCurrentState>());
|
|
|
|
send_request(td_api::make_object<td_api::close>());
|
|
|
|
// send_request(td_api::make_object<td_api::getCurrentState>());
|
|
|
|
// send_request(td_api::make_object<td_api::close>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "DeleteAccountYesIReallyWantToDeleteMyAccount") {
|
2022-07-01 20:25:34 +02:00
|
|
|
string password;
|
|
|
|
string reason;
|
|
|
|
get_args(args, password, reason);
|
|
|
|
send_request(td_api::make_object<td_api::deleteAccount>(reason, password));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gps" || op == "GetPasswordState") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getPasswordState>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spass" || op == "SetPassword") {
|
|
|
|
string password;
|
|
|
|
string new_password;
|
|
|
|
string new_hint;
|
|
|
|
string recovery_email_address;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, password, new_password, new_hint, recovery_email_address);
|
2018-12-31 20:04:05 +01:00
|
|
|
if (password == "#") {
|
|
|
|
password = "";
|
|
|
|
}
|
|
|
|
if (new_password == "#") {
|
|
|
|
new_password = "";
|
|
|
|
}
|
|
|
|
if (new_hint == "#") {
|
|
|
|
new_hint = "";
|
|
|
|
}
|
|
|
|
if (recovery_email_address == "#") {
|
|
|
|
recovery_email_address = "";
|
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setPassword>(password, new_password, new_hint, true, recovery_email_address));
|
2018-04-28 00:54:45 +02:00
|
|
|
} else if (op == "gpafhttp") {
|
2018-04-06 15:24:29 +02:00
|
|
|
ChainBufferWriter writer;
|
|
|
|
writer.append(PSLICE() << "GET " << args << " HTTP/1.1\r\n\r\n\r\n");
|
|
|
|
ChainBufferReader reader = writer.extract_reader();
|
|
|
|
HttpReader http_reader;
|
|
|
|
http_reader.init(&reader);
|
|
|
|
HttpQuery query;
|
2022-10-09 13:15:54 +02:00
|
|
|
auto r_size = http_reader.read_next(&query);
|
|
|
|
if (r_size.is_error()) {
|
|
|
|
LOG(ERROR) << r_size.error();
|
2018-04-06 15:24:29 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-12-31 12:56:57 +01:00
|
|
|
string bot_user_id = query.get_arg("bot_id").str();
|
2018-04-19 14:23:54 +02:00
|
|
|
string scope = query.get_arg("scope").str();
|
|
|
|
string public_key = query.get_arg("public_key").str();
|
|
|
|
string payload = query.get_arg("payload").str();
|
2018-04-23 17:05:02 +02:00
|
|
|
LOG(INFO) << "Callback URL:" << query.get_arg("callback_url");
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::getPassportAuthorizationForm>(as_user_id(bot_user_id), scope, public_key,
|
|
|
|
payload));
|
2018-04-28 00:54:45 +02:00
|
|
|
} else if (op == "gpaf") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId bot_user_id;
|
2018-04-28 00:54:45 +02:00
|
|
|
string scope;
|
|
|
|
string public_key =
|
|
|
|
"-----BEGIN PUBLIC KEY-----\n"
|
|
|
|
"MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzmgKr0fPP4rB/TsNEweC\n"
|
|
|
|
"hoG3ntUxuBTmHsFBW6CpABGdaTmKZSjAI/cTofhBgtRQIOdX0YRGHHHhwyLf49Wv\n"
|
|
|
|
"9l+XexbJOa0lTsJSNMj8Y/9sZbqUl5ur8ZOTM0sxbXC0XKexu1tM9YavH+Lbrobk\n"
|
|
|
|
"jt0+cmo/zEYZWNtLVihnR2IDv+7tSgiDoFWi/koAUdfJ1VMw+hReUaLg3vE9CmPK\n"
|
|
|
|
"tQiTy+NvmrYaBPb75I0Jz3Lrz1+mZSjLKO25iT84RIsxarBDd8iYh2avWkCmvtiR\n"
|
|
|
|
"Lcif8wLxi2QWC1rZoCA3Ip+Hg9J9vxHlzl6xT01WjUStMhfwrUW6QBpur7FJ+aKM\n"
|
|
|
|
"oaMoHieFNCG4qIkWVEHHSsUpLum4SYuEnyNH3tkjbrdldZanCvanGq+TZyX0buRt\n"
|
|
|
|
"4zk7FGcu8iulUkAP/o/WZM0HKinFN/vuzNVA8iqcO/BBhewhzpqmmTMnWmAO8WPP\n"
|
|
|
|
"DJMABRtXJnVuPh1CI5pValzomLJM4/YvnJGppzI1QiHHNA9JtxVmj2xf8jaXa1LJ\n"
|
|
|
|
"WUNJK+RvUWkRUxpWiKQQO9FAyTPLRtDQGN9eUeDR1U0jqRk/gNT8smHGN6I4H+NR\n"
|
|
|
|
"3X3/1lMfcm1dvk654ql8mxjCA54IpTPr/icUMc7cSzyIiQ7Tp9PZTl1gHh281ZWf\n"
|
|
|
|
"P7d2+fuJMlkjtM7oAwf+tI8CAwEAAQ==\n"
|
|
|
|
"-----END PUBLIC KEY-----";
|
|
|
|
string payload;
|
2021-12-31 12:56:57 +01:00
|
|
|
get_args(args, bot_user_id, scope, payload);
|
|
|
|
send_request(td_api::make_object<td_api::getPassportAuthorizationForm>(bot_user_id, scope, public_key, payload));
|
2018-09-25 04:12:41 +02:00
|
|
|
} else if (op == "gpafae") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 form_id;
|
2018-09-25 04:12:41 +02:00
|
|
|
string password;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, form_id, password);
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(td_api::make_object<td_api::getPassportAuthorizationFormAvailableElements>(form_id, password));
|
2018-04-06 15:24:29 +02:00
|
|
|
} else if (op == "spaf") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 form_id;
|
2018-04-06 21:37:30 +02:00
|
|
|
string types;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, form_id, types);
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::sendPassportAuthorizationForm>(form_id, as_passport_element_types(types)));
|
2018-08-24 00:02:59 +02:00
|
|
|
} else if (op == "gpcl") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getPreferredCountryLanguage>(args));
|
2018-04-09 16:20:12 +02:00
|
|
|
} else if (op == "spnvc" || op == "SendPhoneNumberVerificationCode") {
|
2019-05-03 04:44:59 +02:00
|
|
|
send_request(td_api::make_object<td_api::sendPhoneNumberVerificationCode>(args, nullptr));
|
2018-04-09 16:20:12 +02:00
|
|
|
} else if (op == "cpnvc" || op == "CheckPhoneNumberVerificationCode") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkPhoneNumberVerificationCode>(args));
|
2018-04-09 18:04:21 +02:00
|
|
|
} else if (op == "rpnvc" || op == "ResendPhoneNumberVerificationCode") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::resendPhoneNumberVerificationCode>());
|
2018-04-09 18:04:21 +02:00
|
|
|
} else if (op == "seavc" || op == "SendEmailAddressVerificationCode") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::sendEmailAddressVerificationCode>(args));
|
2018-04-09 18:04:21 +02:00
|
|
|
} else if (op == "ceavc" || op == "CheckEmailAddressVerificationCode") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkEmailAddressVerificationCode>(args));
|
2018-04-09 18:04:21 +02:00
|
|
|
} else if (op == "reavc" || op == "ResendEmailAddressVerificationCode") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::resendEmailAddressVerificationCode>());
|
2022-09-07 12:49:48 +02:00
|
|
|
} else if (op == "slea") {
|
|
|
|
send_request(td_api::make_object<td_api::setLoginEmailAddress>(args));
|
2022-09-07 13:39:33 +02:00
|
|
|
} else if (op == "rleac") {
|
|
|
|
send_request(td_api::make_object<td_api::resendLoginEmailAddressCode>());
|
2022-09-07 14:18:43 +02:00
|
|
|
} else if (op == "cleac") {
|
|
|
|
send_request(td_api::make_object<td_api::checkLoginEmailAddressCode>(as_email_address_authentication(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "srea" || op == "SetRecoveryEmailAddress") {
|
|
|
|
string password;
|
|
|
|
string recovery_email_address;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, password, recovery_email_address);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setRecoveryEmailAddress>(password, recovery_email_address));
|
2019-02-10 21:16:52 +01:00
|
|
|
} else if (op == "grea" || op == "GetRecoveryEmailAddress") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getRecoveryEmailAddress>(args));
|
2019-02-10 21:16:52 +01:00
|
|
|
} else if (op == "creac") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkRecoveryEmailAddressCode>(args));
|
2019-02-10 21:32:49 +01:00
|
|
|
} else if (op == "rreac") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::resendRecoveryEmailAddressCode>());
|
2018-06-27 20:26:52 +02:00
|
|
|
} else if (op == "spncc") {
|
2021-10-18 11:57:13 +02:00
|
|
|
string hash;
|
|
|
|
string phone_number;
|
|
|
|
get_args(args, hash, phone_number);
|
|
|
|
send_request(td_api::make_object<td_api::sendPhoneNumberConfirmationCode>(hash, phone_number, nullptr));
|
2018-06-27 20:26:52 +02:00
|
|
|
} else if (op == "cpncc") {
|
2021-10-18 11:57:13 +02:00
|
|
|
send_request(td_api::make_object<td_api::checkPhoneNumberConfirmationCode>(args));
|
2018-06-27 20:26:52 +02:00
|
|
|
} else if (op == "rpncc") {
|
2021-10-18 11:57:13 +02:00
|
|
|
send_request(td_api::make_object<td_api::resendPhoneNumberConfirmationCode>());
|
2021-06-29 04:16:48 +02:00
|
|
|
} else if (op == "rpr") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::requestPasswordRecovery>());
|
2021-06-28 22:47:54 +02:00
|
|
|
} else if (op == "cprc") {
|
|
|
|
string recovery_code = args;
|
|
|
|
send_request(td_api::make_object<td_api::checkPasswordRecoveryCode>(recovery_code));
|
2021-06-29 04:16:48 +02:00
|
|
|
} else if (op == "rp") {
|
2021-06-28 22:47:54 +02:00
|
|
|
string recovery_code;
|
2021-06-28 18:47:23 +02:00
|
|
|
string new_password;
|
|
|
|
string new_hint;
|
2021-06-28 22:47:54 +02:00
|
|
|
get_args(args, recovery_code, new_password, new_hint);
|
|
|
|
send_request(td_api::make_object<td_api::recoverPassword>(recovery_code, new_password, new_hint));
|
2021-06-29 04:16:48 +02:00
|
|
|
} else if (op == "resetp") {
|
|
|
|
send_request(td_api::make_object<td_api::resetPassword>());
|
2021-06-30 18:49:52 +02:00
|
|
|
} else if (op == "cpr") {
|
|
|
|
send_request(td_api::make_object<td_api::cancelPasswordReset>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gtp" || op == "GetTemporaryPassword") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getTemporaryPasswordState>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ctp" || op == "CreateTemporaryPassword") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::createTemporaryPassword>(args, 60 * 6));
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (op == "gpe") {
|
2018-03-27 15:11:15 +02:00
|
|
|
string password;
|
2018-08-01 15:52:07 +02:00
|
|
|
string passport_element_type;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, password, passport_element_type);
|
2018-08-01 15:52:07 +02:00
|
|
|
send_request(
|
2019-02-21 17:48:05 +01:00
|
|
|
td_api::make_object<td_api::getPassportElement>(as_passport_element_type(passport_element_type), password));
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (op == "gape") {
|
2018-04-07 00:29:36 +02:00
|
|
|
string password = args;
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getAllPassportElements>(password));
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (op == "spe" || op == "spes") {
|
2018-03-27 15:11:15 +02:00
|
|
|
string password;
|
2018-08-01 15:52:07 +02:00
|
|
|
string passport_element_type;
|
2018-04-11 16:21:24 +02:00
|
|
|
string arg;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, password, passport_element_type, arg);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setPassportElement>(
|
2018-08-04 08:55:49 +02:00
|
|
|
as_input_passport_element(passport_element_type, arg, op == "spes"), password));
|
2018-08-01 15:52:07 +02:00
|
|
|
} else if (op == "dpe") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &passport_element_type = args;
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::deletePassportElement>(as_passport_element_type(passport_element_type)));
|
2018-12-24 01:12:59 +01:00
|
|
|
} else if (op == "ppn") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::processPushNotification>(args));
|
2018-12-28 23:48:32 +01:00
|
|
|
} else if (op == "gpri") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getPushReceiverId>(args));
|
2018-01-10 13:11:35 +01:00
|
|
|
} else if (op == "rda") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::registerDevice>(
|
|
|
|
td_api::make_object<td_api::deviceTokenApplePush>(args, true), as_user_ids("")));
|
2018-01-10 13:11:35 +01:00
|
|
|
} else if (op == "rdb") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::registerDevice>(
|
|
|
|
td_api::make_object<td_api::deviceTokenBlackBerryPush>(args), as_user_ids("")));
|
2019-04-18 01:23:02 +02:00
|
|
|
} else if (op == "rdf") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::registerDevice>(
|
2019-04-18 01:23:02 +02:00
|
|
|
td_api::make_object<td_api::deviceTokenFirebaseCloudMessaging>(args, true), as_user_ids("")));
|
2018-01-19 16:04:16 +01:00
|
|
|
} else if (op == "rdt") {
|
|
|
|
string token;
|
|
|
|
string other_user_ids_str;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, token, other_user_ids_str);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::registerDevice>(td_api::make_object<td_api::deviceTokenTizenPush>(token),
|
|
|
|
as_user_ids(other_user_ids_str)));
|
2018-01-10 13:11:35 +01:00
|
|
|
} else if (op == "rdu") {
|
2018-01-10 01:18:03 +01:00
|
|
|
string token;
|
|
|
|
string other_user_ids_str;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, token, other_user_ids_str);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::registerDevice>(
|
|
|
|
td_api::make_object<td_api::deviceTokenUbuntuPush>(token), as_user_ids(other_user_ids_str)));
|
2018-01-19 16:04:16 +01:00
|
|
|
} else if (op == "rdw") {
|
|
|
|
string endpoint;
|
|
|
|
string key;
|
|
|
|
string secret;
|
|
|
|
string other_user_ids_str;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, endpoint, key, secret, other_user_ids_str);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::registerDevice>(
|
|
|
|
td_api::make_object<td_api::deviceTokenWebPush>(endpoint, key, secret), as_user_ids(other_user_ids_str)));
|
2020-02-13 17:20:34 +01:00
|
|
|
} else if (op == "gbci") {
|
|
|
|
send_request(td_api::make_object<td_api::getBankCardInfo>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gpf") {
|
2022-05-03 17:50:29 +02:00
|
|
|
InputInvoice input_invoice;
|
|
|
|
get_args(args, input_invoice);
|
2022-10-12 14:03:47 +02:00
|
|
|
send_request(td_api::make_object<td_api::getPaymentForm>(input_invoice, as_theme_parameters()));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "voi") {
|
2022-05-03 17:50:29 +02:00
|
|
|
InputInvoice input_invoice;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool allow_save;
|
2022-05-03 17:50:29 +02:00
|
|
|
get_args(args, input_invoice, allow_save);
|
|
|
|
send_request(td_api::make_object<td_api::validateOrderInfo>(input_invoice, nullptr, allow_save));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spfs") {
|
2022-05-03 17:50:29 +02:00
|
|
|
InputInvoice input_invoice;
|
2021-03-30 17:45:22 +02:00
|
|
|
int64 tip_amount;
|
2021-03-30 16:18:08 +02:00
|
|
|
int64 payment_form_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string order_info_id;
|
|
|
|
string shipping_option_id;
|
|
|
|
string saved_credentials_id;
|
2022-05-03 17:50:29 +02:00
|
|
|
get_args(args, input_invoice, tip_amount, payment_form_id, order_info_id, shipping_option_id,
|
2021-03-30 17:45:22 +02:00
|
|
|
saved_credentials_id);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::sendPaymentForm>(
|
2022-05-03 17:50:29 +02:00
|
|
|
input_invoice, payment_form_id, order_info_id, shipping_option_id,
|
2021-03-30 17:45:22 +02:00
|
|
|
td_api::make_object<td_api::inputCredentialsSaved>(saved_credentials_id), tip_amount));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spfn") {
|
2022-05-03 17:50:29 +02:00
|
|
|
InputInvoice input_invoice;
|
2021-03-30 17:45:22 +02:00
|
|
|
int64 tip_amount;
|
2021-03-30 16:18:08 +02:00
|
|
|
int64 payment_form_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string order_info_id;
|
|
|
|
string shipping_option_id;
|
|
|
|
string data;
|
2022-05-03 17:50:29 +02:00
|
|
|
get_args(args, input_invoice, tip_amount, payment_form_id, order_info_id, shipping_option_id, data);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::sendPaymentForm>(
|
2022-05-03 17:50:29 +02:00
|
|
|
input_invoice, payment_form_id, order_info_id, shipping_option_id,
|
2021-03-30 17:45:22 +02:00
|
|
|
td_api::make_object<td_api::inputCredentialsNew>(data, true), tip_amount));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gpre") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getPaymentReceipt>(chat_id, message_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gsoi") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSavedOrderInfo>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "dsoi") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteSavedOrderInfo>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "dsc") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteSavedCredentials>());
|
2020-01-19 23:52:46 +01:00
|
|
|
// } else if (op == "stlsr") {
|
|
|
|
// send_request(td_api::make_object<td_api::sendTonLiteServerRequest>());
|
|
|
|
// } else if (op == "gtwps") {
|
|
|
|
// send_request(td_api::make_object<td_api::getTonWalletPasswordSalt>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gpr") {
|
2022-10-12 14:03:47 +02:00
|
|
|
send_request(td_api::make_object<td_api::getUserPrivacySettingRules>(as_user_privacy_setting(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spr") {
|
|
|
|
string setting;
|
2023-05-25 17:38:15 +02:00
|
|
|
PrivacyRules rules;
|
|
|
|
get_args(args, setting, rules);
|
|
|
|
send_request(td_api::make_object<td_api::setUserPrivacySettingRules>(as_user_privacy_setting(setting), rules));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cp" || op == "ChangePhone") {
|
2019-05-03 04:44:59 +02:00
|
|
|
send_request(td_api::make_object<td_api::changePhoneNumber>(args, nullptr));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ccpc" || op == "CheckChangePhoneCode") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkChangePhoneNumberCode>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rcpc" || op == "ResendChangePhoneCode") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::resendChangePhoneNumberCode>());
|
2018-08-16 19:09:23 +02:00
|
|
|
} else if (op == "gco") {
|
|
|
|
if (args.empty()) {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getContacts>());
|
2018-08-16 19:09:23 +02:00
|
|
|
} else {
|
2020-12-25 23:25:00 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchContacts>("", as_limit(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2023-05-03 19:42:47 +02:00
|
|
|
} else if (op == "gcfr") {
|
|
|
|
send_request(td_api::make_object<td_api::getCloseFriends>());
|
2023-05-04 17:27:03 +02:00
|
|
|
} else if (op == "scfr") {
|
|
|
|
send_request(td_api::make_object<td_api::setCloseFriends>(as_user_ids(args)));
|
2022-12-01 13:08:13 +01:00
|
|
|
} else if (op == "gul") {
|
|
|
|
send_request(td_api::make_object<td_api::getUserLink>());
|
2022-12-01 14:54:58 +01:00
|
|
|
} else if (op == "subt") {
|
|
|
|
send_request(td_api::make_object<td_api::searchUserByToken>(args));
|
2023-06-28 15:29:20 +02:00
|
|
|
} else if (op == "aco") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2019-10-08 17:12:15 +02:00
|
|
|
string first_name;
|
|
|
|
string last_name;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, user_id, first_name, last_name);
|
2019-10-08 17:12:15 +02:00
|
|
|
send_request(td_api::make_object<td_api::addContact>(
|
2021-12-31 12:56:57 +01:00
|
|
|
td_api::make_object<td_api::contact>(string(), first_name, last_name, string(), user_id), false));
|
2022-02-18 16:13:10 +01:00
|
|
|
} else if (op == "subpn") {
|
|
|
|
string phone_number;
|
|
|
|
get_args(args, phone_number);
|
|
|
|
send_request(td_api::make_object<td_api::searchUserByPhoneNumber>(phone_number));
|
2019-10-11 16:59:04 +02:00
|
|
|
} else if (op == "spn") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
|
|
|
get_args(args, user_id);
|
|
|
|
send_request(td_api::make_object<td_api::sharePhoneNumber>(user_id));
|
2018-06-25 23:10:53 +02:00
|
|
|
} else if (op == "ImportContacts" || op == "cic") {
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<string> contacts_str = full_split(args, ';');
|
2019-12-03 02:36:23 +01:00
|
|
|
vector<td_api::object_ptr<td_api::contact>> contacts;
|
2018-12-31 20:04:05 +01:00
|
|
|
for (auto c : contacts_str) {
|
|
|
|
string phone_number;
|
|
|
|
string first_name;
|
|
|
|
string last_name;
|
|
|
|
std::tie(phone_number, c) = split(c, ',');
|
|
|
|
std::tie(first_name, last_name) = split(c, ',');
|
2019-02-21 17:48:05 +01:00
|
|
|
contacts.push_back(td_api::make_object<td_api::contact>(phone_number, first_name, last_name, string(), 0));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-06-25 23:10:53 +02:00
|
|
|
if (op == "cic") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::changeImportedContacts>(std::move(contacts)));
|
2018-06-25 23:10:53 +02:00
|
|
|
} else {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::importContacts>(std::move(contacts)));
|
2018-06-25 23:10:53 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "RemoveContacts") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeContacts>(as_user_ids(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gicc") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getImportedContactCount>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ClearImportedContacts") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::clearImportedContacts>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
2021-08-11 14:59:09 +02:00
|
|
|
if (op == "gc" || op == "gca" || begins_with(op, "gc-")) {
|
|
|
|
send_request(td_api::make_object<td_api::getChats>(as_chat_list(op), as_limit(args, 10000)));
|
2021-08-10 16:52:31 +02:00
|
|
|
} else if (op == "lc" || op == "lca" || begins_with(op, "lc-")) {
|
|
|
|
send_request(td_api::make_object<td_api::loadChats>(as_chat_list(op), as_limit(args, 10000)));
|
2018-12-15 17:27:06 +01:00
|
|
|
} else if (op == "gctest") {
|
2021-08-11 14:59:09 +02:00
|
|
|
send_request(td_api::make_object<td_api::getChats>(nullptr, 1));
|
|
|
|
send_request(td_api::make_object<td_api::getChats>(nullptr, 10));
|
|
|
|
send_request(td_api::make_object<td_api::getChats>(nullptr, 5));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gcc" || op == "GetCommonChats") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
ChatId offset_chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, user_id, offset_chat_id, limit);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::getGroupsInCommon>(user_id, offset_chat_id, as_limit(limit, 100)));
|
2020-09-30 03:26:39 +02:00
|
|
|
} else if (op == "gh" || op == "GetHistory" || op == "ghl" || op == "gmth") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId thread_message_id;
|
|
|
|
MessageId from_message_id;
|
2020-12-26 18:58:30 +01:00
|
|
|
int32 offset;
|
2020-12-26 18:47:51 +01:00
|
|
|
string limit;
|
2023-01-17 13:34:31 +01:00
|
|
|
get_args(args, chat_id, args);
|
2020-09-30 03:26:39 +02:00
|
|
|
if (op == "gmth") {
|
2020-12-26 18:58:30 +01:00
|
|
|
get_args(args, thread_message_id, args);
|
2020-09-30 03:26:39 +02:00
|
|
|
}
|
2023-01-17 13:34:31 +01:00
|
|
|
get_args(args, from_message_id, offset, limit);
|
2020-12-26 18:47:51 +01:00
|
|
|
if (op == "gmth") {
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessageThreadHistory>(chat_id, thread_message_id, from_message_id,
|
|
|
|
offset, as_limit(limit)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatHistory>(chat_id, from_message_id, offset, as_limit(limit),
|
|
|
|
op == "ghl"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-12-04 18:06:39 +01:00
|
|
|
} else if (op == "gcsm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatScheduledMessages>(chat_id));
|
2022-08-22 20:29:09 +02:00
|
|
|
} else if (op == "sdrt") {
|
|
|
|
string reaction;
|
|
|
|
get_args(args, reaction);
|
|
|
|
send_request(td_api::make_object<td_api::setDefaultReactionType>(as_reaction_type(reaction)));
|
2022-09-12 14:03:35 +02:00
|
|
|
} else if (op == "ger") {
|
|
|
|
string emoji;
|
|
|
|
get_args(args, emoji);
|
|
|
|
send_request(td_api::make_object<td_api::getEmojiReaction>(emoji));
|
2022-09-12 14:44:37 +02:00
|
|
|
} else if (op == "gcera") {
|
|
|
|
send_request(td_api::make_object<td_api::getCustomEmojiReactionAnimations>());
|
2022-01-26 13:25:03 +01:00
|
|
|
} else if (op == "gmar") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
get_args(args, chat_id, message_id);
|
2022-09-13 18:19:35 +02:00
|
|
|
send_request(td_api::make_object<td_api::getMessageAvailableReactions>(chat_id, message_id, 8));
|
2022-09-12 18:37:45 +02:00
|
|
|
} else if (op == "crr") {
|
|
|
|
send_request(td_api::make_object<td_api::clearRecentReactions>());
|
2022-09-09 14:56:45 +02:00
|
|
|
} else if (op == "amr" || op == "react") {
|
2022-01-21 18:39:55 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
string reaction;
|
2022-01-26 14:41:41 +01:00
|
|
|
bool is_big;
|
2022-09-09 14:56:45 +02:00
|
|
|
bool update_recent_reactions;
|
|
|
|
get_args(args, chat_id, message_id, reaction, is_big, update_recent_reactions);
|
|
|
|
send_request(td_api::make_object<td_api::addMessageReaction>(chat_id, message_id, as_reaction_type(reaction),
|
|
|
|
is_big, update_recent_reactions));
|
|
|
|
} else if (op == "rmr") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
string reaction;
|
|
|
|
get_args(args, chat_id, message_id, reaction);
|
|
|
|
send_request(td_api::make_object<td_api::removeMessageReaction>(chat_id, message_id, as_reaction_type(reaction)));
|
2022-01-26 23:52:21 +01:00
|
|
|
} else if (op == "gmars") {
|
2022-01-21 14:46:16 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
string reaction;
|
|
|
|
string offset;
|
|
|
|
string limit;
|
|
|
|
get_args(args, chat_id, message_id, reaction, offset, limit);
|
2022-08-16 21:42:29 +02:00
|
|
|
send_request(td_api::make_object<td_api::getMessageAddedReactions>(
|
|
|
|
chat_id, message_id, as_reaction_type(reaction), offset, as_limit(limit)));
|
2020-08-21 13:47:43 +02:00
|
|
|
} else if (op == "gmpf") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-08-21 13:47:43 +02:00
|
|
|
string offset;
|
|
|
|
string limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, offset, limit);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessagePublicForwards>(chat_id, message_id, offset, as_limit(limit)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ghf") {
|
2018-06-01 01:12:36 +02:00
|
|
|
get_history_chat_id_ = as_chat_id(args);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatHistory>(get_history_chat_id_, std::numeric_limits<int64>::max(),
|
|
|
|
0, 100, false));
|
2020-09-11 16:51:01 +02:00
|
|
|
} else if (op == "replies") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2022-10-23 21:16:20 +02:00
|
|
|
string filter;
|
|
|
|
get_args(args, chat_id, message_thread_id, filter);
|
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
2022-10-27 13:19:04 +02:00
|
|
|
chat_id, "", nullptr, 0, 0, 100, as_search_messages_filter(filter), message_thread_id));
|
2018-01-10 17:59:38 +01:00
|
|
|
} else if (op == "spvf") {
|
2018-06-01 01:12:36 +02:00
|
|
|
search_chat_id_ = as_chat_id(args);
|
2020-12-26 19:12:09 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(search_chat_id_, "", nullptr, 0, 0, 100,
|
|
|
|
as_search_messages_filter("pvi"), 0));
|
2019-10-22 14:06:11 +02:00
|
|
|
} else if (op == "Search" || op == "SearchA" || op == "SearchM") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string query;
|
2020-12-26 17:40:46 +01:00
|
|
|
string limit;
|
2020-08-21 16:40:05 +02:00
|
|
|
string filter;
|
2022-12-25 20:28:05 +01:00
|
|
|
string offset;
|
|
|
|
get_args(args, query, limit, filter, offset);
|
2019-10-22 14:06:11 +02:00
|
|
|
td_api::object_ptr<td_api::ChatList> chat_list;
|
|
|
|
if (op == "SearchA") {
|
|
|
|
chat_list = td_api::make_object<td_api::chatListArchive>();
|
|
|
|
}
|
|
|
|
if (op == "SearchM") {
|
|
|
|
chat_list = td_api::make_object<td_api::chatListMain>();
|
|
|
|
}
|
2022-12-25 20:28:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchMessages>(std::move(chat_list), query, offset, as_limit(limit),
|
|
|
|
as_search_messages_filter(filter), 1, 2147483647));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "SCM") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, chat_id, query);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, 0, 0, query.limit,
|
|
|
|
nullptr, 0));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "SMME") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, limit);
|
2020-10-14 13:41:04 +02:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
2021-12-31 12:20:34 +01:00
|
|
|
chat_id, "", td_api::make_object<td_api::messageSenderUser>(my_id_), 0, 0, as_limit(limit), nullptr, 0));
|
2020-10-14 13:41:04 +02:00
|
|
|
} else if (op == "SMU" || op == "SMC") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-10-14 13:41:04 +02:00
|
|
|
string sender_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId from_message_id;
|
2020-03-05 18:11:35 +01:00
|
|
|
string limit;
|
2021-11-30 13:07:14 +01:00
|
|
|
get_args(args, chat_id, sender_id, from_message_id, limit);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, "", as_message_sender(sender_id),
|
|
|
|
from_message_id, 0, as_limit(limit), nullptr, 0));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "SM") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2019-12-28 23:46:30 +01:00
|
|
|
string filter;
|
|
|
|
string limit;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId offset_message_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 offset;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, filter, limit, offset_message_id, offset);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, "", nullptr, offset_message_id, offset, as_limit(limit), as_search_messages_filter(filter), 0));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "SC") {
|
|
|
|
string limit;
|
2022-12-28 17:17:25 +01:00
|
|
|
string offset;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool only_missed;
|
2022-12-28 17:17:25 +01:00
|
|
|
get_args(args, limit, offset, only_missed);
|
|
|
|
send_request(td_api::make_object<td_api::searchCallMessages>(offset, as_limit(limit), only_missed));
|
2022-02-22 13:58:16 +01:00
|
|
|
} else if (op == "sodm") {
|
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, query);
|
|
|
|
send_request(td_api::make_object<td_api::searchOutgoingDocumentMessages>(query.query, query.limit));
|
2021-01-19 11:21:50 +01:00
|
|
|
} else if (op == "DeleteAllCallMessages") {
|
|
|
|
bool revoke = as_bool(args);
|
|
|
|
send_request(td_api::make_object<td_api::deleteAllCallMessages>(revoke));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "SCRLM") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, limit);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatRecentLocationMessages>(chat_id, as_limit(limit)));
|
2021-10-30 02:34:49 +02:00
|
|
|
} else if (op == "gcmca") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-10-30 02:34:49 +02:00
|
|
|
string filter;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId from_message_id;
|
2021-10-30 02:34:49 +02:00
|
|
|
get_args(args, chat_id, filter, from_message_id);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatMessageCalendar>(chat_id, as_search_messages_filter(filter),
|
2021-12-31 12:31:43 +01:00
|
|
|
from_message_id));
|
2020-12-26 19:12:09 +01:00
|
|
|
} else if (op == "SearchAudio" || op == "SearchDocument" || op == "SearchPhoto" || op == "SearchChatPhoto") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId offset_message_id;
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, chat_id, offset_message_id, query);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMessages>(chat_id, query.query, nullptr, offset_message_id, 0,
|
|
|
|
query.limit, as_search_messages_filter(op), 0));
|
2021-10-15 16:40:30 +02:00
|
|
|
} else if (op == "gcmbd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-10-15 16:40:30 +02:00
|
|
|
int32 date;
|
|
|
|
get_args(args, chat_id, date);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatMessageByDate>(chat_id, date));
|
2021-10-15 16:40:30 +02:00
|
|
|
} else if (op == "gcsmp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-10-15 16:40:30 +02:00
|
|
|
string filter;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId from_message_id;
|
2021-10-15 16:40:30 +02:00
|
|
|
string limit;
|
|
|
|
get_args(args, chat_id, filter, from_message_id, limit);
|
|
|
|
send_request(td_api::make_object<td_api::getChatSparseMessagePositions>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, as_search_messages_filter(filter), from_message_id, as_limit(limit)));
|
2018-07-19 15:58:09 +02:00
|
|
|
} else if (op == "gcmc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-07-19 15:58:09 +02:00
|
|
|
string filter;
|
2020-12-26 17:40:46 +01:00
|
|
|
bool return_local;
|
|
|
|
get_args(args, chat_id, filter, return_local);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::getChatMessageCount>(chat_id, as_search_messages_filter(filter), return_local));
|
2022-09-30 19:04:21 +02:00
|
|
|
} else if (op == "gcmp") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
string filter;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2022-09-30 19:04:21 +02:00
|
|
|
get_args(args, chat_id, message_id, filter, message_thread_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatMessagePosition>(
|
2022-10-27 13:19:04 +02:00
|
|
|
chat_id, message_id, as_search_messages_filter(filter), message_thread_id));
|
2020-06-28 16:44:56 +02:00
|
|
|
} else if (op == "gup" || op == "gupp") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 offset;
|
2020-12-26 18:47:51 +01:00
|
|
|
string limit;
|
|
|
|
get_args(args, user_id, offset, limit);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::getUserProfilePhotos>(user_id, offset, as_limit(limit)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "dcrm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteChatReplyMarkup>(chat_id, message_id));
|
2018-09-04 03:29:26 +02:00
|
|
|
} else if (op == "glti") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getLocalizationTargetInfo>(as_bool(args)));
|
2019-02-12 02:15:45 +01:00
|
|
|
} else if (op == "glpi") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getLanguagePackInfo>(args));
|
2018-07-03 19:28:00 +02:00
|
|
|
} else if (op == "glps") {
|
|
|
|
string language_code;
|
|
|
|
string keys;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, language_code, keys);
|
2022-01-24 15:40:16 +01:00
|
|
|
send_request(td_api::make_object<td_api::getLanguagePackStrings>(language_code, autosplit_str(keys)));
|
2018-07-23 19:29:14 +02:00
|
|
|
} else if (op == "glpss") {
|
|
|
|
string language_database_path;
|
|
|
|
string language_pack;
|
|
|
|
string language_code;
|
|
|
|
string key;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, language_database_path, language_pack, language_code, key);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getLanguagePackString>(language_database_path, language_pack,
|
|
|
|
language_code, key));
|
2019-02-23 18:27:14 +01:00
|
|
|
} else if (op == "synclp") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &language_code = args;
|
2019-02-23 18:27:14 +01:00
|
|
|
send_request(td_api::make_object<td_api::synchronizeLanguagePack>(language_code));
|
2019-02-11 19:53:10 +01:00
|
|
|
} else if (op == "acslp") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &language_code = args;
|
2019-02-11 19:53:10 +01:00
|
|
|
send_request(td_api::make_object<td_api::addCustomServerLanguagePack>(language_code));
|
2018-09-04 03:29:26 +02:00
|
|
|
} else if (op == "sclp") {
|
2018-08-06 16:22:22 +02:00
|
|
|
string language_code;
|
|
|
|
string name;
|
|
|
|
string native_name;
|
|
|
|
string key;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, language_code, name, native_name, key);
|
2019-12-03 02:36:23 +01:00
|
|
|
vector<td_api::object_ptr<td_api::languagePackString>> strings;
|
2019-02-21 17:48:05 +01:00
|
|
|
strings.push_back(td_api::make_object<td_api::languagePackString>(
|
|
|
|
key, td_api::make_object<td_api::languagePackStringValueOrdinary>("Ordinary value")));
|
|
|
|
strings.push_back(td_api::make_object<td_api::languagePackString>(
|
|
|
|
"Plu", td_api::make_object<td_api::languagePackStringValuePluralized>("Zero", string("One\0One", 7), "Two",
|
|
|
|
"Few", "Many", "Other")));
|
|
|
|
strings.push_back(td_api::make_object<td_api::languagePackString>(
|
|
|
|
"DELETED", td_api::make_object<td_api::languagePackStringValueDeleted>()));
|
|
|
|
send_request(td_api::make_object<td_api::setCustomLanguagePack>(
|
2019-02-11 18:57:35 +01:00
|
|
|
as_language_pack_info(language_code, name, native_name), std::move(strings)));
|
2018-09-04 03:29:26 +02:00
|
|
|
} else if (op == "eclpi") {
|
2018-08-31 19:18:12 +02:00
|
|
|
string language_code;
|
|
|
|
string name;
|
|
|
|
string native_name;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, language_code, name, native_name);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::editCustomLanguagePackInfo>(
|
|
|
|
as_language_pack_info(language_code, name, native_name)));
|
2018-09-04 03:29:26 +02:00
|
|
|
} else if (op == "sclpsv" || op == "sclpsp" || op == "sclpsd") {
|
2018-08-22 22:11:54 +02:00
|
|
|
string language_code;
|
|
|
|
string key;
|
|
|
|
string value;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, language_code, key, value);
|
2019-12-03 02:36:23 +01:00
|
|
|
td_api::object_ptr<td_api::languagePackString> str =
|
|
|
|
td_api::make_object<td_api::languagePackString>(key, nullptr);
|
2018-08-22 22:11:54 +02:00
|
|
|
if (op == "sclsv") {
|
2019-02-21 17:48:05 +01:00
|
|
|
str->value_ = td_api::make_object<td_api::languagePackStringValueOrdinary>(value);
|
2018-08-22 22:11:54 +02:00
|
|
|
} else if (op == "sclsp") {
|
2019-02-21 17:48:05 +01:00
|
|
|
str->value_ = td_api::make_object<td_api::languagePackStringValuePluralized>(value, string("One\0One", 7),
|
|
|
|
"Two", "Few", "Many", "Other");
|
2018-08-22 22:11:54 +02:00
|
|
|
} else {
|
2019-02-21 17:48:05 +01:00
|
|
|
str->value_ = td_api::make_object<td_api::languagePackStringValueDeleted>();
|
2018-08-22 22:11:54 +02:00
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setCustomLanguagePackString>(language_code, std::move(str)));
|
2018-09-04 03:29:26 +02:00
|
|
|
} else if (op == "dlp") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteLanguagePack>(args));
|
2021-12-03 09:20:56 +01:00
|
|
|
} else if (op == "on" || op == "off") {
|
|
|
|
send_request(td_api::make_object<td_api::setOption>("online",
|
|
|
|
td_api::make_object<td_api::optionValueBoolean>(op == "on")));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "go") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getOption>(args));
|
2022-07-11 12:33:56 +02:00
|
|
|
} else if (op == "gos") {
|
|
|
|
execute(td_api::make_object<td_api::getOption>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sob") {
|
|
|
|
string name;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool value;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, name, value);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setOption>(name, td_api::make_object<td_api::optionValueBoolean>(value)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "soe") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setOption>(args, td_api::make_object<td_api::optionValueEmpty>()));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "soi") {
|
|
|
|
string name;
|
2020-12-26 17:40:46 +01:00
|
|
|
int64 value;
|
|
|
|
get_args(args, name, value);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(
|
2020-12-26 17:40:46 +01:00
|
|
|
td_api::make_object<td_api::setOption>(name, td_api::make_object<td_api::optionValueInteger>(value)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sos") {
|
|
|
|
string name;
|
|
|
|
string value;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, name, value);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setOption>(name, td_api::make_object<td_api::optionValueString>(value)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "me") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMe>());
|
2022-12-28 15:02:41 +01:00
|
|
|
} else if (op == "sdmadt") {
|
2022-12-28 19:46:16 +01:00
|
|
|
int32 auto_delete_time;
|
|
|
|
get_args(args, auto_delete_time);
|
|
|
|
send_request(td_api::make_object<td_api::setDefaultMessageAutoDeleteTime>(
|
|
|
|
td_api::make_object<td_api::messageAutoDeleteTime>(auto_delete_time)));
|
2022-12-28 15:02:41 +01:00
|
|
|
} else if (op == "gdmadt") {
|
2022-12-28 19:46:16 +01:00
|
|
|
send_request(td_api::make_object<td_api::getDefaultMessageAutoDeleteTime>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sattl") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int32 days;
|
|
|
|
get_args(args, days);
|
|
|
|
send_request(td_api::make_object<td_api::setAccountTtl>(td_api::make_object<td_api::accountTtl>(days)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gattl") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getAccountTtl>());
|
2021-11-16 14:04:19 +01:00
|
|
|
} else if (op == "GetActiveSessions" || op == "devices" || op == "sessions") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getActiveSessions>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "TerminateSession") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int64 session_id;
|
|
|
|
get_args(args, session_id);
|
|
|
|
send_request(td_api::make_object<td_api::terminateSession>(session_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "TerminateAllOtherSessions") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::terminateAllOtherSessions>());
|
2021-11-24 15:59:17 +01:00
|
|
|
} else if (op == "tscac") {
|
|
|
|
int64 session_id;
|
|
|
|
bool can_accept_calls;
|
|
|
|
get_args(args, session_id, can_accept_calls);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSessionCanAcceptCalls>(session_id, can_accept_calls));
|
2021-11-16 14:04:19 +01:00
|
|
|
} else if (op == "tscasc") {
|
2021-11-16 13:22:00 +01:00
|
|
|
int64 session_id;
|
|
|
|
bool can_accept_secret_chats;
|
|
|
|
get_args(args, session_id, can_accept_secret_chats);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSessionCanAcceptSecretChats>(session_id, can_accept_secret_chats));
|
2021-11-16 14:04:19 +01:00
|
|
|
} else if (op == "sist") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int32 inactive_session_ttl_days;
|
|
|
|
get_args(args, inactive_session_ttl_days);
|
|
|
|
send_request(td_api::make_object<td_api::setInactiveSessionTtl>(inactive_session_ttl_days));
|
2018-02-07 00:31:38 +01:00
|
|
|
} else if (op == "gcw") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getConnectedWebsites>());
|
2018-02-07 00:31:38 +01:00
|
|
|
} else if (op == "dw") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int64 website_id;
|
|
|
|
get_args(args, website_id);
|
|
|
|
send_request(td_api::make_object<td_api::disconnectWebsite>(website_id));
|
2018-02-07 00:31:38 +01:00
|
|
|
} else if (op == "daw") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::disconnectAllWebsites>());
|
2019-05-07 16:10:20 +02:00
|
|
|
} else if (op == "gbgs") {
|
2019-06-18 00:39:57 +02:00
|
|
|
send_request(td_api::make_object<td_api::getBackgrounds>(as_bool(args)));
|
2019-05-07 16:10:20 +02:00
|
|
|
} else if (op == "gbgu") {
|
2023-04-10 18:45:15 +02:00
|
|
|
send_get_background_url(as_wallpaper_background(false, false));
|
|
|
|
send_get_background_url(as_wallpaper_background(false, true));
|
|
|
|
send_get_background_url(as_wallpaper_background(true, false));
|
|
|
|
send_get_background_url(as_wallpaper_background(true, true));
|
2022-10-12 14:03:47 +02:00
|
|
|
send_get_background_url(as_solid_pattern_background(-1, 0, false));
|
|
|
|
send_get_background_url(as_solid_pattern_background(0x1000000, 0, true));
|
|
|
|
send_get_background_url(as_solid_pattern_background(0, -1, false));
|
|
|
|
send_get_background_url(as_solid_pattern_background(0, 101, false));
|
|
|
|
send_get_background_url(as_solid_pattern_background(0, 0, false));
|
|
|
|
send_get_background_url(as_solid_pattern_background(0xFFFFFF, 100, true));
|
|
|
|
send_get_background_url(as_solid_pattern_background(0xABCDEF, 49, true));
|
|
|
|
send_get_background_url(as_gradient_pattern_background(0, 0, 0, false, false));
|
|
|
|
send_get_background_url(as_gradient_pattern_background(0, 0, 0, true, false));
|
|
|
|
send_get_background_url(as_gradient_pattern_background(0xFFFFFF, 0, 100, false, true));
|
|
|
|
send_get_background_url(as_gradient_pattern_background(0xFFFFFF, 0, 100, true, true));
|
|
|
|
send_get_background_url(as_gradient_pattern_background(0xABCDEF, 0xFEDCBA, 49, false, true));
|
|
|
|
send_get_background_url(as_gradient_pattern_background(0, 0x1000000, 49, false, true));
|
|
|
|
send_get_background_url(as_freeform_gradient_pattern_background({0xABCDEF, 0xFEDCBA}, 49, false, true));
|
|
|
|
send_get_background_url(as_freeform_gradient_pattern_background({0xABCDEF, 0x111111, 0x222222}, 49, true, true));
|
2021-05-21 00:49:59 +02:00
|
|
|
send_get_background_url(
|
2022-10-12 14:03:47 +02:00
|
|
|
as_freeform_gradient_pattern_background({0xABCDEF, 0xFEDCBA, 0x111111, 0x222222}, 49, false, true));
|
|
|
|
send_get_background_url(as_solid_background(-1));
|
|
|
|
send_get_background_url(as_solid_background(0xABCDEF));
|
|
|
|
send_get_background_url(as_solid_background(0x1000000));
|
|
|
|
send_get_background_url(as_gradient_background(0xABCDEF, 0xFEDCBA));
|
|
|
|
send_get_background_url(as_gradient_background(0, 0));
|
|
|
|
send_get_background_url(as_gradient_background(-1, -1));
|
|
|
|
send_get_background_url(as_freeform_gradient_background({0xFEDCBA, 0x222222}));
|
|
|
|
send_get_background_url(as_freeform_gradient_background({0xFEDCBA, 0x111111, 0x222222}));
|
|
|
|
send_get_background_url(as_freeform_gradient_background({0xABCDEF, 0xFEDCBA, 0x111111, 0x222222}));
|
2021-12-04 23:00:28 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
2023-04-10 19:22:10 +02:00
|
|
|
if (op == "SBG") {
|
2019-05-07 17:21:57 +02:00
|
|
|
send_request(td_api::make_object<td_api::searchBackground>(args));
|
2023-04-10 19:22:10 +02:00
|
|
|
} else if (op == "sbg" || op == "sbgd") {
|
2023-04-10 18:41:54 +02:00
|
|
|
InputBackground input_background;
|
2023-04-10 19:22:10 +02:00
|
|
|
BackgroundType background_type;
|
|
|
|
get_args(args, input_background, background_type);
|
|
|
|
send_request(td_api::make_object<td_api::setBackground>(input_background, background_type, op == "sbgd"));
|
2019-05-10 22:55:26 +02:00
|
|
|
} else if (op == "rbg") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int64 background_id;
|
|
|
|
get_args(args, background_id);
|
|
|
|
send_request(td_api::make_object<td_api::removeBackground>(background_id));
|
2019-05-12 03:10:18 +02:00
|
|
|
} else if (op == "rbgs") {
|
|
|
|
send_request(td_api::make_object<td_api::resetBackgrounds>());
|
2023-04-11 16:46:55 +02:00
|
|
|
} else if (op == "scbg") {
|
|
|
|
ChatId chat_id;
|
|
|
|
InputBackground input_background;
|
|
|
|
BackgroundType background_type;
|
2023-04-11 23:59:53 +02:00
|
|
|
int32 dark_theme_dimming;
|
|
|
|
get_args(args, chat_id, input_background, background_type, dark_theme_dimming);
|
2023-04-11 16:46:55 +02:00
|
|
|
send_request(td_api::make_object<td_api::setChatBackground>(chat_id, input_background, background_type,
|
2023-04-11 23:59:53 +02:00
|
|
|
dark_theme_dimming));
|
2020-08-24 22:38:45 +02:00
|
|
|
} else if (op == "gcos") {
|
|
|
|
send_request(td_api::make_object<td_api::getCountries>());
|
2020-08-25 12:42:14 +02:00
|
|
|
} else if (op == "gcoc") {
|
|
|
|
send_request(td_api::make_object<td_api::getCountryCode>());
|
|
|
|
} else if (op == "gpni") {
|
|
|
|
send_request(td_api::make_object<td_api::getPhoneNumberInfo>(args));
|
2021-08-30 21:26:02 +02:00
|
|
|
} else if (op == "gpnis") {
|
|
|
|
execute(td_api::make_object<td_api::getPhoneNumberInfoSync>(rand_bool() ? "en" : "", args));
|
2021-06-04 18:31:18 +02:00
|
|
|
} else if (op == "gadl") {
|
|
|
|
send_request(td_api::make_object<td_api::getApplicationDownloadLink>());
|
2022-05-24 01:55:03 +02:00
|
|
|
} else if (op == "gprl") {
|
2023-04-03 16:28:51 +02:00
|
|
|
auto limit_type = td_api::make_object<td_api::premiumLimitTypeChatFolderCount>();
|
2022-05-24 01:55:03 +02:00
|
|
|
send_request(td_api::make_object<td_api::getPremiumLimit>(std::move(limit_type)));
|
|
|
|
} else if (op == "gprf") {
|
2022-05-24 14:42:46 +02:00
|
|
|
auto source = td_api::make_object<td_api::premiumSourceLimitExceeded>(
|
2023-04-03 16:28:51 +02:00
|
|
|
td_api::make_object<td_api::premiumLimitTypeChatFolderCount>());
|
2022-05-24 01:19:30 +02:00
|
|
|
send_request(td_api::make_object<td_api::getPremiumFeatures>(std::move(source)));
|
2022-08-01 14:42:02 +02:00
|
|
|
} else if (op == "gprse") {
|
|
|
|
send_request(td_api::make_object<td_api::getPremiumStickerExamples>());
|
2022-05-24 19:45:03 +02:00
|
|
|
} else if (op == "vprf") {
|
|
|
|
auto feature = td_api::make_object<td_api::premiumFeatureProfileBadge>();
|
|
|
|
send_request(td_api::make_object<td_api::viewPremiumFeature>(std::move(feature)));
|
2022-05-25 14:34:36 +02:00
|
|
|
} else if (op == "cprsb") {
|
|
|
|
send_request(td_api::make_object<td_api::clickPremiumSubscriptionButton>());
|
2022-06-01 14:14:09 +02:00
|
|
|
} else if (op == "gprs") {
|
|
|
|
send_request(td_api::make_object<td_api::getPremiumState>());
|
2022-06-24 16:07:10 +02:00
|
|
|
} else if (op == "cppr") {
|
2022-12-21 16:06:08 +01:00
|
|
|
UserId user_id;
|
|
|
|
string currency;
|
|
|
|
int64 amount;
|
|
|
|
get_args(args, user_id, currency, amount);
|
|
|
|
if (currency.empty()) {
|
|
|
|
send_request(td_api::make_object<td_api::canPurchasePremium>(
|
2023-01-19 14:49:57 +01:00
|
|
|
td_api::make_object<td_api::storePaymentPurposePremiumSubscription>(false, false)));
|
2022-12-21 16:06:08 +01:00
|
|
|
} else {
|
|
|
|
send_request(td_api::make_object<td_api::canPurchasePremium>(
|
|
|
|
td_api::make_object<td_api::storePaymentPurposeGiftedPremium>(user_id, currency, amount)));
|
|
|
|
}
|
2018-06-07 20:42:17 +02:00
|
|
|
} else if (op == "atos") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::acceptTermsOfService>(args));
|
2018-04-12 22:51:42 +02:00
|
|
|
} else if (op == "gdli") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getDeepLinkInfo>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "tme") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getRecentlyVisitedTMeUrls>(args));
|
2020-10-18 01:10:58 +02:00
|
|
|
} else if (op == "gbms") {
|
2023-07-28 16:52:44 +02:00
|
|
|
string block_list;
|
2020-12-26 17:40:46 +01:00
|
|
|
int32 offset;
|
2018-12-31 20:04:05 +01:00
|
|
|
string limit;
|
2023-07-28 16:52:44 +02:00
|
|
|
get_args(args, block_list, offset, limit);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::getBlockedMessageSenders>(as_block_list(block_list), offset, as_limit(limit)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gu") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
|
|
|
get_args(args, user_id);
|
|
|
|
send_request(td_api::make_object<td_api::getUser>(user_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gsu") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSupportUser>());
|
2022-08-05 13:06:06 +02:00
|
|
|
} else if (op == "gs" || op == "gsmm" || op == "gsee" || op == "gseeme") {
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, query);
|
2022-08-05 13:06:06 +02:00
|
|
|
send_request(td_api::make_object<td_api::getStickers>(as_sticker_type(op), query.query, query.limit,
|
|
|
|
op == "gseeme" ? my_id_ : 0));
|
2023-01-23 19:07:42 +01:00
|
|
|
} else if (op == "sst" || op == "sstm" || op == "sste") {
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, query);
|
2023-01-23 19:07:42 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchStickers>(as_sticker_type(op), query.query, query.limit));
|
2022-08-01 18:21:08 +02:00
|
|
|
} else if (op == "gprst") {
|
|
|
|
string limit;
|
|
|
|
get_args(args, limit);
|
|
|
|
send_request(td_api::make_object<td_api::getPremiumStickers>(as_limit(limit)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gss") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int64 sticker_set_id;
|
|
|
|
get_args(args, sticker_set_id);
|
|
|
|
send_request(td_api::make_object<td_api::getStickerSet>(sticker_set_id));
|
2022-07-14 15:42:27 +02:00
|
|
|
} else if (op == "giss" || op == "gissm" || op == "gisse") {
|
2022-07-24 13:53:48 +02:00
|
|
|
send_request(td_api::make_object<td_api::getInstalledStickerSets>(as_sticker_type(op)));
|
2022-07-14 15:42:27 +02:00
|
|
|
} else if (op == "gass" || op == "gassm" || op == "gasse") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int64 offset_sticker_set_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string limit;
|
2022-07-14 15:17:19 +02:00
|
|
|
get_args(args, offset_sticker_set_id, limit);
|
|
|
|
send_request(td_api::make_object<td_api::getArchivedStickerSets>(as_sticker_type(op), offset_sticker_set_id,
|
|
|
|
as_limit(limit)));
|
2022-07-17 21:39:22 +02:00
|
|
|
} else if (op == "gtss" || op == "gtssm" || op == "gtsse") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 offset;
|
2020-04-18 00:55:54 +02:00
|
|
|
string limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, offset, limit);
|
2022-07-17 21:39:22 +02:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::getTrendingStickerSets>(as_sticker_type(op), offset, as_limit(limit, 1000)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gatss") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
|
|
|
get_args(args, file_id);
|
|
|
|
send_request(td_api::make_object<td_api::getAttachedStickerSets>(file_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "storage") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int32 chat_limit;
|
|
|
|
get_args(args, chat_limit);
|
|
|
|
send_request(td_api::make_object<td_api::getStorageStatistics>(chat_limit));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "storage_fast") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getStorageStatisticsFast>());
|
2019-04-17 11:17:51 +02:00
|
|
|
} else if (op == "database") {
|
|
|
|
send_request(td_api::make_object<td_api::getDatabaseStatistics>());
|
2020-03-02 09:59:47 +01:00
|
|
|
} else if (op == "optimize_storage" || op == "optimize_storage_all") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string chat_ids;
|
|
|
|
string exclude_chat_ids;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 chat_ids_limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_ids, exclude_chat_ids, chat_ids_limit);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::optimizeStorage>(
|
2019-12-18 16:09:32 +01:00
|
|
|
10000000, -1, -1, 0, std::vector<td_api::object_ptr<td_api::FileType>>(), as_chat_ids(chat_ids),
|
2020-12-26 18:26:19 +01:00
|
|
|
as_chat_ids(exclude_chat_ids), op == "optimize_storage", chat_ids_limit));
|
2018-01-26 14:01:40 +01:00
|
|
|
} else if (op == "clean_storage_default") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::optimizeStorage>());
|
2018-05-30 21:45:42 +02:00
|
|
|
} else if (op == "clean_photos") {
|
2019-12-03 02:36:23 +01:00
|
|
|
std::vector<td_api::object_ptr<td_api::FileType>> types;
|
2021-10-19 17:11:16 +02:00
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypePhoto>());
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::optimizeStorage>(0, 0, 0, 0, std::move(types), as_chat_ids(""),
|
2020-03-02 09:59:47 +01:00
|
|
|
as_chat_ids(""), true, 20));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "clean_storage") {
|
2019-12-03 02:36:23 +01:00
|
|
|
std::vector<td_api::object_ptr<td_api::FileType>> types;
|
2021-10-19 17:11:16 +02:00
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeThumbnail>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeProfilePhoto>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypePhoto>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeVoiceNote>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeVideo>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeDocument>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeSecret>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeUnknown>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeSticker>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeAudio>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeAnimation>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeVideoNote>());
|
|
|
|
types.emplace_back(td_api::make_object<td_api::fileTypeSecure>());
|
2019-12-18 16:09:32 +01:00
|
|
|
send_request(td_api::make_object<td_api::optimizeStorage>(0, -1, -1, 0, std::move(types), as_chat_ids(args),
|
2020-03-02 09:59:47 +01:00
|
|
|
as_chat_ids(""), true, 20));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "network") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getNetworkStatistics>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "current_network") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getNetworkStatistics>(true));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "reset_network") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::resetNetworkStatistics>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "snt") {
|
2022-10-12 14:03:47 +02:00
|
|
|
send_request(td_api::make_object<td_api::setNetworkType>(as_network_type(args)));
|
2019-05-14 01:03:05 +02:00
|
|
|
} else if (op == "gadsp") {
|
|
|
|
send_request(td_api::make_object<td_api::getAutoDownloadSettingsPresets>());
|
|
|
|
} else if (op == "sads") {
|
|
|
|
send_request(td_api::make_object<td_api::setAutoDownloadSettings>(
|
2022-10-12 14:03:47 +02:00
|
|
|
td_api::make_object<td_api::autoDownloadSettings>(), as_network_type(args)));
|
2023-02-03 10:39:23 +01:00
|
|
|
} else if (op == "gaus") {
|
|
|
|
send_request(td_api::make_object<td_api::getAutosaveSettings>());
|
2023-02-03 13:58:15 +01:00
|
|
|
} else if (op == "saus") {
|
|
|
|
string scope_str;
|
|
|
|
bool autosave_photos;
|
|
|
|
bool autosave_videos;
|
|
|
|
int64 max_video_file_size;
|
|
|
|
get_args(args, scope_str, autosave_photos, autosave_videos, max_video_file_size);
|
|
|
|
auto scope = [&]() -> td_api::object_ptr<td_api::AutosaveSettingsScope> {
|
|
|
|
if (scope_str == "users") {
|
|
|
|
return td_api::make_object<td_api::autosaveSettingsScopePrivateChats>();
|
|
|
|
}
|
|
|
|
if (scope_str == "groups") {
|
|
|
|
return td_api::make_object<td_api::autosaveSettingsScopeGroupChats>();
|
|
|
|
}
|
|
|
|
if (scope_str == "channels") {
|
|
|
|
return td_api::make_object<td_api::autosaveSettingsScopeChannelChats>();
|
|
|
|
}
|
|
|
|
auto chat_id = as_chat_id(scope_str);
|
|
|
|
if (chat_id != 0) {
|
|
|
|
return td_api::make_object<td_api::autosaveSettingsScopeChat>(chat_id);
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}();
|
|
|
|
send_request(td_api::make_object<td_api::setAutosaveSettings>(
|
|
|
|
std::move(scope),
|
|
|
|
td_api::make_object<td_api::scopeAutosaveSettings>(autosave_photos, autosave_videos, max_video_file_size)));
|
2023-02-03 11:07:43 +01:00
|
|
|
} else if (op == "cause") {
|
|
|
|
send_request(td_api::make_object<td_api::clearAutosaveSettingsExceptions>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ansc") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 sent_bytes;
|
|
|
|
int32 received_bytes;
|
2018-12-31 20:04:05 +01:00
|
|
|
string duration;
|
|
|
|
string network_type;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, sent_bytes, received_bytes, duration, network_type);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::addNetworkStatistics>(td_api::make_object<td_api::networkStatisticsEntryCall>(
|
2022-10-12 14:03:47 +02:00
|
|
|
as_network_type(network_type), sent_bytes, received_bytes, to_double(duration))));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ans") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 sent_bytes;
|
|
|
|
int32 received_bytes;
|
2018-12-31 20:04:05 +01:00
|
|
|
string network_type;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, sent_bytes, received_bytes, network_type);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::addNetworkStatistics>(td_api::make_object<td_api::networkStatisticsEntryFile>(
|
2022-10-12 14:03:47 +02:00
|
|
|
td_api::make_object<td_api::fileTypeDocument>(), as_network_type(network_type), sent_bytes,
|
2020-12-26 18:26:19 +01:00
|
|
|
received_bytes)));
|
2021-09-24 22:17:38 +02:00
|
|
|
} else if (op == "gtc") {
|
2022-10-12 14:03:47 +02:00
|
|
|
send_request(td_api::make_object<td_api::getTopChats>(as_top_chat_category(args), 50));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rtc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string category;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, category);
|
2022-10-12 14:03:47 +02:00
|
|
|
send_request(td_api::make_object<td_api::removeTopChat>(as_top_chat_category(category), chat_id));
|
2021-06-17 19:38:03 +02:00
|
|
|
} else if (op == "gsssn") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &title = args;
|
2021-06-17 19:38:03 +02:00
|
|
|
send_request(td_api::make_object<td_api::getSuggestedStickerSetName>(title));
|
2021-06-17 20:29:07 +02:00
|
|
|
} else if (op == "cssn") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &name = args;
|
2021-06-17 20:29:07 +02:00
|
|
|
send_request(td_api::make_object<td_api::checkStickerSetName>(name));
|
2022-07-21 16:31:27 +02:00
|
|
|
} else if (op == "usf" || op == "usfa" || op == "usfv") {
|
2023-02-09 14:05:26 +01:00
|
|
|
send_request(td_api::make_object<td_api::uploadStickerFile>(-1, as_sticker_format(op), as_input_file(args)));
|
2022-07-14 15:42:27 +02:00
|
|
|
} else if (op == "cnss" || op == "cnssa" || op == "cnssv" || op == "cnssm" || op == "cnsse") {
|
2021-06-17 19:14:48 +02:00
|
|
|
string title;
|
|
|
|
string name;
|
|
|
|
string stickers;
|
|
|
|
get_args(args, title, name, stickers);
|
|
|
|
auto input_stickers =
|
2022-01-25 14:56:10 +01:00
|
|
|
transform(autosplit(stickers), [op](Slice sticker) -> td_api::object_ptr<td_api::inputSticker> {
|
2023-02-14 12:59:03 +01:00
|
|
|
return td_api::make_object<td_api::inputSticker>(as_input_file(sticker), "😀", as_mask_position(op),
|
|
|
|
vector<string>{"keyword"});
|
2022-01-24 15:40:16 +01:00
|
|
|
});
|
2023-02-14 12:59:03 +01:00
|
|
|
send_request(td_api::make_object<td_api::createNewStickerSet>(
|
|
|
|
my_id_, title, name, as_sticker_format(op), as_sticker_type(op), false, std::move(input_stickers), "tg_cli"));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sss") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchStickerSet>(args));
|
2018-03-05 23:44:11 +01:00
|
|
|
} else if (op == "siss") {
|
2022-07-14 15:17:19 +02:00
|
|
|
send_request(td_api::make_object<td_api::searchInstalledStickerSets>(nullptr, args, 2));
|
2018-03-05 23:44:11 +01:00
|
|
|
} else if (op == "ssss") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchStickerSets>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "css") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int64 set_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_installed;
|
|
|
|
bool is_archived;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, set_id, is_installed, is_archived);
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(td_api::make_object<td_api::changeStickerSet>(set_id, is_installed, is_archived));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "vtss") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::viewTrendingStickerSets>(to_integers<int64>(args)));
|
2022-07-14 15:42:27 +02:00
|
|
|
} else if (op == "riss" || op == "rissm" || op == "risse") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string new_order;
|
2022-07-14 15:17:19 +02:00
|
|
|
get_args(args, new_order);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::reorderInstalledStickerSets>(as_sticker_type(op), to_integers<int64>(new_order)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "grs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getRecentStickers>(as_bool(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ars") {
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_attached;
|
2018-12-31 20:04:05 +01:00
|
|
|
string sticker_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, is_attached, sticker_id);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(td_api::make_object<td_api::addRecentSticker>(is_attached, as_input_file_id(sticker_id)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rrs") {
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_attached;
|
2018-12-31 20:04:05 +01:00
|
|
|
string sticker_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, is_attached, sticker_id);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeRecentSticker>(is_attached, as_input_file_id(sticker_id)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gfs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getFavoriteStickers>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "afs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::addFavoriteSticker>(as_input_file_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rfs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeFavoriteSticker>(as_input_file_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "crs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::clearRecentStickers>(as_bool(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gse") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getStickerEmojis>(as_input_file_id(args)));
|
2019-05-21 17:48:35 +02:00
|
|
|
} else if (op == "se") {
|
2020-04-22 14:17:53 +02:00
|
|
|
send_request(td_api::make_object<td_api::searchEmojis>(args, false, vector<string>()));
|
2019-05-21 17:48:35 +02:00
|
|
|
} else if (op == "see") {
|
2020-04-22 14:17:53 +02:00
|
|
|
send_request(td_api::make_object<td_api::searchEmojis>(args, true, vector<string>()));
|
2020-01-08 17:07:40 +01:00
|
|
|
} else if (op == "seru") {
|
2020-04-22 14:17:53 +02:00
|
|
|
send_request(td_api::make_object<td_api::searchEmojis>(args, false, vector<string>{"ru_RU"}));
|
2023-01-27 13:16:40 +01:00
|
|
|
} else if (op == "gec" || op == "geces" || op == "geccp") {
|
|
|
|
auto type = [&]() -> td_api::object_ptr<td_api::EmojiCategoryType> {
|
|
|
|
if (op == "geces") {
|
|
|
|
return td_api::make_object<td_api::emojiCategoryTypeEmojiStatus>();
|
|
|
|
}
|
|
|
|
if (op == "geccp") {
|
|
|
|
return td_api::make_object<td_api::emojiCategoryTypeChatPhoto>();
|
|
|
|
}
|
|
|
|
return td_api::make_object<td_api::emojiCategoryTypeDefault>();
|
|
|
|
}();
|
2023-01-24 19:38:53 +01:00
|
|
|
send_request(td_api::make_object<td_api::getEmojiCategories>(std::move(type)));
|
2021-10-26 16:59:15 +02:00
|
|
|
} else if (op == "gae") {
|
|
|
|
send_request(td_api::make_object<td_api::getAnimatedEmoji>(args));
|
2019-05-21 21:44:13 +02:00
|
|
|
} else if (op == "gesu") {
|
|
|
|
send_request(td_api::make_object<td_api::getEmojiSuggestionsUrl>(args));
|
2022-07-19 15:00:04 +02:00
|
|
|
} else if (op == "gces") {
|
|
|
|
send_request(td_api::make_object<td_api::getCustomEmojiStickers>(to_integers<int64>(args)));
|
2023-01-10 13:23:07 +01:00
|
|
|
} else if (op == "gdcpces") {
|
|
|
|
send_request(td_api::make_object<td_api::getDefaultChatPhotoCustomEmojiStickers>());
|
2023-01-10 13:40:52 +01:00
|
|
|
} else if (op == "gdppces") {
|
|
|
|
send_request(td_api::make_object<td_api::getDefaultProfilePhotoCustomEmojiStickers>());
|
2021-12-04 23:00:28 +01:00
|
|
|
} else if (op == "gsan") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSavedAnimations>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "asan") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::addSavedAnimation>(as_input_file_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rsan") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeSavedAnimation>(as_input_file_id(args)));
|
2021-12-04 23:00:28 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op == "guf") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
|
|
|
get_args(args, user_id);
|
|
|
|
send_request(td_api::make_object<td_api::getUserFullInfo>(user_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gbg") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getBasicGroup>(as_basic_group_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gbgf") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getBasicGroupFullInfo>(as_basic_group_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gsg" || op == "gch") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSupergroup>(as_supergroup_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gsgf" || op == "gchf") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSupergroupFullInfo>(as_supergroup_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gsc") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSecretChat>(as_secret_chat_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "scm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-07-20 02:00:17 +02:00
|
|
|
string filter;
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, chat_id, filter, query);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchChatMembers>(chat_id, query.query, query.limit,
|
2022-10-12 14:03:47 +02:00
|
|
|
as_chat_members_filter(filter)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gcm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-03-24 21:40:13 +01:00
|
|
|
string member_id;
|
|
|
|
get_args(args, chat_id, member_id);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatMember>(chat_id, as_message_sender(member_id)));
|
2019-03-18 03:36:47 +01:00
|
|
|
} else if (op == "GetChatAdministrators") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatAdministrators>(chat_id));
|
2019-03-18 03:45:36 +01:00
|
|
|
} else if (op == "GetSupergroupAdministrators" || op == "GetSupergroupBanned" || op == "GetSupergroupBots" ||
|
2019-03-18 20:22:50 +01:00
|
|
|
op == "GetSupergroupContacts" || op == "GetSupergroupMembers" || op == "GetSupergroupRestricted" ||
|
2020-10-19 00:33:31 +02:00
|
|
|
op == "SearchSupergroupMembers" || op == "SearchSupergroupMentions") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string supergroup_id;
|
2020-10-19 00:33:31 +02:00
|
|
|
string message_thread_id;
|
2020-12-26 18:58:30 +01:00
|
|
|
int32 offset;
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
2020-10-19 00:33:31 +02:00
|
|
|
if (op == "SearchSupergroupMentions") {
|
2020-12-26 18:58:30 +01:00
|
|
|
get_args(args, message_thread_id, args);
|
2020-10-19 00:33:31 +02:00
|
|
|
}
|
2020-12-26 18:58:30 +01:00
|
|
|
get_args(args, supergroup_id, offset, query);
|
2020-12-26 19:45:19 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSupergroupMembers>(
|
2022-10-12 14:03:47 +02:00
|
|
|
as_supergroup_id(supergroup_id), as_supergroup_members_filter(op, query.query, message_thread_id), offset,
|
2020-12-26 19:45:19 +01:00
|
|
|
query.limit));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gdialog" || op == "gd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChat>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "open") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
2021-11-28 09:49:46 +01:00
|
|
|
send_request(td_api::make_object<td_api::openChat>(chat_id));
|
2021-12-31 12:20:34 +01:00
|
|
|
opened_chat_id_ = chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "close") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::closeChat>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessage>(chat_id, message_id));
|
2019-03-05 00:06:48 +01:00
|
|
|
} else if (op == "gmf") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
int64 from_message_id;
|
|
|
|
int64 to_message_id;
|
|
|
|
get_args(args, chat_id, from_message_id, to_message_id);
|
|
|
|
for (auto message_id = from_message_id; message_id <= to_message_id; message_id++) {
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessage>(chat_id, message_id << 20));
|
2019-03-05 00:06:48 +01:00
|
|
|
}
|
2019-01-09 03:57:43 +01:00
|
|
|
} else if (op == "gml") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessageLocally>(chat_id, message_id));
|
2018-02-07 00:31:38 +01:00
|
|
|
} else if (op == "grm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getRepliedMessage>(chat_id, message_id));
|
2020-09-22 16:27:35 +02:00
|
|
|
} else if (op == "gmt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessageThread>(chat_id, message_id));
|
2021-09-03 15:14:03 +02:00
|
|
|
} else if (op == "gmv") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2021-09-03 15:14:03 +02:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessageViewers>(chat_id, message_id));
|
2018-02-07 00:31:38 +01:00
|
|
|
} else if (op == "gcpm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatPinnedMessage>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gms") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string message_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_ids);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessages>(chat_id, as_message_ids(message_ids)));
|
2022-07-24 13:53:48 +02:00
|
|
|
} else if (op == "gcspm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
2022-10-21 14:04:56 +02:00
|
|
|
send_request(td_api::make_object<td_api::getChatSponsoredMessages>(chat_id));
|
2023-05-04 16:21:50 +02:00
|
|
|
} else if (op == "ccspm") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
get_args(args, chat_id, message_id);
|
|
|
|
send_request(td_api::make_object<td_api::clickChatSponsoredMessage>(chat_id, message_id));
|
2019-04-08 03:50:26 +02:00
|
|
|
} else if (op == "gmlink") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2021-07-26 03:01:10 +02:00
|
|
|
int32 media_timestamp;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool for_album;
|
|
|
|
bool for_comment;
|
2021-07-26 03:01:10 +02:00
|
|
|
get_args(args, chat_id, message_id, media_timestamp, for_album, for_comment);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::getMessageLink>(chat_id, message_id, media_timestamp, for_album, for_comment));
|
2020-09-20 17:17:47 +02:00
|
|
|
} else if (op == "gmec") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool for_album;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, for_album);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessageEmbeddingCode>(chat_id, message_id, for_album));
|
2019-08-05 11:12:59 +02:00
|
|
|
} else if (op == "gmli") {
|
|
|
|
send_request(td_api::make_object<td_api::getMessageLinkInfo>(args));
|
2022-01-29 21:43:57 +01:00
|
|
|
} else if (op == "tt") {
|
|
|
|
string text;
|
2022-01-14 20:28:28 +01:00
|
|
|
string to_language_code;
|
2023-01-18 14:34:49 +01:00
|
|
|
get_args(args, to_language_code, text);
|
|
|
|
send_request(td_api::make_object<td_api::translateText>(as_formatted_text(text), to_language_code));
|
2023-01-23 13:46:26 +01:00
|
|
|
} else if (op == "tmt") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
string to_language_code;
|
|
|
|
get_args(args, chat_id, message_id, to_language_code);
|
|
|
|
send_request(td_api::make_object<td_api::translateMessageText>(chat_id, message_id, to_language_code));
|
2022-05-25 20:18:40 +02:00
|
|
|
} else if (op == "rs") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
get_args(args, chat_id, message_id);
|
|
|
|
send_request(td_api::make_object<td_api::recognizeSpeech>(chat_id, message_id));
|
2022-05-26 19:40:43 +02:00
|
|
|
} else if (op == "rsr") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
bool is_good;
|
|
|
|
get_args(args, chat_id, message_id, is_good);
|
|
|
|
send_request(td_api::make_object<td_api::rateSpeechRecognition>(chat_id, message_id, is_good));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gf" || op == "GetFile") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
|
|
|
get_args(args, file_id);
|
|
|
|
send_request(td_api::make_object<td_api::getFile>(file_id));
|
2018-12-26 17:11:15 +01:00
|
|
|
} else if (op == "gfdps") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2022-05-11 16:17:20 +02:00
|
|
|
int64 offset;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, file_id, offset);
|
2022-02-19 00:42:18 +01:00
|
|
|
send_request(td_api::make_object<td_api::getFileDownloadedPrefixSize>(file_id, offset));
|
2019-04-26 00:03:31 +02:00
|
|
|
} else if (op == "rfp") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2022-05-11 16:17:20 +02:00
|
|
|
int64 offset;
|
|
|
|
int64 count;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, file_id, offset, count);
|
2022-02-19 00:42:18 +01:00
|
|
|
send_request(td_api::make_object<td_api::readFilePart>(file_id, offset, count));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "grf") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getRemoteFile>(args, nullptr));
|
2018-08-13 22:18:27 +02:00
|
|
|
} else if (op == "gmtf") {
|
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 zoom;
|
|
|
|
int32 width;
|
|
|
|
int32 height;
|
|
|
|
int32 scale;
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, latitude, longitude, zoom, width, height, scale, chat_id);
|
2021-10-19 17:11:16 +02:00
|
|
|
send_request(td_api::make_object<td_api::getMapThumbnailFile>(as_location(latitude, longitude, string()), zoom,
|
2021-12-31 12:20:34 +01:00
|
|
|
width, height, scale, chat_id));
|
2019-03-27 19:43:46 +01:00
|
|
|
} else if (op == "df" || op == "DownloadFile" || op == "dff" || op == "dfs") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2022-05-11 16:17:20 +02:00
|
|
|
int64 offset;
|
|
|
|
int64 limit;
|
2021-12-31 08:25:40 +01:00
|
|
|
int32 priority;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, file_id, offset, limit, priority);
|
2020-12-26 18:26:19 +01:00
|
|
|
if (priority <= 0) {
|
|
|
|
priority = 1;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2022-02-19 00:42:18 +01:00
|
|
|
int32 max_file_id = file_id.file_id;
|
2019-02-21 17:45:42 +01:00
|
|
|
int32 min_file_id = (op == "dff" ? 1 : max_file_id);
|
|
|
|
for (int32 i = min_file_id; i <= max_file_id; i++) {
|
2021-12-31 08:25:40 +01:00
|
|
|
send_request(td_api::make_object<td_api::downloadFile>(i, priority, offset, limit, op == "dfs"));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
} else if (op == "cdf") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
|
|
|
get_args(args, file_id);
|
|
|
|
send_request(td_api::make_object<td_api::cancelDownloadFile>(file_id, false));
|
2021-07-24 06:19:22 +02:00
|
|
|
} else if (op == "gsfn") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2021-07-24 06:19:22 +02:00
|
|
|
string directory_name;
|
|
|
|
get_args(args, file_id, directory_name);
|
2022-02-19 00:42:18 +01:00
|
|
|
send_request(td_api::make_object<td_api::getSuggestedFileName>(file_id, directory_name));
|
2018-04-27 10:00:56 +02:00
|
|
|
} else if (op == "uf" || op == "ufs" || op == "ufse") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string file_path;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 priority;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, file_path, priority);
|
2020-12-26 18:26:19 +01:00
|
|
|
if (priority <= 0) {
|
|
|
|
priority = 1;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
td_api::object_ptr<td_api::FileType> type = td_api::make_object<td_api::fileTypePhoto>();
|
2018-04-26 22:41:34 +02:00
|
|
|
if (op == "ufs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
type = td_api::make_object<td_api::fileTypeSecret>();
|
2018-04-26 22:41:34 +02:00
|
|
|
}
|
|
|
|
if (op == "ufse") {
|
2019-02-21 17:48:05 +01:00
|
|
|
type = td_api::make_object<td_api::fileTypeSecure>();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2022-07-18 13:07:50 +02:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::preliminaryUploadFile>(as_input_file(file_path), std::move(type), priority));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ufg") {
|
|
|
|
string file_path;
|
|
|
|
string conversion;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, file_path, conversion);
|
2022-07-18 13:07:50 +02:00
|
|
|
send_request(td_api::make_object<td_api::preliminaryUploadFile>(as_generated_file(file_path, conversion),
|
|
|
|
td_api::make_object<td_api::fileTypePhoto>(), 1));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cuf") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
|
|
|
get_args(args, file_id);
|
2022-07-18 13:07:50 +02:00
|
|
|
send_request(td_api::make_object<td_api::cancelPreliminaryUploadFile>(file_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "delf" || op == "DeleteFile") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
|
|
|
get_args(args, file_id);
|
|
|
|
send_request(td_api::make_object<td_api::deleteFile>(file_id));
|
2022-02-17 23:37:04 +01:00
|
|
|
} else if (op == "aftd") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2022-02-17 23:37:04 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
int32 priority;
|
|
|
|
get_args(args, file_id, chat_id, message_id, priority);
|
2022-02-19 00:42:18 +01:00
|
|
|
send_request(td_api::make_object<td_api::addFileToDownloads>(file_id, chat_id, message_id, max(priority, 1)));
|
2022-02-17 23:37:04 +01:00
|
|
|
} else if (op == "tdip") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2022-02-17 23:37:04 +01:00
|
|
|
bool is_paused;
|
|
|
|
get_args(args, file_id, is_paused);
|
2022-02-19 00:42:18 +01:00
|
|
|
send_request(td_api::make_object<td_api::toggleDownloadIsPaused>(file_id, is_paused));
|
2022-02-17 23:37:04 +01:00
|
|
|
} else if (op == "tadap") {
|
|
|
|
bool are_paused;
|
|
|
|
get_args(args, are_paused);
|
|
|
|
send_request(td_api::make_object<td_api::toggleAllDownloadsArePaused>(are_paused));
|
|
|
|
} else if (op == "rffd") {
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2022-02-17 23:37:04 +01:00
|
|
|
bool delete_from_cache;
|
|
|
|
get_args(args, file_id, delete_from_cache);
|
2022-02-19 00:42:18 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeFileFromDownloads>(file_id, delete_from_cache));
|
2022-02-17 23:37:04 +01:00
|
|
|
} else if (op == "raffd" || op == "raffda" || op == "raffdc") {
|
|
|
|
bool delete_from_cache;
|
|
|
|
get_args(args, delete_from_cache);
|
|
|
|
send_request(td_api::make_object<td_api::removeAllFilesFromDownloads>(op.back() == 'a', op.back() == 'c',
|
|
|
|
delete_from_cache));
|
|
|
|
} else if (op == "sfd" || op == "sfda" || op == "sfdc") {
|
|
|
|
string offset;
|
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, offset, query);
|
|
|
|
send_request(td_api::make_object<td_api::searchFileDownloads>(query.query, op.back() == 'a', op.back() == 'c',
|
|
|
|
offset, query.limit));
|
2020-09-13 00:31:08 +02:00
|
|
|
} else if (op == "dm" || op == "dmr") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-03-02 17:21:43 +01:00
|
|
|
string message_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_ids);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteMessages>(chat_id, as_message_ids(message_ids), op == "dmr"));
|
2021-08-31 22:37:21 +02:00
|
|
|
} else if (op == "fm" || op == "cm" || op == "fmp" || op == "cmp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
ChatId from_chat_id;
|
2018-03-02 17:21:43 +01:00
|
|
|
string message_ids;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2022-10-21 17:02:39 +02:00
|
|
|
get_args(args, chat_id, from_chat_id, message_ids, message_thread_id);
|
|
|
|
send_request(td_api::make_object<td_api::forwardMessages>(
|
2022-10-27 13:19:04 +02:00
|
|
|
chat_id, message_thread_id, from_chat_id, as_message_ids(message_ids), default_message_send_options(),
|
|
|
|
op[0] == 'c', rand_bool(), op.back() == 'p'));
|
2019-08-15 17:36:27 +02:00
|
|
|
} else if (op == "resend") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2019-08-15 17:36:27 +02:00
|
|
|
string message_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_ids);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::resendMessages>(chat_id, as_message_ids(message_ids)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "csc" || op == "CreateSecretChat") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::createSecretChat>(as_secret_chat_id(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cnsc" || op == "CreateNewSecretChat") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
|
|
|
get_args(args, user_id);
|
|
|
|
send_request(td_api::make_object<td_api::createNewSecretChat>(user_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "closeSC" || op == "cancelSC") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::closeSecretChat>(as_secret_chat_id(args)));
|
2021-12-04 23:00:28 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op == "cc" || op == "CreateCall") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
|
|
|
get_args(args, user_id);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::createCall>(
|
2021-12-31 12:56:57 +01:00
|
|
|
user_id, td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6", "3.0"}),
|
2020-12-26 19:01:57 +01:00
|
|
|
rand_bool()));
|
2020-08-10 10:34:28 +02:00
|
|
|
} else if (op == "ac" || op == "AcceptCall") {
|
2022-04-22 13:44:53 +02:00
|
|
|
CallId call_id;
|
|
|
|
get_args(args, call_id);
|
2020-08-10 10:34:28 +02:00
|
|
|
send_request(td_api::make_object<td_api::acceptCall>(
|
2022-04-22 13:44:53 +02:00
|
|
|
call_id, td_api::make_object<td_api::callProtocol>(true, true, 65, 65, vector<string>{"2.6", "3.0"})));
|
2020-08-10 10:34:28 +02:00
|
|
|
} else if (op == "scsd") {
|
2022-04-22 13:44:53 +02:00
|
|
|
CallId call_id;
|
|
|
|
get_args(args, call_id);
|
|
|
|
send_request(td_api::make_object<td_api::sendCallSignalingData>(call_id, "abacaba"));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "dc" || op == "DiscardCall") {
|
2022-04-22 13:44:53 +02:00
|
|
|
CallId call_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_disconnected;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, call_id, is_disconnected);
|
2022-04-22 13:44:53 +02:00
|
|
|
send_request(td_api::make_object<td_api::discardCall>(call_id, is_disconnected, 0, rand_bool(), 0));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "scr" || op == "SendCallRating") {
|
2022-04-22 13:44:53 +02:00
|
|
|
CallId call_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 rating;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, call_id, rating);
|
2019-08-06 19:07:23 +02:00
|
|
|
vector<td_api::object_ptr<td_api::CallProblem>> problems;
|
2019-08-18 14:24:51 +02:00
|
|
|
problems.emplace_back(td_api::make_object<td_api::callProblemNoise>());
|
|
|
|
problems.emplace_back(td_api::make_object<td_api::callProblemNoise>());
|
2020-08-21 19:53:39 +02:00
|
|
|
problems.emplace_back(td_api::make_object<td_api::callProblemDistortedVideo>());
|
2019-08-06 19:07:23 +02:00
|
|
|
problems.emplace_back(nullptr);
|
2019-08-18 14:24:51 +02:00
|
|
|
problems.emplace_back(td_api::make_object<td_api::callProblemNoise>());
|
2019-08-06 19:07:23 +02:00
|
|
|
problems.emplace_back(td_api::make_object<td_api::callProblemEcho>());
|
2020-08-21 19:53:39 +02:00
|
|
|
problems.emplace_back(td_api::make_object<td_api::callProblemPixelatedVideo>());
|
2019-08-06 19:07:23 +02:00
|
|
|
problems.emplace_back(td_api::make_object<td_api::callProblemDistortedSpeech>());
|
2022-04-22 13:44:53 +02:00
|
|
|
send_request(td_api::make_object<td_api::sendCallRating>(call_id, rating, "Wow, such good call! (TDLib test)",
|
|
|
|
std::move(problems)));
|
2022-04-22 14:16:09 +02:00
|
|
|
} else if (op == "scdi") {
|
2022-04-22 13:44:53 +02:00
|
|
|
CallId call_id;
|
|
|
|
get_args(args, call_id);
|
|
|
|
send_request(td_api::make_object<td_api::sendCallDebugInformation>(call_id, "{}"));
|
2022-04-22 14:16:09 +02:00
|
|
|
} else if (op == "sclog") {
|
|
|
|
CallId call_id;
|
|
|
|
string log_file;
|
|
|
|
get_args(args, call_id, log_file);
|
|
|
|
send_request(td_api::make_object<td_api::sendCallLog>(call_id, as_input_file(log_file)));
|
2021-04-07 02:30:26 +02:00
|
|
|
} else if (op == "gvcap") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getVideoChatAvailableParticipants>(chat_id));
|
2021-04-07 15:25:29 +02:00
|
|
|
} else if (op == "svcdp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-04-07 15:25:29 +02:00
|
|
|
string participant_id;
|
2021-04-09 17:50:07 +02:00
|
|
|
get_args(args, chat_id, participant_id);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setVideoChatDefaultParticipant>(chat_id, as_message_sender(participant_id)));
|
2020-12-02 23:08:20 +01:00
|
|
|
} else if (op == "cvc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-04-06 01:13:57 +02:00
|
|
|
string title;
|
2021-04-06 01:54:55 +02:00
|
|
|
int32 start_date;
|
2022-02-22 14:37:11 +01:00
|
|
|
bool is_rtmp_stream;
|
|
|
|
get_args(args, chat_id, title, start_date, is_rtmp_stream);
|
|
|
|
send_request(td_api::make_object<td_api::createVideoChat>(chat_id, title, start_date, is_rtmp_stream));
|
2022-02-25 15:58:03 +01:00
|
|
|
} else if (op == "gvcru") {
|
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getVideoChatRtmpUrl>(chat_id));
|
|
|
|
} else if (op == "rvcru") {
|
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::replaceVideoChatRtmpUrl>(chat_id));
|
2020-12-03 00:00:46 +01:00
|
|
|
} else if (op == "ggc") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(td_api::make_object<td_api::getGroupCall>(group_call_id));
|
2022-02-22 15:42:58 +01:00
|
|
|
} else if (op == "ggcs") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2022-02-22 15:42:58 +01:00
|
|
|
get_args(args, group_call_id);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::getGroupCallStreams>(group_call_id));
|
2021-03-10 20:50:14 +01:00
|
|
|
} else if (op == "ggcss") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-08-23 15:59:00 +02:00
|
|
|
int32 channel_id;
|
|
|
|
get_args(args, group_call_id, channel_id);
|
|
|
|
send_request(td_api::make_object<td_api::getGroupCallStreamSegment>(
|
2022-04-22 13:50:52 +02:00
|
|
|
group_call_id, (std::time(nullptr) - 5) * 1000, 0, channel_id, nullptr));
|
2021-04-07 01:11:14 +02:00
|
|
|
} else if (op == "ssgc") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(td_api::make_object<td_api::startScheduledGroupCall>(group_call_id));
|
2021-04-07 02:04:56 +02:00
|
|
|
} else if (op == "tgcesn" || op == "tgcesne") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::toggleGroupCallEnabledStartNotification>(group_call_id, op == "tgcesne"));
|
2021-04-30 18:53:39 +02:00
|
|
|
} else if (op == "jgc" || op == "jgcv" || op == "sgcss") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-04-07 15:25:29 +02:00
|
|
|
string participant_id;
|
2021-03-12 16:36:55 +01:00
|
|
|
string invite_hash;
|
2021-04-07 15:25:29 +02:00
|
|
|
get_args(args, group_call_id, participant_id, invite_hash);
|
2021-04-30 16:49:00 +02:00
|
|
|
|
|
|
|
auto payload = PSTRING() << "{\"ufrag\":\"ufrag\",\"pwd\":\"pwd\",\"fingerprints\":[{\"hash\":\"hash\",\"setup\":"
|
|
|
|
"\"setup\",\"fingerprint\":\"fingerprint\"},{\"hash\":\"h2\",\"setup\":\"s2\","
|
|
|
|
"\"fingerprint\":\"fingerprint2\"}],\"ssrc\":"
|
|
|
|
<< group_call_source_ << ',';
|
|
|
|
if (op == "jgc") {
|
|
|
|
payload.back() = '}';
|
|
|
|
} else {
|
2021-05-28 17:43:50 +02:00
|
|
|
string sim_sources = "[1,2]";
|
|
|
|
string fid_sources = "[3,4]";
|
2021-06-07 18:35:12 +02:00
|
|
|
if (op == "sgcss") {
|
2021-05-28 17:43:50 +02:00
|
|
|
sim_sources = "[5,6]";
|
|
|
|
fid_sources = "[7,8]";
|
|
|
|
}
|
2021-04-30 16:49:00 +02:00
|
|
|
payload +=
|
|
|
|
"\"payload-types\":[{\"id\":12345,\"name\":\"opus\",\"clockrate\":48000,\"channels\":2,\"rtcp-fbs\":[{"
|
|
|
|
"\"type\":\"transport-cc\",\"subtype\":\"subtype1\"},{\"type\":\"type2\",\"subtype\":\"subtype2\"}],"
|
|
|
|
"\"parameters\":{\"minptime\":\"10\",\"useinbandfec\":\"1\"}}],\"rtp-hdrexts\":[{\"id\":1,\"uri\":\"urn:"
|
2021-05-28 17:43:50 +02:00
|
|
|
"ietf:params:rtp-hdrext:ssrc-audio-level\"}],\"ssrc-groups\":[{\"sources\":" +
|
|
|
|
sim_sources + ",\"semantics\":\"SIM\"},{\"sources\":" + fid_sources + ",\"semantics\":\"FID\"}]}";
|
2021-04-30 16:49:00 +02:00
|
|
|
}
|
2021-04-30 18:53:39 +02:00
|
|
|
if (op == "sgcss") {
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::startGroupCallScreenSharing>(group_call_id, group_call_source_ + 1,
|
|
|
|
std::move(payload)));
|
2021-04-30 18:53:39 +02:00
|
|
|
} else {
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::joinGroupCall>(group_call_id, as_message_sender(participant_id),
|
|
|
|
group_call_source_, std::move(payload), true, true,
|
|
|
|
invite_hash));
|
2021-04-30 18:53:39 +02:00
|
|
|
}
|
2021-06-04 00:17:15 +02:00
|
|
|
} else if (op == "tgcssip") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-06-04 00:17:15 +02:00
|
|
|
bool is_paused;
|
|
|
|
get_args(args, group_call_id, is_paused);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::toggleGroupCallScreenSharingIsPaused>(group_call_id, is_paused));
|
2021-04-30 19:21:07 +02:00
|
|
|
} else if (op == "egcss") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(td_api::make_object<td_api::endGroupCallScreenSharing>(group_call_id));
|
2021-03-02 17:44:57 +01:00
|
|
|
} else if (op == "sgct") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-03-02 17:44:57 +01:00
|
|
|
string title;
|
2021-12-31 12:20:34 +01:00
|
|
|
get_args(args, group_call_id, title);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::setGroupCallTitle>(group_call_id, title));
|
2020-12-08 15:51:37 +01:00
|
|
|
} else if (op == "tgcmnp" || op == "tgcmnpe") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(td_api::make_object<td_api::toggleGroupCallMuteNewParticipants>(group_call_id, op == "tgcmnpe"));
|
2021-03-12 17:31:52 +01:00
|
|
|
} else if (op == "rgcil") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(td_api::make_object<td_api::revokeGroupCallInviteLink>(group_call_id));
|
2021-06-01 19:11:18 +02:00
|
|
|
} else if (op == "tgcimvp") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-06-01 19:11:18 +02:00
|
|
|
bool is_my_video_paused;
|
|
|
|
get_args(args, group_call_id, is_my_video_paused);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::toggleGroupCallIsMyVideoPaused>(group_call_id, is_my_video_paused));
|
2021-05-02 01:40:22 +02:00
|
|
|
} else if (op == "tgcimve") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-05-02 01:40:22 +02:00
|
|
|
bool is_my_video_enabled;
|
|
|
|
get_args(args, group_call_id, is_my_video_enabled);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::toggleGroupCallIsMyVideoEnabled>(group_call_id, is_my_video_enabled));
|
2020-12-08 15:51:37 +01:00
|
|
|
} else if (op == "sgcpis") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-05-03 20:44:21 +02:00
|
|
|
int32 source_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_speaking;
|
2021-05-03 20:44:21 +02:00
|
|
|
get_args(args, group_call_id, source_id, is_speaking);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setGroupCallParticipantIsSpeaking>(group_call_id, source_id, is_speaking));
|
2020-12-08 15:51:37 +01:00
|
|
|
} else if (op == "igcp") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2020-11-29 13:41:03 +01:00
|
|
|
string user_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, group_call_id, user_ids);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::inviteGroupCallParticipants>(group_call_id, as_user_ids(user_ids)));
|
2021-03-12 17:29:06 +01:00
|
|
|
} else if (op == "ggcil") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-03-12 17:29:06 +01:00
|
|
|
bool can_self_unmute;
|
|
|
|
get_args(args, group_call_id, can_self_unmute);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::getGroupCallInviteLink>(group_call_id, can_self_unmute));
|
2021-03-11 20:19:19 +01:00
|
|
|
} else if (op == "sgcr") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-03-11 20:19:19 +01:00
|
|
|
string title;
|
2021-08-23 14:29:03 +02:00
|
|
|
bool record_video;
|
|
|
|
bool use_portrait_orientation;
|
2021-12-31 12:20:34 +01:00
|
|
|
get_args(args, group_call_id, title, record_video, use_portrait_orientation);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::startGroupCallRecording>(group_call_id, title, record_video,
|
|
|
|
use_portrait_orientation));
|
2021-03-11 20:19:19 +01:00
|
|
|
} else if (op == "egcr") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-12-31 12:20:34 +01:00
|
|
|
get_args(args, group_call_id);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::endGroupCallRecording>(group_call_id));
|
2020-12-08 15:51:37 +01:00
|
|
|
} else if (op == "tgcpim") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-03-05 14:03:49 +01:00
|
|
|
string participant_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_muted;
|
2021-03-05 14:03:49 +01:00
|
|
|
get_args(args, group_call_id, participant_id, is_muted);
|
|
|
|
send_request(td_api::make_object<td_api::toggleGroupCallParticipantIsMuted>(
|
2022-04-22 13:50:52 +02:00
|
|
|
group_call_id, as_message_sender(participant_id), is_muted));
|
2021-02-01 22:40:40 +01:00
|
|
|
} else if (op == "sgcpvl") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-03-05 14:03:49 +01:00
|
|
|
string participant_id;
|
2021-01-02 20:59:48 +01:00
|
|
|
int32 volume_level;
|
2021-03-05 14:03:49 +01:00
|
|
|
get_args(args, group_call_id, participant_id, volume_level);
|
|
|
|
send_request(td_api::make_object<td_api::setGroupCallParticipantVolumeLevel>(
|
2022-04-22 13:50:52 +02:00
|
|
|
group_call_id, as_message_sender(participant_id), volume_level));
|
2021-03-14 23:56:59 +01:00
|
|
|
} else if (op == "tgcpihr") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2021-03-14 23:56:59 +01:00
|
|
|
string participant_id;
|
|
|
|
bool is_hand_raised;
|
|
|
|
get_args(args, group_call_id, participant_id, is_hand_raised);
|
|
|
|
send_request(td_api::make_object<td_api::toggleGroupCallParticipantIsHandRaised>(
|
2022-04-22 13:50:52 +02:00
|
|
|
group_call_id, as_message_sender(participant_id), is_hand_raised));
|
2020-12-11 17:39:27 +01:00
|
|
|
} else if (op == "lgcp") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
2020-12-11 17:39:27 +01:00
|
|
|
string limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, group_call_id, limit);
|
2022-04-22 13:50:52 +02:00
|
|
|
send_request(td_api::make_object<td_api::loadGroupCallParticipants>(group_call_id, as_limit(limit)));
|
2020-11-26 09:37:54 +01:00
|
|
|
} else if (op == "lgc") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(td_api::make_object<td_api::leaveGroupCall>(group_call_id));
|
2021-12-23 11:00:05 +01:00
|
|
|
} else if (op == "egc") {
|
2022-04-22 13:50:52 +02:00
|
|
|
GroupCallId group_call_id;
|
|
|
|
get_args(args, group_call_id);
|
|
|
|
send_request(td_api::make_object<td_api::endGroupCall>(group_call_id));
|
2021-01-18 21:04:56 +01:00
|
|
|
} else if (op == "rpcil") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::replacePrimaryChatInviteLink>(chat_id));
|
2021-01-18 21:04:56 +01:00
|
|
|
} else if (op == "ccilt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-11-04 07:52:27 +01:00
|
|
|
string name;
|
2021-12-22 11:57:47 +01:00
|
|
|
int32 expiration_date;
|
2021-01-17 21:07:17 +01:00
|
|
|
int32 member_limit;
|
2021-11-04 07:52:27 +01:00
|
|
|
bool creates_join_request;
|
2021-12-22 11:57:47 +01:00
|
|
|
get_args(args, chat_id, name, expiration_date, member_limit, creates_join_request);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::createChatInviteLink>(chat_id, name, expiration_date, member_limit,
|
|
|
|
creates_join_request));
|
2021-01-12 17:21:12 +01:00
|
|
|
} else if (op == "ecil") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-01-12 17:21:12 +01:00
|
|
|
string invite_link;
|
2021-11-04 07:52:27 +01:00
|
|
|
string name;
|
2021-12-22 11:57:47 +01:00
|
|
|
int32 expiration_date;
|
2021-01-17 21:07:17 +01:00
|
|
|
int32 member_limit;
|
2021-11-04 07:52:27 +01:00
|
|
|
bool creates_join_request;
|
2021-12-22 11:57:47 +01:00
|
|
|
get_args(args, chat_id, invite_link, name, expiration_date, member_limit, creates_join_request);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::editChatInviteLink>(chat_id, invite_link, name, expiration_date,
|
|
|
|
member_limit, creates_join_request));
|
2021-01-18 20:35:28 +01:00
|
|
|
} else if (op == "rcil") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-01-18 20:35:28 +01:00
|
|
|
string invite_link;
|
|
|
|
get_args(args, chat_id, invite_link);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::revokeChatInviteLink>(chat_id, invite_link));
|
2021-02-02 17:23:45 +01:00
|
|
|
} else if (op == "gcilc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatInviteLinkCounts>(chat_id));
|
2021-02-24 20:25:10 +01:00
|
|
|
} else if (op == "gcil") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-02-24 20:25:10 +01:00
|
|
|
string invite_link;
|
|
|
|
get_args(args, chat_id, invite_link);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatInviteLink>(chat_id, invite_link));
|
2021-02-24 20:25:10 +01:00
|
|
|
} else if (op == "gcils" || op == "gcilr") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId creator_user_id;
|
2021-01-20 15:30:26 +01:00
|
|
|
int32 offset_date;
|
2021-01-14 17:39:51 +01:00
|
|
|
string offset_invite_link;
|
|
|
|
string limit;
|
2021-02-25 14:02:07 +01:00
|
|
|
get_args(args, chat_id, creator_user_id, offset_date, offset_invite_link, limit);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatInviteLinks>(chat_id, creator_user_id, op == "gcilr", offset_date,
|
|
|
|
offset_invite_link, as_limit(limit)));
|
2021-01-17 21:07:17 +01:00
|
|
|
} else if (op == "gcilm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-01-14 21:21:23 +01:00
|
|
|
string invite_link;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId offset_user_id;
|
2021-01-14 21:21:23 +01:00
|
|
|
int32 offset_date;
|
|
|
|
string limit;
|
|
|
|
get_args(args, chat_id, invite_link, offset_user_id, offset_date, limit);
|
2021-01-17 21:07:17 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatInviteLinkMembers>(
|
2023-04-03 12:36:47 +02:00
|
|
|
chat_id, invite_link,
|
|
|
|
td_api::make_object<td_api::chatInviteLinkMember>(offset_user_id, offset_date, false, 0), as_limit(limit)));
|
2021-10-13 21:33:31 +02:00
|
|
|
} else if (op == "gcjr") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-10-13 21:33:31 +02:00
|
|
|
string invite_link;
|
|
|
|
string query;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId offset_user_id;
|
2021-10-13 21:33:31 +02:00
|
|
|
int32 offset_date;
|
|
|
|
string limit;
|
|
|
|
get_args(args, chat_id, invite_link, query, offset_user_id, offset_date, limit);
|
|
|
|
send_request(td_api::make_object<td_api::getChatJoinRequests>(
|
2021-12-31 12:20:34 +01:00
|
|
|
chat_id, invite_link, query,
|
2021-12-31 12:56:57 +01:00
|
|
|
td_api::make_object<td_api::chatJoinRequest>(offset_user_id, offset_date, string()), as_limit(limit)));
|
2021-11-24 09:33:18 +01:00
|
|
|
} else if (op == "pcjr") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2021-11-24 09:33:18 +01:00
|
|
|
bool approve;
|
|
|
|
get_args(args, chat_id, user_id, approve);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::processChatJoinRequest>(chat_id, user_id, approve));
|
2021-11-24 10:02:23 +01:00
|
|
|
} else if (op == "pcjrs") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-11-24 10:02:23 +01:00
|
|
|
string invite_link;
|
|
|
|
bool approve;
|
|
|
|
get_args(args, chat_id, invite_link, approve);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::processChatJoinRequests>(chat_id, invite_link, approve));
|
2021-01-18 17:51:46 +01:00
|
|
|
} else if (op == "drcil") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-01-18 17:51:46 +01:00
|
|
|
string invite_link;
|
|
|
|
get_args(args, chat_id, invite_link);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteRevokedChatInviteLink>(chat_id, invite_link));
|
2021-01-18 17:59:21 +01:00
|
|
|
} else if (op == "darcil") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId creator_user_id;
|
2021-02-25 14:02:07 +01:00
|
|
|
get_args(args, chat_id, creator_user_id);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteAllRevokedChatInviteLinks>(chat_id, creator_user_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ccil") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkChatInviteLink>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "jcbil") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::joinChatByInviteLink>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gte") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getTextEntities>(args));
|
2022-09-07 09:25:21 +02:00
|
|
|
} else if (op == "gtee") {
|
2019-02-21 17:48:05 +01:00
|
|
|
execute(td_api::make_object<td_api::getTextEntities>(args));
|
2020-03-09 21:55:32 +01:00
|
|
|
} else if (op == "pm") {
|
2020-03-11 23:44:42 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::parseMarkdown>(td_api::make_object<td_api::formattedText>(args, Auto())));
|
2018-01-30 18:06:54 +01:00
|
|
|
} else if (op == "pte") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(
|
2019-12-30 22:58:11 +01:00
|
|
|
td_api::make_object<td_api::parseTextEntities>(args, td_api::make_object<td_api::textParseModeMarkdown>(2)));
|
2018-10-09 15:27:40 +02:00
|
|
|
} else if (op == "pteh") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::parseTextEntities>(args, td_api::make_object<td_api::textParseModeHTML>()));
|
2018-01-30 18:06:54 +01:00
|
|
|
} else if (op == "ptes") {
|
2019-02-21 17:48:05 +01:00
|
|
|
execute(
|
2019-12-30 22:58:11 +01:00
|
|
|
td_api::make_object<td_api::parseTextEntities>(args, td_api::make_object<td_api::textParseModeMarkdown>(2)));
|
2018-10-09 15:27:40 +02:00
|
|
|
} else if (op == "ptehs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
execute(td_api::make_object<td_api::parseTextEntities>(args, td_api::make_object<td_api::textParseModeHTML>()));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gfmt") {
|
2019-02-21 17:48:05 +01:00
|
|
|
execute(td_api::make_object<td_api::getFileMimeType>(trim(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gfe") {
|
2019-02-21 17:48:05 +01:00
|
|
|
execute(td_api::make_object<td_api::getFileExtension>(trim(args)));
|
2018-04-30 14:50:54 +02:00
|
|
|
} else if (op == "cfn") {
|
2019-02-21 17:48:05 +01:00
|
|
|
execute(td_api::make_object<td_api::cleanFileName>(args));
|
2018-12-10 02:01:02 +01:00
|
|
|
} else if (op == "gjv") {
|
|
|
|
execute(td_api::make_object<td_api::getJsonValue>(args));
|
2018-12-10 20:08:58 +01:00
|
|
|
} else if (op == "gjvtest") {
|
|
|
|
execute(td_api::make_object<td_api::getJsonValue>("\"aba\200caba\""));
|
|
|
|
execute(td_api::make_object<td_api::getJsonValue>("\"\\u0080\""));
|
|
|
|
execute(td_api::make_object<td_api::getJsonValue>("\"\\uD800\""));
|
2018-12-10 02:01:02 +01:00
|
|
|
} else if (op == "gjs") {
|
2021-10-18 11:57:13 +02:00
|
|
|
auto test_get_json_string = [&](td_api::object_ptr<td_api::JsonValue> &&json_value) {
|
2018-12-10 20:08:58 +01:00
|
|
|
execute(td_api::make_object<td_api::getJsonString>(std::move(json_value)));
|
|
|
|
};
|
|
|
|
|
|
|
|
test_get_json_string(nullptr);
|
|
|
|
test_get_json_string(td_api::make_object<td_api::jsonValueNull>());
|
|
|
|
test_get_json_string(td_api::make_object<td_api::jsonValueBoolean>(true));
|
|
|
|
test_get_json_string(td_api::make_object<td_api::jsonValueNumber>(123456789123.0));
|
|
|
|
test_get_json_string(td_api::make_object<td_api::jsonValueString>(string("aba\0caba", 8)));
|
|
|
|
test_get_json_string(td_api::make_object<td_api::jsonValueString>("aba\200caba"));
|
2018-12-10 02:01:02 +01:00
|
|
|
|
|
|
|
auto inner_array = td_api::make_object<td_api::jsonValueArray>();
|
2021-10-19 17:11:16 +02:00
|
|
|
inner_array->values_.emplace_back(td_api::make_object<td_api::jsonValueBoolean>(false));
|
2018-12-10 02:01:02 +01:00
|
|
|
auto array = td_api::make_object<td_api::jsonValueArray>();
|
2021-10-19 17:11:16 +02:00
|
|
|
array->values_.emplace_back(nullptr);
|
|
|
|
array->values_.emplace_back(std::move(inner_array));
|
|
|
|
array->values_.emplace_back(td_api::make_object<td_api::jsonValueNull>());
|
|
|
|
array->values_.emplace_back(td_api::make_object<td_api::jsonValueNumber>(-1));
|
2018-12-10 20:08:58 +01:00
|
|
|
test_get_json_string(std::move(array));
|
2018-12-10 02:01:02 +01:00
|
|
|
|
|
|
|
auto object = td_api::make_object<td_api::jsonValueObject>();
|
2021-10-19 17:11:16 +02:00
|
|
|
object->members_.emplace_back(
|
2018-12-10 02:01:02 +01:00
|
|
|
td_api::make_object<td_api::jsonObjectMember>("", td_api::make_object<td_api::jsonValueString>("test")));
|
2021-10-19 17:11:16 +02:00
|
|
|
object->members_.emplace_back(td_api::make_object<td_api::jsonObjectMember>("a", nullptr));
|
|
|
|
object->members_.emplace_back(td_api::make_object<td_api::jsonObjectMember>("\x80", nullptr));
|
|
|
|
object->members_.emplace_back(nullptr);
|
|
|
|
object->members_.emplace_back(
|
2018-12-10 02:01:02 +01:00
|
|
|
td_api::make_object<td_api::jsonObjectMember>("a", td_api::make_object<td_api::jsonValueNull>()));
|
2018-12-10 20:08:58 +01:00
|
|
|
test_get_json_string(std::move(object));
|
2022-03-29 19:22:38 +02:00
|
|
|
} else if (op == "gtpjs") {
|
2022-10-12 14:03:47 +02:00
|
|
|
execute(td_api::make_object<td_api::getThemeParametersJsonString>(as_theme_parameters()));
|
2018-12-10 20:08:58 +01:00
|
|
|
} else if (op == "gac") {
|
|
|
|
send_request(td_api::make_object<td_api::getApplicationConfig>());
|
2023-02-21 10:08:55 +01:00
|
|
|
} else if (op == "aac") {
|
|
|
|
send_request(td_api::make_object<td_api::addApplicationChangelog>(args));
|
2018-12-10 20:08:58 +01:00
|
|
|
} else if (op == "sale") {
|
|
|
|
string type;
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-10 20:08:58 +01:00
|
|
|
string json;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, type, chat_id, json);
|
2018-12-10 20:08:58 +01:00
|
|
|
auto result = execute(td_api::make_object<td_api::getJsonValue>(json));
|
|
|
|
if (result->get_id() == td_api::error::ID) {
|
|
|
|
LOG(ERROR) << to_string(result);
|
|
|
|
} else {
|
|
|
|
send_request(td_api::make_object<td_api::saveApplicationLogEvent>(
|
2021-12-31 12:20:34 +01:00
|
|
|
type, chat_id, move_tl_object_as<td_api::JsonValue>(result)));
|
2018-12-10 20:08:58 +01:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
2020-09-22 18:45:27 +02:00
|
|
|
if (op == "scdm" || op == "scdmt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string reply_to_message_id;
|
|
|
|
string message;
|
2020-09-22 18:45:27 +02:00
|
|
|
if (op == "scdmt") {
|
2020-12-26 18:58:30 +01:00
|
|
|
get_args(args, message_thread_id, args);
|
2020-09-22 18:45:27 +02:00
|
|
|
}
|
2020-12-26 18:58:30 +01:00
|
|
|
get_args(args, chat_id, reply_to_message_id, message);
|
2019-12-03 02:36:23 +01:00
|
|
|
td_api::object_ptr<td_api::draftMessage> draft_message;
|
2018-12-31 20:04:05 +01:00
|
|
|
if (!reply_to_message_id.empty() || !message.empty()) {
|
2019-12-03 02:36:23 +01:00
|
|
|
vector<td_api::object_ptr<td_api::textEntity>> entities;
|
2019-02-21 17:48:05 +01:00
|
|
|
entities.push_back(
|
|
|
|
td_api::make_object<td_api::textEntity>(0, 1, td_api::make_object<td_api::textEntityTypePre>()));
|
|
|
|
draft_message = td_api::make_object<td_api::draftMessage>(
|
2020-03-12 17:56:42 +01:00
|
|
|
as_message_id(reply_to_message_id), 0,
|
|
|
|
td_api::make_object<td_api::inputMessageText>(as_formatted_text(message, std::move(entities)), true,
|
|
|
|
false));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2022-10-27 13:19:04 +02:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setChatDraftMessage>(chat_id, message_thread_id, std::move(draft_message)));
|
2018-07-17 05:46:27 +02:00
|
|
|
} else if (op == "cadm") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::clearAllDraftMessages>());
|
2021-12-09 19:48:57 +01:00
|
|
|
} else if (op == "tchpc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-06 19:43:55 +01:00
|
|
|
bool has_protected_content;
|
|
|
|
get_args(args, chat_id, has_protected_content);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::toggleChatHasProtectedContent>(chat_id, has_protected_content));
|
2020-05-22 00:19:28 +02:00
|
|
|
} else if (op == "tcip" || op == "tcipa" || begins_with(op, "tcip-")) {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_pinned;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, is_pinned);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::toggleChatIsPinned>(as_chat_list(op), chat_id, is_pinned));
|
2020-09-20 02:00:01 +02:00
|
|
|
} else if (op == "tcimau") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2023-01-20 10:38:25 +01:00
|
|
|
bool is_marked_as_unread;
|
|
|
|
get_args(args, chat_id, is_marked_as_unread);
|
|
|
|
send_request(td_api::make_object<td_api::toggleChatIsMarkedAsUnread>(chat_id, is_marked_as_unread));
|
|
|
|
} else if (op == "tcit") {
|
|
|
|
ChatId chat_id;
|
|
|
|
bool is_translatable;
|
|
|
|
get_args(args, chat_id, is_translatable);
|
|
|
|
send_request(td_api::make_object<td_api::toggleChatIsTranslatable>(chat_id, is_translatable));
|
2023-07-28 16:33:47 +02:00
|
|
|
} else if (op == "smsbl") {
|
2021-02-19 11:13:39 +01:00
|
|
|
string sender_id;
|
2023-07-28 16:33:47 +02:00
|
|
|
string block_list;
|
|
|
|
get_args(args, sender_id, block_list);
|
|
|
|
send_request(td_api::make_object<td_api::setMessageSenderBlockList>(as_message_sender(sender_id),
|
|
|
|
as_block_list(block_list)));
|
2020-10-18 00:26:36 +02:00
|
|
|
} else if (op == "bmsfr") {
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool delete_message;
|
|
|
|
bool delete_all_messages;
|
|
|
|
bool report_spam;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, message_id, delete_message, delete_all_messages, report_spam);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::blockMessageSenderFromReplies>(message_id, delete_message,
|
2020-12-26 17:59:45 +01:00
|
|
|
delete_all_messages, report_spam));
|
2018-04-28 20:05:04 +02:00
|
|
|
} else if (op == "tcddn") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool default_disable_notification;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, default_disable_notification);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::toggleChatDefaultDisableNotification>(chat_id, default_disable_notification));
|
2020-05-22 00:19:28 +02:00
|
|
|
} else if (op == "spchats" || op == "spchatsa" || begins_with(op, "spchats-")) {
|
2022-01-24 15:40:16 +01:00
|
|
|
send_request(td_api::make_object<td_api::setPinnedChats>(as_chat_list(op), as_chat_ids(args)));
|
2023-04-14 14:17:25 +02:00
|
|
|
} else if (op == "rcl" || op == "rcla" || begins_with(op, "rcl-")) {
|
|
|
|
send_request(td_api::make_object<td_api::readChatList>(as_chat_list(op)));
|
2023-07-11 11:29:10 +02:00
|
|
|
} else if (op == "gst" || op == "gstl") {
|
2023-06-27 20:51:36 +02:00
|
|
|
ChatId story_sender_chat_id;
|
2023-06-05 15:55:06 +02:00
|
|
|
StoryId story_id;
|
2023-06-27 20:51:36 +02:00
|
|
|
get_args(args, story_sender_chat_id, story_id);
|
2023-07-11 11:29:10 +02:00
|
|
|
send_request(td_api::make_object<td_api::getStory>(story_sender_chat_id, story_id, op == "gstl"));
|
2023-05-25 20:10:02 +02:00
|
|
|
} else if (op == "ssp" || op == "sspp") {
|
2023-05-25 14:03:29 +02:00
|
|
|
string photo;
|
|
|
|
string caption;
|
2023-07-18 15:00:06 +02:00
|
|
|
StoryPrivacySettings rules;
|
2023-06-09 15:41:40 +02:00
|
|
|
int32 active_period;
|
2023-05-25 14:03:29 +02:00
|
|
|
string sticker_file_ids;
|
2023-06-27 16:19:10 +02:00
|
|
|
bool protect_content;
|
|
|
|
get_args(args, photo, caption, rules, active_period, sticker_file_ids, protect_content);
|
2023-06-09 15:41:40 +02:00
|
|
|
send_request(td_api::make_object<td_api::sendStory>(
|
|
|
|
td_api::make_object<td_api::inputStoryContentPhoto>(as_input_file(photo),
|
|
|
|
to_integers<int32>(sticker_file_ids)),
|
2023-08-01 18:07:13 +02:00
|
|
|
nullptr, as_caption(caption), rules, active_period ? active_period : 86400, op == "sspp", protect_content));
|
2023-05-25 20:10:02 +02:00
|
|
|
} else if (op == "ssv" || op == "ssvp") {
|
2023-05-25 14:03:29 +02:00
|
|
|
string video;
|
|
|
|
string caption;
|
2023-07-18 15:00:06 +02:00
|
|
|
StoryPrivacySettings rules;
|
2023-06-09 15:41:40 +02:00
|
|
|
int32 active_period;
|
2023-06-05 13:33:00 +02:00
|
|
|
double duration;
|
2023-05-25 14:03:29 +02:00
|
|
|
string sticker_file_ids;
|
2023-06-27 16:19:10 +02:00
|
|
|
bool protect_content;
|
|
|
|
get_args(args, video, caption, rules, active_period, duration, sticker_file_ids, protect_content);
|
2023-05-25 14:03:29 +02:00
|
|
|
send_request(td_api::make_object<td_api::sendStory>(
|
|
|
|
td_api::make_object<td_api::inputStoryContentVideo>(as_input_file(video),
|
2023-06-23 15:06:02 +02:00
|
|
|
to_integers<int32>(sticker_file_ids), duration, true),
|
2023-08-01 18:07:13 +02:00
|
|
|
nullptr, as_caption(caption), rules, active_period ? active_period : 86400, op == "ssvp", protect_content));
|
2023-05-30 13:41:36 +02:00
|
|
|
} else if (op == "esc") {
|
|
|
|
StoryId story_id;
|
|
|
|
string caption;
|
|
|
|
get_args(args, story_id, caption);
|
2023-08-01 19:37:37 +02:00
|
|
|
send_request(td_api::make_object<td_api::editStory>(story_id, nullptr, nullptr, as_caption(caption)));
|
2023-05-30 13:41:36 +02:00
|
|
|
} else if (op == "esp") {
|
|
|
|
StoryId story_id;
|
|
|
|
string photo;
|
|
|
|
string caption;
|
|
|
|
string sticker_file_ids;
|
|
|
|
get_args(args, story_id, photo, caption, sticker_file_ids);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::editStory>(story_id,
|
|
|
|
td_api::make_object<td_api::inputStoryContentPhoto>(
|
|
|
|
as_input_file(photo), to_integers<int32>(sticker_file_ids)),
|
2023-08-01 19:37:37 +02:00
|
|
|
nullptr, as_caption(caption)));
|
2023-05-30 13:41:36 +02:00
|
|
|
} else if (op == "esv") {
|
|
|
|
StoryId story_id;
|
|
|
|
string video;
|
|
|
|
string caption;
|
|
|
|
int32 duration;
|
|
|
|
string sticker_file_ids;
|
|
|
|
get_args(args, story_id, video, caption, duration, sticker_file_ids);
|
|
|
|
send_request(td_api::make_object<td_api::editStory>(
|
|
|
|
story_id,
|
|
|
|
td_api::make_object<td_api::inputStoryContentVideo>(as_input_file(video),
|
2023-06-23 15:06:02 +02:00
|
|
|
to_integers<int32>(sticker_file_ids), duration, false),
|
2023-08-01 19:37:37 +02:00
|
|
|
nullptr, as_caption(caption)));
|
2023-07-18 15:00:06 +02:00
|
|
|
} else if (op == "ssps") {
|
2023-05-25 17:18:28 +02:00
|
|
|
StoryId story_id;
|
2023-07-18 15:00:06 +02:00
|
|
|
StoryPrivacySettings rules;
|
2023-05-25 17:38:15 +02:00
|
|
|
get_args(args, story_id, rules);
|
2023-07-18 15:00:06 +02:00
|
|
|
send_request(td_api::make_object<td_api::setStoryPrivacySettings>(story_id, rules));
|
2023-05-26 13:21:36 +02:00
|
|
|
} else if (op == "tsip") {
|
|
|
|
StoryId story_id;
|
|
|
|
bool is_pinned;
|
|
|
|
get_args(args, story_id, is_pinned);
|
|
|
|
send_request(td_api::make_object<td_api::toggleStoryIsPinned>(story_id, is_pinned));
|
2023-06-01 16:28:49 +02:00
|
|
|
} else if (op == "ds") {
|
|
|
|
StoryId story_id;
|
|
|
|
get_args(args, story_id);
|
|
|
|
send_request(td_api::make_object<td_api::deleteStory>(story_id));
|
2023-07-08 14:55:49 +02:00
|
|
|
} else if (op == "las" || op == "lasa" || op == "lase") {
|
|
|
|
send_request(td_api::make_object<td_api::loadActiveStories>(as_story_list(op)));
|
2023-07-08 15:53:29 +02:00
|
|
|
} else if (op == "scasl" || op == "scasla" || op == "scasle") {
|
2023-06-27 21:40:34 +02:00
|
|
|
ChatId chat_id;
|
2023-07-08 15:53:29 +02:00
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::setChatActiveStoriesList>(chat_id, as_story_list(op)));
|
2023-06-27 21:45:01 +02:00
|
|
|
} else if (op == "gcps") {
|
|
|
|
ChatId chat_id;
|
2023-05-20 22:24:36 +02:00
|
|
|
StoryId from_story_id;
|
|
|
|
string limit;
|
2023-06-27 21:45:01 +02:00
|
|
|
get_args(args, chat_id, from_story_id, limit);
|
|
|
|
send_request(td_api::make_object<td_api::getChatPinnedStories>(chat_id, from_story_id, as_limit(limit)));
|
2023-06-09 16:21:34 +02:00
|
|
|
} else if (op == "gast") {
|
|
|
|
StoryId from_story_id;
|
|
|
|
string limit;
|
|
|
|
get_args(args, from_story_id, limit);
|
|
|
|
send_request(td_api::make_object<td_api::getArchivedStories>(from_story_id, as_limit(limit)));
|
2023-07-06 18:15:00 +02:00
|
|
|
} else if (op == "gsnse") {
|
|
|
|
send_request(td_api::make_object<td_api::getStoryNotificationSettingsExceptions>());
|
2023-06-27 21:45:01 +02:00
|
|
|
} else if (op == "gcas") {
|
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatActiveStories>(chat_id));
|
2023-06-14 14:17:24 +02:00
|
|
|
} else if (op == "os") {
|
2023-06-27 20:51:36 +02:00
|
|
|
ChatId story_sender_chat_id;
|
2023-06-14 14:17:24 +02:00
|
|
|
StoryId story_id;
|
2023-06-27 20:51:36 +02:00
|
|
|
get_args(args, story_sender_chat_id, story_id);
|
|
|
|
send_request(td_api::make_object<td_api::openStory>(story_sender_chat_id, story_id));
|
2023-06-15 17:34:05 +02:00
|
|
|
} else if (op == "cs") {
|
2023-06-27 20:51:36 +02:00
|
|
|
ChatId story_sender_chat_id;
|
2023-06-15 17:34:05 +02:00
|
|
|
StoryId story_id;
|
2023-06-27 20:51:36 +02:00
|
|
|
get_args(args, story_sender_chat_id, story_id);
|
|
|
|
send_request(td_api::make_object<td_api::closeStory>(story_sender_chat_id, story_id));
|
2023-08-06 22:28:00 +02:00
|
|
|
} else if (op == "ssr") {
|
|
|
|
ChatId story_sender_chat_id;
|
|
|
|
StoryId story_id;
|
|
|
|
string reaction;
|
|
|
|
bool update_recent_reactions;
|
|
|
|
get_args(args, story_sender_chat_id, story_id, reaction, update_recent_reactions);
|
|
|
|
send_request(td_api::make_object<td_api::setStoryReaction>(story_sender_chat_id, story_id,
|
|
|
|
as_reaction_type(reaction), update_recent_reactions));
|
2023-06-18 22:25:50 +02:00
|
|
|
} else if (op == "gsv") {
|
|
|
|
StoryId story_id;
|
|
|
|
string limit;
|
2023-08-07 18:40:15 +02:00
|
|
|
string offset;
|
2023-08-07 18:56:55 +02:00
|
|
|
string query;
|
|
|
|
bool only_contacts;
|
|
|
|
bool prefer_with_reaction;
|
|
|
|
get_args(args, story_id, limit, offset, query, only_contacts, prefer_with_reaction);
|
|
|
|
send_request(td_api::make_object<td_api::getStoryViewers>(story_id, query, only_contacts, prefer_with_reaction,
|
|
|
|
offset, as_limit(limit)));
|
2023-06-21 22:23:19 +02:00
|
|
|
} else if (op == "rst") {
|
2023-06-27 20:51:36 +02:00
|
|
|
ChatId story_sender_chat_id;
|
2023-06-21 22:23:19 +02:00
|
|
|
StoryId story_id;
|
2023-08-01 19:44:24 +02:00
|
|
|
ReportReason reason;
|
2023-06-21 22:23:19 +02:00
|
|
|
string text;
|
2023-06-27 20:51:36 +02:00
|
|
|
get_args(args, story_sender_chat_id, story_id, reason, text);
|
2023-08-01 19:44:24 +02:00
|
|
|
send_request(td_api::make_object<td_api::reportStory>(story_sender_chat_id, story_id, reason, text));
|
2023-08-04 14:23:51 +02:00
|
|
|
} else if (op == "assm") {
|
|
|
|
send_request(td_api::make_object<td_api::activateStoryStealthMode>());
|
2022-03-29 14:00:00 +02:00
|
|
|
} else if (op == "gamb") {
|
|
|
|
UserId user_id;
|
|
|
|
get_args(args, user_id);
|
2022-04-14 21:56:27 +02:00
|
|
|
send_request(td_api::make_object<td_api::getAttachmentMenuBot>(user_id));
|
2022-03-26 21:41:22 +01:00
|
|
|
} else if (op == "tbiatam") {
|
|
|
|
UserId user_id;
|
|
|
|
bool is_added;
|
2022-12-15 12:21:22 +01:00
|
|
|
bool allow_write_access;
|
|
|
|
get_args(args, user_id, is_added, allow_write_access);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::toggleBotIsAddedToAttachmentMenu>(user_id, is_added, allow_write_access));
|
2023-02-24 12:07:40 +01:00
|
|
|
} else if (op == "swa") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string short_name;
|
|
|
|
get_args(args, bot_user_id, short_name);
|
|
|
|
send_request(td_api::make_object<td_api::searchWebApp>(bot_user_id, short_name));
|
2023-02-24 13:08:16 +01:00
|
|
|
} else if (op == "gwalu") {
|
|
|
|
ChatId chat_id;
|
|
|
|
UserId bot_user_id;
|
|
|
|
string short_name;
|
|
|
|
string start_parameter;
|
|
|
|
get_args(args, chat_id, bot_user_id, short_name, start_parameter);
|
|
|
|
send_request(td_api::make_object<td_api::getWebAppLinkUrl>(chat_id, bot_user_id, short_name, start_parameter,
|
|
|
|
as_theme_parameters(), "android", true));
|
2022-03-31 15:42:59 +02:00
|
|
|
} else if (op == "gwau") {
|
2023-02-24 12:07:40 +01:00
|
|
|
UserId bot_user_id;
|
2022-03-30 15:27:01 +02:00
|
|
|
string url;
|
2023-02-24 12:07:40 +01:00
|
|
|
get_args(args, bot_user_id, url);
|
|
|
|
send_request(td_api::make_object<td_api::getWebAppUrl>(bot_user_id, url, as_theme_parameters(), "android"));
|
2022-03-31 15:42:59 +02:00
|
|
|
} else if (op == "swad") {
|
2023-02-24 12:07:40 +01:00
|
|
|
UserId bot_user_id;
|
2022-03-28 14:18:15 +02:00
|
|
|
string button_text;
|
|
|
|
string data;
|
2023-02-24 12:07:40 +01:00
|
|
|
get_args(args, bot_user_id, button_text, data);
|
|
|
|
send_request(td_api::make_object<td_api::sendWebAppData>(bot_user_id, button_text, data));
|
2022-03-31 15:42:59 +02:00
|
|
|
} else if (op == "owa") {
|
2022-03-31 14:05:08 +02:00
|
|
|
ChatId chat_id;
|
|
|
|
UserId bot_user_id;
|
|
|
|
string url;
|
2023-06-08 16:27:24 +02:00
|
|
|
MessageReplyTo message_reply_to;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2023-06-08 16:27:24 +02:00
|
|
|
get_args(args, chat_id, bot_user_id, url, message_reply_to, message_thread_id);
|
2022-10-12 14:03:47 +02:00
|
|
|
send_request(td_api::make_object<td_api::openWebApp>(chat_id, bot_user_id, url, as_theme_parameters(), "android",
|
2023-06-08 16:27:24 +02:00
|
|
|
message_thread_id, message_reply_to));
|
2022-03-31 20:45:35 +02:00
|
|
|
} else if (op == "cwa") {
|
|
|
|
int64 launch_id;
|
|
|
|
get_args(args, launch_id);
|
|
|
|
send_request(td_api::make_object<td_api::closeWebApp>(launch_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sca") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string action;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_thread_id, action);
|
2022-10-27 13:19:04 +02:00
|
|
|
send_request(td_api::make_object<td_api::sendChatAction>(chat_id, message_thread_id, as_chat_action(action)));
|
2018-02-13 15:01:30 +01:00
|
|
|
} else if (op == "smt" || op == "smtp" || op == "smtf" || op == "smtpf") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
for (int i = 1; i <= 200; i++) {
|
2021-07-16 17:58:11 +02:00
|
|
|
string message = PSTRING() << (Random::fast(0, 3) == 0 && i > 90 ? "sleep " : "") << "#" << i;
|
2018-02-13 15:01:30 +01:00
|
|
|
if (i == 6 || (op.back() == 'f' && i % 2 == 0)) {
|
|
|
|
message = string(4097, 'a');
|
|
|
|
}
|
|
|
|
if (op[3] == 'p') {
|
2022-12-28 15:02:41 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
|
|
|
|
as_local_file("rgb.jpg"), nullptr, Auto(), 0, 0, as_caption(message),
|
2022-12-28 19:46:16 +01:00
|
|
|
message_self_destruct_time_, has_spoiler_));
|
2018-01-30 18:06:54 +01:00
|
|
|
} else {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (op == "ssm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string filter;
|
2020-12-25 22:43:38 +01:00
|
|
|
string offset;
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, chat_id, filter, offset, query);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchSecretMessages>(chat_id, query.query, offset, query.limit,
|
|
|
|
as_search_messages_filter(filter)));
|
2019-12-06 01:08:11 +01:00
|
|
|
} else if (op == "ssd") {
|
2021-10-19 17:11:16 +02:00
|
|
|
schedule_date_ = std::move(args);
|
2020-09-23 00:52:16 +02:00
|
|
|
} else if (op == "smti") {
|
2022-10-27 13:19:04 +02:00
|
|
|
get_args(args, message_thread_id_);
|
2022-12-16 13:58:33 +01:00
|
|
|
} else if (op == "shs") {
|
|
|
|
has_spoiler_ = as_bool(args);
|
2022-12-28 15:09:39 +01:00
|
|
|
} else if (op == "smsdt") {
|
2022-12-28 19:46:16 +01:00
|
|
|
message_self_destruct_time_ = to_integer<int32>(args);
|
2021-11-12 15:11:01 +01:00
|
|
|
} else if (op == "gcams") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatAvailableMessageSenders>(chat_id));
|
2021-12-21 11:49:26 +01:00
|
|
|
} else if (op == "scmsr") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-11-15 15:08:37 +01:00
|
|
|
string sender_id;
|
|
|
|
get_args(args, chat_id, sender_id);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::setChatMessageSender>(chat_id, as_message_sender(sender_id)));
|
2018-01-30 18:06:54 +01:00
|
|
|
} else if (op == "sm" || op == "sms" || op == "smr" || op == "smf") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2023-06-08 16:27:24 +02:00
|
|
|
MessageReplyTo message_reply_to;
|
2018-12-31 20:04:05 +01:00
|
|
|
string message;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message);
|
2018-01-30 18:06:54 +01:00
|
|
|
if (op == "smr") {
|
2023-06-08 16:27:24 +02:00
|
|
|
get_args(message, message_reply_to, message);
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
|
|
|
if (op == "smf") {
|
2018-04-04 21:30:10 +02:00
|
|
|
message = string(5097, 'a');
|
2018-01-30 18:06:54 +01:00
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true),
|
2023-06-08 16:27:24 +02:00
|
|
|
op == "sms", false, message_reply_to);
|
2022-07-18 00:03:58 +02:00
|
|
|
} else if (op == "smce") {
|
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
vector<td_api::object_ptr<td_api::textEntity>> entities;
|
2022-07-21 12:54:18 +02:00
|
|
|
entities.push_back(td_api::make_object<td_api::textEntity>(
|
|
|
|
0, 2, td_api::make_object<td_api::textEntityTypeCustomEmoji>(5368324170671202286)));
|
|
|
|
entities.push_back(td_api::make_object<td_api::textEntity>(
|
|
|
|
3, 2, td_api::make_object<td_api::textEntityTypeCustomEmoji>(5377637695583426942)));
|
|
|
|
entities.push_back(td_api::make_object<td_api::textEntity>(
|
|
|
|
6, 5, td_api::make_object<td_api::textEntityTypeCustomEmoji>(5368324170671202286)));
|
2022-07-18 00:03:58 +02:00
|
|
|
auto text = as_formatted_text("👍 😉 🧑🚒", std::move(entities));
|
2023-06-08 16:27:24 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageText>(std::move(text), false, true));
|
2018-03-26 22:20:56 +02:00
|
|
|
} else if (op == "alm" || op == "almr") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-10-14 20:47:20 +02:00
|
|
|
string sender_id;
|
2023-06-08 16:27:24 +02:00
|
|
|
MessageReplyTo message_reply_to;
|
2018-03-26 22:20:56 +02:00
|
|
|
string message;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, sender_id, message);
|
2018-04-27 18:51:11 +02:00
|
|
|
if (op == "almr") {
|
2023-06-08 16:27:24 +02:00
|
|
|
get_args(message, message_reply_to, message);
|
2018-03-26 22:20:56 +02:00
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::addLocalMessage>(
|
2023-06-08 16:27:24 +02:00
|
|
|
chat_id, as_message_sender(sender_id), message_reply_to, false,
|
2019-02-21 17:48:05 +01:00
|
|
|
td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), false, true)));
|
2022-02-22 20:42:46 +01:00
|
|
|
} else if (op == "smap" || op == "smapr" || op == "smapp" || op == "smaprp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2023-06-08 16:27:24 +02:00
|
|
|
MessageReplyTo message_reply_to;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, args);
|
2022-02-22 20:42:46 +01:00
|
|
|
if (op == "smapr" || op == "smaprp") {
|
2023-06-08 16:27:24 +02:00
|
|
|
get_args(args, message_reply_to, args);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2022-12-16 13:58:33 +01:00
|
|
|
auto input_message_contents = transform(full_split(args), [this](const string &photo) {
|
2022-12-28 15:02:41 +01:00
|
|
|
td_api::object_ptr<td_api::InputMessageContent> content = td_api::make_object<td_api::inputMessagePhoto>(
|
2022-12-28 19:46:16 +01:00
|
|
|
as_input_file(photo), nullptr, Auto(), 0, 0, as_caption(""), rand_bool() ? message_self_destruct_time_ : 0,
|
2022-12-28 15:02:41 +01:00
|
|
|
has_spoiler_ && rand_bool());
|
2022-02-22 20:42:46 +01:00
|
|
|
return content;
|
|
|
|
});
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::sendMessageAlbum>(
|
2023-06-08 16:27:24 +02:00
|
|
|
chat_id, message_thread_id_, message_reply_to, default_message_send_options(),
|
2022-02-22 20:42:46 +01:00
|
|
|
std::move(input_message_contents), op == "smapp" || op == "smaprp"));
|
|
|
|
} else if (op == "smad" || op == "smadp") {
|
|
|
|
ChatId chat_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, args);
|
2022-02-22 20:42:46 +01:00
|
|
|
auto input_message_contents = transform(full_split(args), [](const string &document) {
|
|
|
|
td_api::object_ptr<td_api::InputMessageContent> content =
|
|
|
|
td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), nullptr, true, as_caption(""));
|
|
|
|
return content;
|
|
|
|
});
|
2023-06-08 16:27:24 +02:00
|
|
|
send_request(td_api::make_object<td_api::sendMessageAlbum>(chat_id, message_thread_id_, nullptr,
|
2022-02-22 20:42:46 +01:00
|
|
|
default_message_send_options(),
|
|
|
|
std::move(input_message_contents), op.back() == 'p'));
|
2021-01-22 17:14:35 +01:00
|
|
|
} else if (op == "gmft") {
|
|
|
|
auto r_message_file_head = read_file_str(args, 2 << 10);
|
|
|
|
if (r_message_file_head.is_error()) {
|
|
|
|
LOG(ERROR) << r_message_file_head.error();
|
|
|
|
} else {
|
|
|
|
auto message_file_head = r_message_file_head.move_as_ok();
|
|
|
|
while (!check_utf8(message_file_head)) {
|
|
|
|
message_file_head.pop_back();
|
|
|
|
}
|
|
|
|
send_request(td_api::make_object<td_api::getMessageFileType>(message_file_head));
|
|
|
|
}
|
2021-02-23 00:03:24 +01:00
|
|
|
} else if (op == "gmict") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-02-23 00:03:24 +01:00
|
|
|
get_args(args, chat_id);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessageImportConfirmationText>(chat_id));
|
2021-01-21 20:00:08 +01:00
|
|
|
} else if (op == "im") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-01-21 20:00:08 +01:00
|
|
|
string message_file;
|
|
|
|
vector<string> attached_files;
|
|
|
|
get_args(args, chat_id, message_file, args);
|
|
|
|
attached_files = full_split(args);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::importMessages>(chat_id, as_input_file(message_file),
|
2021-06-17 19:14:48 +02:00
|
|
|
transform(attached_files, as_input_file)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "em") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string message;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, message);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageText>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, nullptr,
|
2019-02-21 17:48:05 +01:00
|
|
|
td_api::make_object<td_api::inputMessageText>(as_formatted_text(message), true, true)));
|
2018-06-19 01:31:34 +02:00
|
|
|
} else if (op == "eman") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-06-19 01:31:34 +02:00
|
|
|
string animation;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, animation);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageMedia>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, nullptr,
|
2020-05-29 10:51:51 +02:00
|
|
|
td_api::make_object<td_api::inputMessageAnimation>(as_input_file(animation), nullptr, vector<int32>(), 0, 0,
|
2022-12-26 12:20:48 +01:00
|
|
|
0, as_caption("animation"), has_spoiler_)));
|
2018-06-19 01:31:34 +02:00
|
|
|
} else if (op == "emc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-06-19 01:31:34 +02:00
|
|
|
string caption;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, caption);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageCaption>(chat_id, message_id, nullptr, as_caption(caption)));
|
2018-06-19 01:31:34 +02:00
|
|
|
} else if (op == "emd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-06-19 01:31:34 +02:00
|
|
|
string document;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, document);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageMedia>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, nullptr,
|
2020-06-22 01:02:21 +02:00
|
|
|
td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), nullptr, false, as_caption(""))));
|
2022-12-16 14:36:51 +01:00
|
|
|
} else if (op == "emp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-06-19 01:31:34 +02:00
|
|
|
string photo;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, photo);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageMedia>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, nullptr,
|
2019-10-18 15:03:42 +02:00
|
|
|
td_api::make_object<td_api::inputMessagePhoto>(as_input_file(photo), as_input_thumbnail(photo), Auto(), 0, 0,
|
2022-12-28 19:46:16 +01:00
|
|
|
as_caption(""), message_self_destruct_time_, has_spoiler_)));
|
2018-06-19 01:31:34 +02:00
|
|
|
} else if (op == "emvt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-06-19 01:31:34 +02:00
|
|
|
string video;
|
|
|
|
string thumbnail;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, video, thumbnail);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageMedia>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, nullptr,
|
2019-10-18 15:03:42 +02:00
|
|
|
td_api::make_object<td_api::inputMessageVideo>(as_input_file(video), as_input_thumbnail(thumbnail), Auto(), 1,
|
2022-12-28 19:46:16 +01:00
|
|
|
2, 3, true, as_caption(""), message_self_destruct_time_,
|
2022-12-28 15:02:41 +01:00
|
|
|
has_spoiler_)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "emll") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-10-17 21:47:47 +02:00
|
|
|
string accuracy;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 heading;
|
|
|
|
int32 proximity_alert_radius;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, latitude, longitude, accuracy, heading, proximity_alert_radius);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageLiveLocation>(
|
|
|
|
chat_id, message_id, nullptr, as_location(latitude, longitude, accuracy), heading, proximity_alert_radius));
|
2019-12-03 02:36:23 +01:00
|
|
|
} else if (op == "emss") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2019-12-03 02:36:23 +01:00
|
|
|
string date;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, date);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::editMessageSchedulingState>(chat_id, message_id,
|
2021-12-31 12:20:34 +01:00
|
|
|
as_message_scheduling_state(date)));
|
2022-10-27 09:06:13 +02:00
|
|
|
} else if (op == "gftdi") {
|
|
|
|
send_request(td_api::make_object<td_api::getForumTopicDefaultIcons>());
|
2022-10-25 15:10:15 +02:00
|
|
|
} else if (op == "cft") {
|
|
|
|
ChatId chat_id;
|
2022-11-02 15:31:25 +01:00
|
|
|
string name;
|
2022-10-25 15:10:15 +02:00
|
|
|
int32 icon_color;
|
2022-11-02 15:31:25 +01:00
|
|
|
get_args(args, chat_id, name, icon_color);
|
2022-10-25 15:10:15 +02:00
|
|
|
send_request(td_api::make_object<td_api::createForumTopic>(
|
2022-11-02 15:31:25 +01:00
|
|
|
chat_id, name, td_api::make_object<td_api::forumTopicIcon>(icon_color, 0)));
|
2022-10-27 15:53:23 +02:00
|
|
|
} else if (op == "eft") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageThreadId message_thread_id;
|
2022-11-02 15:31:25 +01:00
|
|
|
string name;
|
2022-11-30 14:53:01 +01:00
|
|
|
bool edit_icon_custom_emoji;
|
2022-10-27 15:53:23 +02:00
|
|
|
int64 icon_custom_emoji_id;
|
2022-11-30 14:53:01 +01:00
|
|
|
get_args(args, chat_id, message_thread_id, name, edit_icon_custom_emoji, icon_custom_emoji_id);
|
|
|
|
send_request(td_api::make_object<td_api::editForumTopic>(chat_id, message_thread_id, name, edit_icon_custom_emoji,
|
|
|
|
icon_custom_emoji_id));
|
2022-12-02 15:04:24 +01:00
|
|
|
} else if (op == "gft") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageThreadId message_thread_id;
|
|
|
|
get_args(args, chat_id, message_thread_id);
|
|
|
|
send_request(td_api::make_object<td_api::getForumTopic>(chat_id, message_thread_id));
|
2022-12-05 11:03:38 +01:00
|
|
|
} else if (op == "gftl") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageThreadId message_thread_id;
|
|
|
|
get_args(args, chat_id, message_thread_id);
|
|
|
|
send_request(td_api::make_object<td_api::getForumTopicLink>(chat_id, message_thread_id));
|
2022-12-06 16:16:22 +01:00
|
|
|
} else if (op == "gfts") {
|
|
|
|
ChatId chat_id;
|
|
|
|
string query;
|
|
|
|
int32 offset_date;
|
|
|
|
MessageId offset_message_id;
|
|
|
|
MessageThreadId offset_message_thread_id;
|
|
|
|
string limit;
|
|
|
|
get_args(args, chat_id, query, offset_date, offset_message_id, offset_message_thread_id, limit);
|
|
|
|
send_request(td_api::make_object<td_api::getForumTopics>(chat_id, query, offset_date, offset_message_id,
|
|
|
|
offset_message_thread_id, as_limit(limit)));
|
2022-10-27 16:31:05 +02:00
|
|
|
} else if (op == "tftic") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageThreadId message_thread_id;
|
|
|
|
bool is_closed;
|
|
|
|
get_args(args, chat_id, message_thread_id, is_closed);
|
|
|
|
send_request(td_api::make_object<td_api::toggleForumTopicIsClosed>(chat_id, message_thread_id, is_closed));
|
2022-11-30 16:52:31 +01:00
|
|
|
} else if (op == "tgftih") {
|
|
|
|
ChatId chat_id;
|
|
|
|
bool is_hidden;
|
|
|
|
get_args(args, chat_id, is_hidden);
|
|
|
|
send_request(td_api::make_object<td_api::toggleGeneralForumTopicIsHidden>(chat_id, is_hidden));
|
2022-12-29 21:23:09 +01:00
|
|
|
} else if (op == "tftip") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageThreadId message_thread_id;
|
|
|
|
bool is_pinned;
|
|
|
|
get_args(args, chat_id, message_thread_id, is_pinned);
|
|
|
|
send_request(td_api::make_object<td_api::toggleForumTopicIsPinned>(chat_id, message_thread_id, is_pinned));
|
2022-12-29 21:48:19 +01:00
|
|
|
} else if (op == "spft") {
|
|
|
|
ChatId chat_id;
|
|
|
|
string message_thread_ids;
|
|
|
|
get_args(args, chat_id, message_thread_ids);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setPinnedForumTopics>(chat_id, as_message_thread_ids(message_thread_ids)));
|
2022-10-29 23:35:37 +02:00
|
|
|
} else if (op == "dft") {
|
|
|
|
ChatId chat_id;
|
|
|
|
MessageThreadId message_thread_id;
|
|
|
|
get_args(args, chat_id, message_thread_id);
|
|
|
|
send_request(td_api::make_object<td_api::deleteForumTopic>(chat_id, message_thread_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gallm") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getActiveLiveLocationMessages>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sbsm") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId bot_user_id;
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string parameter;
|
2021-12-31 12:56:57 +01:00
|
|
|
get_args(args, bot_user_id, chat_id, parameter);
|
|
|
|
send_request(td_api::make_object<td_api::sendBotStartMessage>(bot_user_id, chat_id, parameter));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "giqr") {
|
|
|
|
string bot_id;
|
|
|
|
string query;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, bot_id, query);
|
2021-10-28 20:46:34 +02:00
|
|
|
send_request(td_api::make_object<td_api::getInlineQueryResults>(as_user_id(bot_id), as_chat_id(bot_id), nullptr,
|
|
|
|
query, ""));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "giqro") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId bot_user_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string offset;
|
|
|
|
string query;
|
2021-12-31 12:56:57 +01:00
|
|
|
get_args(args, bot_user_id, offset, query);
|
|
|
|
send_request(td_api::make_object<td_api::getInlineQueryResults>(bot_user_id, 0, nullptr, query, offset));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "giqrl") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId bot_user_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string query;
|
2021-12-31 12:56:57 +01:00
|
|
|
get_args(args, bot_user_id, query);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::getInlineQueryResults>(bot_user_id, 0, as_location("1.1", "2.2", ""), query, ""));
|
2019-01-02 22:05:47 +01:00
|
|
|
} else if (op == "siqr" || op == "siqrh") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int64 query_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string result_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, query_id, result_id);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::sendInlineQueryResultMessage>(
|
2023-06-08 16:27:24 +02:00
|
|
|
chat_id, message_thread_id_, nullptr, default_message_send_options(), query_id, result_id, op == "siqrh"));
|
2020-08-18 08:32:37 +02:00
|
|
|
} else if (op == "gcqa") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string data;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, data);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getCallbackQueryAnswer>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, td_api::make_object<td_api::callbackQueryPayloadData>(data)));
|
2020-08-18 08:32:37 +02:00
|
|
|
} else if (op == "gcpqa") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-08-18 08:32:37 +02:00
|
|
|
string password;
|
|
|
|
string data;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, password, data);
|
2020-08-18 08:32:37 +02:00
|
|
|
send_request(td_api::make_object<td_api::getCallbackQueryAnswer>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, td_api::make_object<td_api::callbackQueryPayloadDataWithPassword>(password, data)));
|
2020-08-18 08:32:37 +02:00
|
|
|
} else if (op == "gcgqa") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getCallbackQueryAnswer>(
|
2021-12-31 12:31:43 +01:00
|
|
|
chat_id, message_id, td_api::make_object<td_api::callbackQueryPayloadGame>("")));
|
2021-12-04 23:00:28 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op == "san") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string animation_path;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 width;
|
|
|
|
int32 height;
|
2018-12-31 20:04:05 +01:00
|
|
|
string caption;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, animation_path, width, height, caption);
|
2020-12-26 18:26:19 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageAnimation>(as_input_file(animation_path), nullptr,
|
|
|
|
vector<int32>(), 60, width, height,
|
2022-12-26 12:20:48 +01:00
|
|
|
as_caption(caption), has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sang") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string animation_path;
|
|
|
|
string animation_conversion;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, animation_path, animation_conversion);
|
2020-05-29 10:51:51 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageAnimation>(
|
|
|
|
as_generated_file(animation_path, animation_conversion), nullptr, vector<int32>(), 60,
|
2022-12-26 12:20:48 +01:00
|
|
|
0, 0, as_caption(""), has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sanid") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string file_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, file_id);
|
2022-12-26 12:20:48 +01:00
|
|
|
send_message(chat_id,
|
|
|
|
td_api::make_object<td_api::inputMessageAnimation>(
|
|
|
|
as_input_file_id(file_id), nullptr, vector<int32>(), 0, 0, 0, as_caption(""), has_spoiler_));
|
2018-01-05 11:33:08 +01:00
|
|
|
} else if (op == "sanurl") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-01-05 11:33:08 +01:00
|
|
|
string url;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, url);
|
2022-12-26 12:20:48 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageAnimation>(as_generated_file(url, "#url#"), nullptr,
|
|
|
|
vector<int32>(), 0, 0, 0, as_caption(""),
|
|
|
|
has_spoiler_));
|
2018-01-05 11:33:08 +01:00
|
|
|
} else if (op == "sanurl2") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-01-05 11:33:08 +01:00
|
|
|
string url;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, url);
|
2020-05-29 10:51:51 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageAnimation>(
|
2022-12-26 12:20:48 +01:00
|
|
|
as_remote_file(url), nullptr, vector<int32>(), 0, 0, 0, as_caption(""), has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sau") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string audio_path;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 duration;
|
2018-12-31 20:04:05 +01:00
|
|
|
string title;
|
|
|
|
string performer;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, audio_path, duration, title, performer);
|
2020-12-26 18:26:19 +01:00
|
|
|
send_message(chat_id,
|
|
|
|
td_api::make_object<td_api::inputMessageAudio>(as_input_file(audio_path), nullptr, duration, title,
|
|
|
|
performer, as_caption("audio caption")));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "svoice") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string voice_path;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, voice_path);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageVoiceNote>(as_input_file(voice_path), 0, "abacaba",
|
|
|
|
as_caption("voice caption")));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "SendContact" || op == "scontact") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string phone_number;
|
|
|
|
string first_name;
|
|
|
|
string last_name;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, phone_number, first_name, last_name, user_id);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageContact>(td_api::make_object<td_api::contact>(
|
2021-12-31 12:56:57 +01:00
|
|
|
phone_number, first_name, last_name, string(), user_id)));
|
2019-08-09 19:28:49 +02:00
|
|
|
} else if (op == "sf" || op == "scopy") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
ChatId from_chat_id;
|
|
|
|
MessageId from_message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, from_chat_id, from_message_id);
|
2020-08-09 13:18:08 +02:00
|
|
|
td_api::object_ptr<td_api::messageCopyOptions> copy_options;
|
|
|
|
if (op == "scopy") {
|
2020-12-26 19:01:57 +01:00
|
|
|
copy_options = td_api::make_object<td_api::messageCopyOptions>(true, rand_bool(), as_caption("_as_d"));
|
2020-08-09 13:18:08 +02:00
|
|
|
}
|
2021-12-31 12:31:43 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageForwarded>(from_chat_id, from_message_id, true,
|
|
|
|
std::move(copy_options)));
|
2020-04-13 13:18:46 +02:00
|
|
|
} else if (op == "sdice" || op == "sdicecd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-04-18 07:45:41 +02:00
|
|
|
string emoji;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, emoji);
|
2020-04-18 07:45:41 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageDice>(emoji, op == "sdicecd"));
|
2020-06-22 01:02:21 +02:00
|
|
|
} else if (op == "sd" || op == "sdf") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string document_path;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, document_path);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
|
2020-06-22 01:02:21 +02:00
|
|
|
as_input_file(document_path), nullptr, op == "sdf",
|
2018-03-13 17:10:26 +01:00
|
|
|
as_caption(u8"\u1680\u180Etest \u180E\n\u180E\n\u180E\n cap\ttion\u180E\u180E")));
|
2020-06-22 01:02:21 +02:00
|
|
|
} else if (op == "sdt" || op == "sdtf") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string document_path;
|
|
|
|
string thumbnail_path;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, document_path, thumbnail_path);
|
2020-06-22 01:02:21 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
|
|
|
|
as_input_file(document_path), as_input_thumbnail(thumbnail_path), op == "sdtf",
|
|
|
|
as_caption("test caption")));
|
2019-01-19 20:35:28 +01:00
|
|
|
} else if (op == "sdg" || op == "sdgu") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string document_path;
|
|
|
|
string document_conversion;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, document_path, document_conversion);
|
2019-01-19 20:35:28 +01:00
|
|
|
if (op == "sdgu") {
|
2022-07-18 13:07:50 +02:00
|
|
|
send_request(td_api::make_object<td_api::preliminaryUploadFile>(
|
|
|
|
as_generated_file(document_path, document_conversion), nullptr, 1));
|
2019-01-19 20:35:28 +01:00
|
|
|
}
|
2020-06-22 01:02:21 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
|
|
|
|
as_generated_file(document_path, document_conversion), nullptr, false,
|
|
|
|
as_caption("test caption")));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sdtg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string document_path;
|
|
|
|
string thumbnail_path;
|
|
|
|
string thumbnail_conversion;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, document_path, thumbnail_path, thumbnail_conversion);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
|
2019-10-18 15:03:42 +02:00
|
|
|
as_input_file(document_path), as_input_thumbnail(thumbnail_path, thumbnail_conversion),
|
2020-06-22 01:02:21 +02:00
|
|
|
false, as_caption("test caption")));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sdgtg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string document_path;
|
|
|
|
string document_conversion;
|
|
|
|
string thumbnail_path;
|
|
|
|
string thumbnail_conversion;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, document_path, document_conversion, thumbnail_path, thumbnail_conversion);
|
2020-06-22 01:02:21 +02:00
|
|
|
send_message(chat_id,
|
|
|
|
td_api::make_object<td_api::inputMessageDocument>(
|
|
|
|
as_generated_file(document_path, document_conversion),
|
|
|
|
as_input_thumbnail(thumbnail_path, thumbnail_conversion), false, as_caption("test caption")));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sdid") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string file_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, file_id);
|
2020-06-22 01:02:21 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(as_input_file_id(file_id), nullptr, false,
|
2019-02-21 17:48:05 +01:00
|
|
|
as_caption("")));
|
2018-06-01 02:05:46 +02:00
|
|
|
} else if (op == "sdurl") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-06-01 02:05:46 +02:00
|
|
|
string url;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, url);
|
2020-06-22 01:02:21 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(as_remote_file(url), nullptr, false,
|
|
|
|
as_caption("")));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId bot_user_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string game_short_name;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, bot_user_id, game_short_name);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageGame>(bot_user_id, game_short_name));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sl") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-10-17 21:47:47 +02:00
|
|
|
string accuracy;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, latitude, longitude, accuracy);
|
2020-10-24 23:49:41 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageLocation>(
|
|
|
|
as_location(latitude, longitude, accuracy), 0, 0, 0));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sll") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 period;
|
2018-12-31 20:04:05 +01:00
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-10-17 21:47:47 +02:00
|
|
|
string accuracy;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 heading;
|
|
|
|
int32 proximity_alert_radius;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, period, latitude, longitude, accuracy, heading, proximity_alert_radius);
|
2020-10-17 21:47:47 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageLocation>(
|
2020-12-26 18:26:19 +01:00
|
|
|
as_location(latitude, longitude, accuracy), period, heading, proximity_alert_radius));
|
2020-01-13 23:51:03 +01:00
|
|
|
} else if (op == "spoll" || op == "spollm" || op == "spollp" || op == "squiz") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2019-02-19 14:45:32 +01:00
|
|
|
string question;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, question, args);
|
2022-01-24 15:40:16 +01:00
|
|
|
auto options = autosplit_str(args);
|
2020-01-11 01:46:26 +01:00
|
|
|
td_api::object_ptr<td_api::PollType> poll_type;
|
|
|
|
if (op == "squiz") {
|
2020-04-03 22:39:50 +02:00
|
|
|
poll_type = td_api::make_object<td_api::pollTypeQuiz>(narrow_cast<int32>(options.size() - 1),
|
|
|
|
as_formatted_text("_te*st*_"));
|
2020-01-11 01:46:26 +01:00
|
|
|
} else {
|
|
|
|
poll_type = td_api::make_object<td_api::pollTypeRegular>(op == "spollm");
|
|
|
|
}
|
2020-01-13 23:51:03 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessagePoll>(question, std::move(options), op != "spollp",
|
2020-04-03 15:50:10 +02:00
|
|
|
std::move(poll_type), 0, 0, false));
|
2022-12-16 14:36:51 +01:00
|
|
|
} else if (op == "sp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-02-05 23:42:43 +01:00
|
|
|
string photo;
|
|
|
|
string caption;
|
|
|
|
string sticker_file_ids;
|
|
|
|
get_args(args, chat_id, photo, caption, sticker_file_ids);
|
2019-04-08 18:53:26 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
|
2022-02-05 23:42:43 +01:00
|
|
|
as_input_file(photo), nullptr, to_integers<int32>(sticker_file_ids), 0, 0,
|
2022-12-28 19:46:16 +01:00
|
|
|
as_caption(caption), message_self_destruct_time_, has_spoiler_));
|
2022-12-16 14:36:51 +01:00
|
|
|
} else if (op == "spg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string photo_path;
|
|
|
|
string conversion;
|
2022-05-11 16:17:20 +02:00
|
|
|
int64 expected_size;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, photo_path, conversion, expected_size);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
|
2020-12-26 18:26:19 +01:00
|
|
|
as_generated_file(photo_path, conversion, expected_size), nullptr, vector<int32>(), 0,
|
2022-12-28 19:46:16 +01:00
|
|
|
0, as_caption(""), message_self_destruct_time_, has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string photo_path;
|
|
|
|
string thumbnail_path;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, photo_path, thumbnail_path);
|
2022-12-15 20:41:55 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
|
|
|
|
as_input_file(photo_path), as_input_thumbnail(thumbnail_path, 90, 89), vector<int32>(),
|
2022-12-28 19:46:16 +01:00
|
|
|
0, 0, as_caption(""), message_self_destruct_time_, has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sptg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string photo_path;
|
|
|
|
string thumbnail_path;
|
|
|
|
string thumbnail_conversion;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, photo_path, thumbnail_path, thumbnail_conversion);
|
2019-10-18 15:03:42 +02:00
|
|
|
send_message(chat_id,
|
|
|
|
td_api::make_object<td_api::inputMessagePhoto>(
|
|
|
|
as_input_file(photo_path), as_input_thumbnail(thumbnail_path, thumbnail_conversion, 90, 89),
|
2022-12-28 19:46:16 +01:00
|
|
|
vector<int32>(), 0, 0, as_caption(""), message_self_destruct_time_, has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spgtg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string photo_path;
|
|
|
|
string conversion;
|
|
|
|
string thumbnail_path;
|
|
|
|
string thumbnail_conversion;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, photo_path, conversion, thumbnail_path, thumbnail_conversion);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(
|
2018-12-31 20:04:05 +01:00
|
|
|
as_generated_file(photo_path, conversion),
|
2019-10-18 15:03:42 +02:00
|
|
|
as_input_thumbnail(thumbnail_path, thumbnail_conversion, 90, 89), vector<int32>(), 0, 0,
|
2022-12-28 19:46:16 +01:00
|
|
|
as_caption(""), message_self_destruct_time_, has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spid") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string file_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, file_id);
|
2022-12-28 15:02:41 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessagePhoto>(as_input_file_id(file_id), nullptr,
|
|
|
|
vector<int32>(), 0, 0, as_caption(""),
|
2022-12-28 19:46:16 +01:00
|
|
|
message_self_destruct_time_, has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ss") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string sticker_path;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, sticker_path);
|
2020-12-19 12:31:42 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageSticker>(as_input_file(sticker_path), nullptr, 0, 0,
|
|
|
|
string()));
|
2018-06-01 00:22:27 +02:00
|
|
|
} else if (op == "sstt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-06-01 00:22:27 +02:00
|
|
|
string sticker_path;
|
|
|
|
string thumbnail_path;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, sticker_path, thumbnail_path);
|
2020-12-19 12:31:42 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageSticker>(
|
|
|
|
as_input_file(sticker_path), as_input_thumbnail(thumbnail_path), 0, 0, string()));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ssid") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string file_id;
|
2020-12-19 12:31:42 +01:00
|
|
|
string emoji;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, file_id, emoji);
|
2020-12-19 12:31:42 +01:00
|
|
|
send_message(chat_id,
|
|
|
|
td_api::make_object<td_api::inputMessageSticker>(as_input_file_id(file_id), nullptr, 0, 0, emoji));
|
2023-06-12 18:23:58 +02:00
|
|
|
} else if (op == "sstory") {
|
|
|
|
ChatId chat_id;
|
2023-06-27 20:51:36 +02:00
|
|
|
ChatId story_sender_chat_id;
|
2023-06-12 18:23:58 +02:00
|
|
|
StoryId story_id;
|
2023-06-27 20:51:36 +02:00
|
|
|
get_args(args, chat_id, story_sender_chat_id, story_id);
|
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageStory>(story_sender_chat_id, story_id));
|
2022-12-16 14:36:51 +01:00
|
|
|
} else if (op == "sv") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string video_path;
|
|
|
|
string sticker_file_ids_str;
|
|
|
|
vector<int32> sticker_file_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, sticker_file_ids_str, video_path);
|
2018-12-31 20:04:05 +01:00
|
|
|
if (trim(video_path).empty()) {
|
|
|
|
video_path = sticker_file_ids_str;
|
|
|
|
} else {
|
2019-12-18 16:09:32 +01:00
|
|
|
sticker_file_ids = to_integers<int32>(sticker_file_ids_str);
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2022-12-28 15:02:41 +01:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageVideo>(
|
|
|
|
as_input_file(video_path), nullptr, std::move(sticker_file_ids), 1, 2, 3, true,
|
2022-12-28 19:46:16 +01:00
|
|
|
as_caption(""), message_self_destruct_time_, has_spoiler_));
|
2022-12-16 14:36:51 +01:00
|
|
|
} else if (op == "svt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2019-10-18 03:31:28 +02:00
|
|
|
string video;
|
|
|
|
string thumbnail;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, video, thumbnail);
|
2019-10-18 03:31:28 +02:00
|
|
|
send_message(chat_id, td_api::make_object<td_api::inputMessageVideo>(
|
2019-10-18 15:03:42 +02:00
|
|
|
as_input_file(video), as_input_thumbnail(thumbnail), vector<int32>(), 0, 0, 0, true,
|
2022-12-28 19:46:16 +01:00
|
|
|
as_caption(""), message_self_destruct_time_, has_spoiler_));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "svn") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string video_path;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, video_path);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_message(chat_id,
|
2021-07-29 22:39:07 +02:00
|
|
|
td_api::make_object<td_api::inputMessageVideoNote>(as_input_file(video_path), nullptr, 10, 5));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "svenue") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-10-17 21:47:47 +02:00
|
|
|
string accuracy;
|
2018-12-31 20:04:05 +01:00
|
|
|
string title;
|
|
|
|
string address;
|
|
|
|
string provider;
|
|
|
|
string venue_id;
|
2018-04-09 20:06:37 +02:00
|
|
|
string venue_type;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, latitude, longitude, accuracy, title, address, provider, venue_id, venue_type);
|
2020-10-17 21:47:47 +02:00
|
|
|
send_message(chat_id,
|
|
|
|
td_api::make_object<td_api::inputMessageVenue>(td_api::make_object<td_api::venue>(
|
|
|
|
as_location(latitude, longitude, accuracy), title, address, provider, venue_id, venue_type)));
|
2021-12-04 23:00:28 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op == "test") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::testNetwork>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "alarm") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setAlarm>(to_double(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "delete") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool remove_from_the_chat_list;
|
|
|
|
bool revoke;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, remove_from_the_chat_list, revoke);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteChatHistory>(chat_id, remove_from_the_chat_list, revoke));
|
2021-10-25 19:39:22 +02:00
|
|
|
} else if (op == "dcmbd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-10-25 19:39:22 +02:00
|
|
|
int32 min_date;
|
|
|
|
int32 max_date;
|
|
|
|
bool revoke;
|
|
|
|
get_args(args, chat_id, min_date, max_date, revoke);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteChatMessagesByDate>(chat_id, min_date, max_date, revoke));
|
2021-11-19 13:48:05 +01:00
|
|
|
} else if (op == "dcmbs") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-11-19 13:48:05 +01:00
|
|
|
string sender_id;
|
|
|
|
get_args(args, chat_id, sender_id);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::deleteChatMessagesBySender>(chat_id, as_message_sender(sender_id)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cnbgc") {
|
|
|
|
string user_ids_string;
|
|
|
|
string title;
|
2022-12-28 19:46:16 +01:00
|
|
|
int32 message_auto_delete_time;
|
|
|
|
get_args(args, user_ids_string, title, message_auto_delete_time);
|
2022-12-28 15:02:41 +01:00
|
|
|
send_request(td_api::make_object<td_api::createNewBasicGroupChat>(as_user_ids(user_ids_string), title,
|
2022-12-28 19:46:16 +01:00
|
|
|
message_auto_delete_time));
|
2022-12-28 15:02:41 +01:00
|
|
|
} else if (op == "cnchc" || op == "cnchcadt") {
|
2023-01-09 19:43:51 +01:00
|
|
|
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, false, true, "Description", nullptr,
|
2022-12-28 15:02:41 +01:00
|
|
|
op == "cnchcadt" ? 86400 : 0, false));
|
|
|
|
} else if (op == "cnsgc" || op == "cnsgcadt") {
|
2023-01-09 19:43:51 +01:00
|
|
|
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, false, false, "Description", nullptr,
|
2022-12-28 15:02:41 +01:00
|
|
|
op == "cnsgcadt" ? 86400 : 0, false));
|
2023-01-09 19:43:51 +01:00
|
|
|
} else if (op == "cnfc" || op == "cnfcadt") {
|
|
|
|
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, true, true, "Description", nullptr,
|
|
|
|
op == "cnfcadt" ? 86400 : 0, false));
|
2021-01-21 20:00:08 +01:00
|
|
|
} else if (op == "cnsgcloc") {
|
2019-10-14 16:51:12 +02:00
|
|
|
send_request(td_api::make_object<td_api::createNewSupergroupChat>(
|
2023-01-09 19:43:51 +01:00
|
|
|
args, false, false, "Description",
|
2022-11-29 13:44:12 +01:00
|
|
|
td_api::make_object<td_api::chatLocation>(as_location("40.0", "60.0", ""), "address"), 0, false));
|
2021-01-22 17:23:44 +01:00
|
|
|
} else if (op == "cnsgcimport") {
|
2023-01-09 19:43:51 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::createNewSupergroupChat>(args, false, false, "Description", nullptr, 0, true));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "UpgradeBasicGroupChatToSupergroupChat") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::upgradeBasicGroupChatToSupergroupChat>(chat_id));
|
2021-01-20 12:49:18 +01:00
|
|
|
} else if (op == "DeleteChat") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::deleteChat>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gcpc") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getCreatedPublicChats>());
|
2019-10-22 12:40:24 +02:00
|
|
|
} else if (op == "gcpcl") {
|
|
|
|
send_request(td_api::make_object<td_api::getCreatedPublicChats>(
|
|
|
|
td_api::make_object<td_api::publicChatTypeIsLocationBased>()));
|
2019-10-22 13:06:46 +02:00
|
|
|
} else if (op == "ccpcl") {
|
|
|
|
send_request(td_api::make_object<td_api::checkCreatedPublicChatsLimit>());
|
|
|
|
} else if (op == "ccpcll") {
|
|
|
|
send_request(td_api::make_object<td_api::checkCreatedPublicChatsLimit>(
|
|
|
|
td_api::make_object<td_api::publicChatTypeIsLocationBased>()));
|
2019-09-13 19:25:17 +02:00
|
|
|
} else if (op == "gsdc") {
|
|
|
|
send_request(td_api::make_object<td_api::getSuitableDiscussionChats>());
|
2019-12-13 15:27:44 +01:00
|
|
|
} else if (op == "gisc") {
|
|
|
|
send_request(td_api::make_object<td_api::getInactiveSupergroupChats>());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cpc") {
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool force;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, user_id, force);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::createPrivateChat>(user_id, force));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "cbgc") {
|
2018-01-23 22:45:26 +01:00
|
|
|
string basic_group_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool force;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, basic_group_id, force);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(td_api::make_object<td_api::createBasicGroupChat>(as_basic_group_id(basic_group_id), force));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "csgc" || op == "cchc") {
|
2018-01-23 22:45:26 +01:00
|
|
|
string supergroup_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool force;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, supergroup_id, force);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(td_api::make_object<td_api::createSupergroupChat>(as_supergroup_id(supergroup_id), force));
|
2020-05-31 02:50:52 +02:00
|
|
|
} else if (op == "gcltac") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatListsToAddChat>(chat_id));
|
2020-05-30 23:48:33 +02:00
|
|
|
} else if (op == "actl" || op == "actla" || begins_with(op, "actl-")) {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::addChatToList>(chat_id, as_chat_list(op)));
|
2020-05-18 01:29:28 +02:00
|
|
|
} else if (op == "gcf") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
|
|
|
get_args(args, chat_folder_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatFolder>(chat_folder_id));
|
2020-05-18 21:26:44 +02:00
|
|
|
} else if (op == "ccf") {
|
2023-04-03 16:28:51 +02:00
|
|
|
send_request(td_api::make_object<td_api::createChatFolder>(as_chat_folder(args)));
|
2020-05-29 09:02:34 +02:00
|
|
|
} else if (op == "ccfe") {
|
2023-04-03 16:28:51 +02:00
|
|
|
auto chat_folder = td_api::make_object<td_api::chatFolder>();
|
|
|
|
chat_folder->title_ = "empty";
|
|
|
|
chat_folder->included_chat_ids_ = as_chat_ids(args);
|
|
|
|
send_request(td_api::make_object<td_api::createChatFolder>(std::move(chat_folder)));
|
2023-03-30 17:39:51 +02:00
|
|
|
} else if (op == "ecf" || op == "ecfs") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
2020-05-18 23:47:34 +02:00
|
|
|
string filter;
|
2023-04-03 16:28:51 +02:00
|
|
|
get_args(args, chat_folder_id, filter);
|
|
|
|
send_request(td_api::make_object<td_api::editChatFolder>(chat_folder_id, as_chat_folder(filter, op == "ecfs")));
|
2020-05-19 00:06:24 +02:00
|
|
|
} else if (op == "dcf") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
2023-04-02 11:05:04 +02:00
|
|
|
string chat_ids;
|
2023-04-03 16:28:51 +02:00
|
|
|
get_args(args, chat_folder_id, chat_ids);
|
|
|
|
send_request(td_api::make_object<td_api::deleteChatFolder>(chat_folder_id, as_chat_ids(chat_ids)));
|
2023-04-02 11:40:57 +02:00
|
|
|
} else if (op == "gcfctl") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
|
|
|
get_args(args, chat_folder_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatFolderChatsToLeave>(chat_folder_id));
|
2023-05-01 13:57:16 +02:00
|
|
|
} else if (op == "gcfcc") {
|
|
|
|
send_request(td_api::make_object<td_api::getChatFolderChatCount>(as_chat_folder(args)));
|
2020-05-19 01:41:07 +02:00
|
|
|
} else if (op == "rcf") {
|
2022-05-19 20:19:06 +02:00
|
|
|
int32 main_chat_list_position;
|
2023-04-03 16:28:51 +02:00
|
|
|
string chat_folder_ids;
|
|
|
|
get_args(args, main_chat_list_position, chat_folder_ids);
|
|
|
|
send_request(td_api::make_object<td_api::reorderChatFolders>(as_chat_folder_ids(chat_folder_ids),
|
2022-05-19 20:19:06 +02:00
|
|
|
main_chat_list_position));
|
2023-04-09 20:54:40 +02:00
|
|
|
} else if (op == "gcfcfil") {
|
|
|
|
ChatFolderId chat_folder_id;
|
|
|
|
get_args(args, chat_folder_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatsForChatFolderInviteLink>(chat_folder_id));
|
2023-03-31 14:50:49 +02:00
|
|
|
} else if (op == "crcfil") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
2023-03-27 20:36:44 +02:00
|
|
|
string name;
|
|
|
|
string chat_ids;
|
2023-04-03 16:28:51 +02:00
|
|
|
get_args(args, chat_folder_id, name, chat_ids);
|
2023-03-27 20:36:44 +02:00
|
|
|
send_request(
|
2023-04-03 16:28:51 +02:00
|
|
|
td_api::make_object<td_api::createChatFolderInviteLink>(chat_folder_id, name, as_chat_ids(chat_ids)));
|
2023-03-30 16:15:04 +02:00
|
|
|
} else if (op == "gcfil") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
|
|
|
get_args(args, chat_folder_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatFolderInviteLinks>(chat_folder_id));
|
2023-03-30 18:37:01 +02:00
|
|
|
} else if (op == "ecfil") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
2023-03-30 18:37:01 +02:00
|
|
|
string invite_link;
|
|
|
|
string name;
|
|
|
|
string chat_ids;
|
2023-04-03 16:28:51 +02:00
|
|
|
get_args(args, chat_folder_id, invite_link, name, chat_ids);
|
|
|
|
send_request(td_api::make_object<td_api::editChatFolderInviteLink>(chat_folder_id, invite_link, name,
|
2023-03-30 18:37:01 +02:00
|
|
|
as_chat_ids(chat_ids)));
|
2023-03-30 18:52:55 +02:00
|
|
|
} else if (op == "dcfil") {
|
2023-04-03 16:28:51 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
2023-03-30 18:52:55 +02:00
|
|
|
string invite_link;
|
2023-04-03 16:28:51 +02:00
|
|
|
get_args(args, chat_folder_id, invite_link);
|
|
|
|
send_request(td_api::make_object<td_api::deleteChatFolderInviteLink>(chat_folder_id, invite_link));
|
2023-03-31 14:50:49 +02:00
|
|
|
} else if (op == "ccfil") {
|
2023-04-03 16:28:51 +02:00
|
|
|
send_request(td_api::make_object<td_api::checkChatFolderInviteLink>(args));
|
2023-03-31 15:48:32 +02:00
|
|
|
} else if (op == "acfbil") {
|
|
|
|
string invite_link;
|
|
|
|
string chat_ids;
|
|
|
|
get_args(args, invite_link, chat_ids);
|
2023-04-03 16:28:51 +02:00
|
|
|
send_request(td_api::make_object<td_api::addChatFolderByInviteLink>(invite_link, as_chat_ids(chat_ids)));
|
2023-04-04 15:21:31 +02:00
|
|
|
} else if (op == "gcfnc") {
|
|
|
|
ChatFolderId chat_folder_id;
|
|
|
|
get_args(args, chat_folder_id);
|
|
|
|
send_request(td_api::make_object<td_api::getChatFolderNewChats>(chat_folder_id));
|
2023-04-12 00:52:36 +02:00
|
|
|
} else if (op == "pcfnc") {
|
2023-04-04 15:35:31 +02:00
|
|
|
ChatFolderId chat_folder_id;
|
|
|
|
string chat_ids;
|
|
|
|
get_args(args, chat_folder_id, chat_ids);
|
2023-04-12 00:52:36 +02:00
|
|
|
send_request(td_api::make_object<td_api::processChatFolderNewChats>(chat_folder_id, as_chat_ids(chat_ids)));
|
2020-05-19 03:03:15 +02:00
|
|
|
} else if (op == "grcf") {
|
2023-04-03 16:28:51 +02:00
|
|
|
send_request(td_api::make_object<td_api::getRecommendedChatFolders>());
|
2020-06-05 02:43:13 +02:00
|
|
|
} else if (op == "gcfdin") {
|
2023-04-03 16:28:51 +02:00
|
|
|
execute(td_api::make_object<td_api::getChatFolderDefaultIconName>(as_chat_folder(args)));
|
2023-07-14 13:54:35 +02:00
|
|
|
} else if (op == "gacls") {
|
|
|
|
send_request(td_api::make_object<td_api::getArchiveChatListSettings>());
|
2023-07-14 14:25:32 +02:00
|
|
|
} else if (op == "sacls") {
|
|
|
|
bool archive_and_mute_new_chats_from_unknown_users;
|
|
|
|
bool keep_unmuted_chats_archived;
|
2023-07-14 17:51:47 +02:00
|
|
|
bool keep_chats_from_folders_archived;
|
2023-07-14 14:25:32 +02:00
|
|
|
get_args(args, archive_and_mute_new_chats_from_unknown_users, keep_unmuted_chats_archived,
|
2023-07-14 17:51:47 +02:00
|
|
|
keep_chats_from_folders_archived);
|
2023-07-14 14:25:32 +02:00
|
|
|
auto settings = td_api::make_object<td_api::archiveChatListSettings>(
|
2023-07-14 17:51:47 +02:00
|
|
|
archive_and_mute_new_chats_from_unknown_users, keep_unmuted_chats_archived, keep_chats_from_folders_archived);
|
2023-07-14 14:25:32 +02:00
|
|
|
send_request(td_api::make_object<td_api::setArchiveChatListSettings>(std::move(settings)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sct") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string title;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, title);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::setChatTitle>(chat_id, title));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "scp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2023-03-29 21:42:19 +02:00
|
|
|
InputChatPhoto input_chat_photo;
|
|
|
|
get_args(args, chat_id, input_chat_photo);
|
|
|
|
send_request(td_api::make_object<td_api::setChatPhoto>(chat_id, input_chat_photo));
|
2021-12-21 12:06:15 +01:00
|
|
|
} else if (op == "scmt") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-12-28 19:46:16 +01:00
|
|
|
int32 auto_delete_time;
|
|
|
|
get_args(args, chat_id, auto_delete_time);
|
|
|
|
send_request(td_api::make_object<td_api::setChatMessageAutoDeleteTime>(chat_id, auto_delete_time));
|
2019-03-20 18:58:13 +01:00
|
|
|
} else if (op == "scperm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2019-03-20 18:58:13 +01:00
|
|
|
string permissions;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, permissions);
|
2023-01-06 12:16:34 +01:00
|
|
|
constexpr size_t EXPECTED_SIZE = 14;
|
|
|
|
if (permissions.size() == EXPECTED_SIZE) {
|
2019-03-20 18:58:13 +01:00
|
|
|
auto &s = permissions;
|
|
|
|
send_request(td_api::make_object<td_api::setChatPermissions>(
|
2021-12-31 12:20:34 +01:00
|
|
|
chat_id, td_api::make_object<td_api::chatPermissions>(s[0] == '1', s[1] == '1', s[2] == '1', s[3] == '1',
|
2022-10-23 12:20:53 +02:00
|
|
|
s[4] == '1', s[5] == '1', s[6] == '1', s[7] == '1',
|
2023-01-06 12:16:34 +01:00
|
|
|
s[8] == '1', s[9] == '1', s[10] == '1', s[11] == '1',
|
|
|
|
s[12] == '1', s[13] == '1')));
|
2019-03-20 18:58:13 +01:00
|
|
|
} else {
|
2023-01-06 12:16:34 +01:00
|
|
|
LOG(ERROR) << "Wrong permissions size, expected " << EXPECTED_SIZE;
|
2019-03-20 18:58:13 +01:00
|
|
|
}
|
2021-08-27 18:23:22 +02:00
|
|
|
} else if (op == "sctn") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-08-27 18:23:22 +02:00
|
|
|
string theme_name;
|
|
|
|
get_args(args, chat_id, theme_name);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::setChatTheme>(chat_id, theme_name));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sccd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string client_data;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, client_data);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::setChatClientData>(chat_id, client_data));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "acm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 forward_limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, user_id, forward_limit);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::addChatMember>(chat_id, user_id, forward_limit));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "acms") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string user_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, user_ids);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::addChatMembers>(chat_id, as_user_ids(user_ids)));
|
2021-01-20 19:12:48 +01:00
|
|
|
} else if (op == "bcm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-03-26 02:11:30 +01:00
|
|
|
string member_id;
|
2021-01-20 19:12:48 +01:00
|
|
|
int32 banned_until_date;
|
|
|
|
bool revoke_messages;
|
2021-03-26 02:11:30 +01:00
|
|
|
get_args(args, chat_id, member_id, banned_until_date, revoke_messages);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::banChatMember>(chat_id, as_message_sender(member_id), banned_until_date,
|
|
|
|
revoke_messages));
|
2019-02-21 13:23:05 +01:00
|
|
|
} else if (op == "spolla") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2019-02-21 13:23:05 +01:00
|
|
|
string option_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, option_ids);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::setPollAnswer>(chat_id, message_id, to_integers<int32>(option_ids)));
|
2020-01-13 19:21:58 +01:00
|
|
|
} else if (op == "gpollv") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 option_id;
|
|
|
|
int32 offset;
|
2020-01-18 05:01:05 +01:00
|
|
|
string limit;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, option_id, offset, limit);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getPollVoters>(chat_id, message_id, option_id, offset, as_limit(limit)));
|
2019-02-22 16:09:55 +01:00
|
|
|
} else if (op == "stoppoll") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::stopPoll>(chat_id, message_id, nullptr));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op == "scms") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-03-26 02:11:30 +01:00
|
|
|
string member_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string status_str;
|
2019-12-03 02:36:23 +01:00
|
|
|
td_api::object_ptr<td_api::ChatMemberStatus> status;
|
2021-03-26 02:11:30 +01:00
|
|
|
get_args(args, chat_id, member_id, status_str);
|
2018-03-20 13:18:16 +01:00
|
|
|
if (status_str == "member") {
|
2019-02-21 17:48:05 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusMember>();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "left") {
|
2019-02-21 17:48:05 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusLeft>();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "banned") {
|
2019-02-21 17:48:05 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusBanned>(std::numeric_limits<int32>::max());
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "creator") {
|
2020-09-28 00:15:56 +02:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusCreator>("", false, true);
|
2020-12-03 21:20:56 +01:00
|
|
|
} else if (status_str == "creatortitle") {
|
|
|
|
status = td_api::make_object<td_api::chatMemberStatusCreator>("owner", false, true);
|
2020-09-11 00:49:15 +02:00
|
|
|
} else if (status_str == "creatoranon") {
|
2020-09-28 00:15:56 +02:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusCreator>("", true, true);
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "uncreator") {
|
2020-09-28 00:15:56 +02:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusCreator>("", false, false);
|
|
|
|
} else if (status_str == "anonadmin") {
|
2022-03-22 11:17:48 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
|
|
|
"anon", true,
|
2022-10-23 12:20:53 +02:00
|
|
|
as_chat_administrator_rights(true, true, true, true, true, true, true, true, true, true, true, true));
|
2021-02-19 13:58:14 +01:00
|
|
|
} else if (status_str == "anon") {
|
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
2022-03-22 11:17:48 +01:00
|
|
|
"anon", false,
|
2022-10-23 12:20:53 +02:00
|
|
|
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, false, false,
|
|
|
|
true));
|
2020-10-26 21:11:27 +01:00
|
|
|
} else if (status_str == "addadmin") {
|
2021-02-19 13:58:14 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
2022-03-22 11:17:48 +01:00
|
|
|
"anon", false,
|
2022-10-23 12:20:53 +02:00
|
|
|
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, true, false,
|
|
|
|
false));
|
2020-12-18 13:20:05 +01:00
|
|
|
} else if (status_str == "calladmin") {
|
2021-02-19 13:58:14 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
2022-03-22 11:17:48 +01:00
|
|
|
"anon", false,
|
2022-10-23 12:20:53 +02:00
|
|
|
as_chat_administrator_rights(false, false, false, false, false, false, false, false, false, false, true,
|
|
|
|
false));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "admin") {
|
2022-03-22 11:17:48 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
2022-10-23 12:20:53 +02:00
|
|
|
"", true,
|
|
|
|
as_chat_administrator_rights(false, true, true, true, true, true, true, true, true, true, true, false));
|
2019-11-11 17:14:32 +01:00
|
|
|
} else if (status_str == "adminq") {
|
2022-03-22 11:17:48 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
|
|
|
"title", true,
|
2022-10-23 12:20:53 +02:00
|
|
|
as_chat_administrator_rights(false, true, true, true, true, true, true, true, true, true, true, false));
|
2019-07-28 19:34:53 +02:00
|
|
|
} else if (status_str == "minadmin") {
|
2022-03-22 11:17:48 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>(
|
|
|
|
"", true,
|
2022-10-23 12:20:53 +02:00
|
|
|
as_chat_administrator_rights(true, false, false, false, false, false, false, false, false, false, false,
|
|
|
|
false));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "unadmin") {
|
2022-03-22 11:17:48 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusAdministrator>("", true, nullptr);
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "rest") {
|
2019-02-21 17:48:05 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
2019-03-20 13:28:06 +01:00
|
|
|
true, static_cast<int32>(120 + std::time(nullptr)),
|
2023-01-06 12:16:34 +01:00
|
|
|
td_api::make_object<td_api::chatPermissions>(false, false, false, false, false, false, false, false, false,
|
|
|
|
false, false, false, false, false));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "restkick") {
|
2019-02-21 17:48:05 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
2019-03-20 13:28:06 +01:00
|
|
|
false, static_cast<int32>(120 + std::time(nullptr)),
|
2023-01-06 12:16:34 +01:00
|
|
|
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false,
|
|
|
|
false, false, false, false, false));
|
2019-01-01 22:14:03 +01:00
|
|
|
} else if (status_str == "restunkick") {
|
2019-02-21 17:48:05 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
2019-03-20 13:28:06 +01:00
|
|
|
true, static_cast<int32>(120 + std::time(nullptr)),
|
2023-01-06 12:16:34 +01:00
|
|
|
td_api::make_object<td_api::chatPermissions>(true, false, false, false, false, false, false, false, false,
|
|
|
|
false, false, false, false, false));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (status_str == "unrest") {
|
2019-03-20 13:28:06 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusRestricted>(
|
2022-10-23 12:20:53 +02:00
|
|
|
true, 0,
|
2023-01-06 12:16:34 +01:00
|
|
|
td_api::make_object<td_api::chatPermissions>(true, true, true, true, true, true, true, true, true, true,
|
|
|
|
true, true, true, true));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
if (status != nullptr) {
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setChatMemberStatus>(chat_id, as_message_sender(member_id), std::move(status)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
LOG(ERROR) << "Unknown status \"" << status_str << "\"";
|
|
|
|
}
|
2019-10-17 18:43:41 +02:00
|
|
|
} else if (op == "cto") {
|
|
|
|
send_request(td_api::make_object<td_api::canTransferOwnership>());
|
2019-10-17 16:05:01 +02:00
|
|
|
} else if (op == "transferChatOwnership") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2019-10-17 16:05:01 +02:00
|
|
|
string password;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, user_id, password);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::transferChatOwnership>(chat_id, user_id, password));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "log") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string limit;
|
2021-12-17 17:15:16 +01:00
|
|
|
string user_ids;
|
|
|
|
get_args(args, chat_id, limit, user_ids);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatEventLog>(chat_id, "", 0, as_limit(limit), nullptr,
|
2021-12-17 17:15:16 +01:00
|
|
|
as_user_ids(user_ids)));
|
2018-08-16 19:09:23 +02:00
|
|
|
} else if (op == "join") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::joinChat>(chat_id));
|
2018-08-16 19:09:23 +02:00
|
|
|
} else if (op == "leave") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::leaveChat>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "dcm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-03-26 02:11:30 +01:00
|
|
|
string member_id;
|
|
|
|
get_args(args, chat_id, member_id);
|
2019-02-21 17:48:05 +01:00
|
|
|
td_api::object_ptr<td_api::ChatMemberStatus> status = td_api::make_object<td_api::chatMemberStatusBanned>();
|
2021-03-26 02:11:30 +01:00
|
|
|
if (as_user_id(member_id) == my_id_) {
|
2019-02-21 17:48:05 +01:00
|
|
|
status = td_api::make_object<td_api::chatMemberStatusLeft>();
|
2018-06-15 21:52:52 +02:00
|
|
|
}
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setChatMemberStatus>(chat_id, as_message_sender(member_id), std::move(status)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sn") {
|
|
|
|
string first_name;
|
|
|
|
string last_name;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, first_name, last_name);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setName>(first_name, last_name));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sb") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setBio>("\n" + args + "\n" + args + "\n"));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sun") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setUsername>(args));
|
2022-10-17 13:04:22 +02:00
|
|
|
} else if (op == "tunia") {
|
|
|
|
string username;
|
|
|
|
bool is_active;
|
|
|
|
get_args(args, username, is_active);
|
|
|
|
send_request(td_api::make_object<td_api::toggleUsernameIsActive>(username, is_active));
|
2022-10-14 14:32:54 +02:00
|
|
|
} else if (op == "raun") {
|
|
|
|
send_request(td_api::make_object<td_api::reorderActiveUsernames>(autosplit_str(args)));
|
2022-09-07 09:25:21 +02:00
|
|
|
} else if (op == "sese") {
|
2023-07-06 19:14:42 +02:00
|
|
|
send_request(td_api::make_object<td_api::setEmojiStatus>(nullptr));
|
2022-09-07 09:25:21 +02:00
|
|
|
} else if (op == "ses") {
|
2022-09-01 21:04:33 +02:00
|
|
|
int64 custom_emoji_id;
|
2023-07-06 19:14:42 +02:00
|
|
|
int32 expiration_date;
|
|
|
|
get_args(args, custom_emoji_id, expiration_date);
|
2022-09-07 09:25:21 +02:00
|
|
|
send_request(td_api::make_object<td_api::setEmojiStatus>(
|
2023-07-06 19:14:42 +02:00
|
|
|
td_api::make_object<td_api::emojiStatus>(custom_emoji_id, expiration_date)));
|
2022-09-07 09:25:21 +02:00
|
|
|
} else if (op == "gtes") {
|
|
|
|
send_request(td_api::make_object<td_api::getThemedEmojiStatuses>());
|
|
|
|
} else if (op == "gdes") {
|
|
|
|
send_request(td_api::make_object<td_api::getDefaultEmojiStatuses>());
|
|
|
|
} else if (op == "gres") {
|
|
|
|
send_request(td_api::make_object<td_api::getRecentEmojiStatuses>());
|
|
|
|
} else if (op == "cres") {
|
|
|
|
send_request(td_api::make_object<td_api::clearRecentEmojiStatuses>());
|
2018-03-02 00:19:00 +01:00
|
|
|
} else if (op == "ccun") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-03-02 00:19:00 +01:00
|
|
|
string username;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, username);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::checkChatUsername>(chat_id, username));
|
2018-03-02 00:19:00 +01:00
|
|
|
} else if (op == "ssgun" || op == "schun") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string supergroup_id;
|
|
|
|
string username;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, supergroup_id, username);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setSupergroupUsername>(as_supergroup_id(supergroup_id), username));
|
2022-10-17 13:04:22 +02:00
|
|
|
} else if (op == "tsgunia" || op == "tchunia") {
|
|
|
|
string supergroup_id;
|
|
|
|
string username;
|
|
|
|
bool is_active;
|
|
|
|
get_args(args, supergroup_id, username, is_active);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSupergroupUsernameIsActive>(as_supergroup_id(supergroup_id),
|
|
|
|
username, is_active));
|
2022-10-17 13:58:47 +02:00
|
|
|
} else if (op == "dasgun" || op == "dachun") {
|
|
|
|
string supergroup_id;
|
|
|
|
get_args(args, supergroup_id);
|
|
|
|
send_request(td_api::make_object<td_api::disableAllSupergroupUsernames>(as_supergroup_id(supergroup_id)));
|
2022-10-14 14:32:54 +02:00
|
|
|
} else if (op == "rsgaun" || op == "rchaun") {
|
|
|
|
string supergroup_id;
|
2022-10-24 12:34:20 +02:00
|
|
|
get_args(args, supergroup_id, args);
|
2022-10-14 14:32:54 +02:00
|
|
|
send_request(td_api::make_object<td_api::reorderSupergroupActiveUsernames>(as_supergroup_id(supergroup_id),
|
|
|
|
autosplit_str(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "ssgss") {
|
|
|
|
string supergroup_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int64 sticker_set_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, supergroup_id, sticker_set_id);
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setSupergroupStickerSet>(as_supergroup_id(supergroup_id), sticker_set_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "tsgp") {
|
|
|
|
string supergroup_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_all_history_available;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, supergroup_id, is_all_history_available);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(td_api::make_object<td_api::toggleSupergroupIsAllHistoryAvailable>(as_supergroup_id(supergroup_id),
|
|
|
|
is_all_history_available));
|
2022-12-20 13:51:37 +01:00
|
|
|
} else if (op == "tsghhm") {
|
|
|
|
string supergroup_id;
|
|
|
|
bool has_hidden_members;
|
|
|
|
get_args(args, supergroup_id, has_hidden_members);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSupergroupHasHiddenMembers>(as_supergroup_id(supergroup_id),
|
|
|
|
has_hidden_members));
|
2022-11-25 14:06:04 +01:00
|
|
|
} else if (op == "tsgas") {
|
|
|
|
string supergroup_id;
|
2022-12-27 17:14:37 +01:00
|
|
|
bool has_aggressive_anti_spam_enabled;
|
|
|
|
get_args(args, supergroup_id, has_aggressive_anti_spam_enabled);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSupergroupHasAggressiveAntiSpamEnabled>(
|
|
|
|
as_supergroup_id(supergroup_id), has_aggressive_anti_spam_enabled));
|
2022-10-25 10:52:45 +02:00
|
|
|
} else if (op == "tsgif") {
|
|
|
|
string supergroup_id;
|
|
|
|
bool is_forum;
|
|
|
|
get_args(args, supergroup_id, is_forum);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSupergroupIsForum>(as_supergroup_id(supergroup_id), is_forum));
|
2021-02-16 23:06:35 +01:00
|
|
|
} else if (op == "ToggleSupergroupIsBroadcastGroup") {
|
|
|
|
string supergroup_id;
|
|
|
|
get_args(args, supergroup_id);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSupergroupIsBroadcastGroup>(as_supergroup_id(supergroup_id)));
|
2018-03-27 16:55:33 +02:00
|
|
|
} else if (op == "tsgsm") {
|
|
|
|
string supergroup_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool sign_messages;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, supergroup_id, sign_messages);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::toggleSupergroupSignMessages>(as_supergroup_id(supergroup_id), sign_messages));
|
2022-04-29 17:25:29 +02:00
|
|
|
} else if (op == "tsgjtsm") {
|
|
|
|
string supergroup_id;
|
|
|
|
bool join_to_send_message;
|
|
|
|
get_args(args, supergroup_id, join_to_send_message);
|
|
|
|
send_request(td_api::make_object<td_api::toggleSupergroupJoinToSendMessages>(as_supergroup_id(supergroup_id),
|
|
|
|
join_to_send_message));
|
2022-05-02 14:45:35 +02:00
|
|
|
} else if (op == "tsgjbr") {
|
2022-04-29 17:25:29 +02:00
|
|
|
string supergroup_id;
|
|
|
|
bool join_by_request;
|
|
|
|
get_args(args, supergroup_id, join_by_request);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::toggleSupergroupJoinByRequest>(as_supergroup_id(supergroup_id), join_by_request));
|
2022-01-05 14:23:35 +01:00
|
|
|
} else if (op == "scar") {
|
|
|
|
ChatId chat_id;
|
|
|
|
string available_reactions;
|
|
|
|
get_args(args, chat_id, available_reactions);
|
2022-08-30 10:45:27 +02:00
|
|
|
td_api::object_ptr<td_api::ChatAvailableReactions> chat_available_reactions;
|
|
|
|
if (available_reactions == "all") {
|
|
|
|
chat_available_reactions = td_api::make_object<td_api::chatAvailableReactionsAll>();
|
|
|
|
} else if (!available_reactions.empty()) {
|
|
|
|
auto reactions = transform(autosplit_str(available_reactions), as_reaction_type);
|
|
|
|
chat_available_reactions = td_api::make_object<td_api::chatAvailableReactionsSome>(std::move(reactions));
|
|
|
|
}
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setChatAvailableReactions>(chat_id, std::move(chat_available_reactions)));
|
2019-03-18 03:24:25 +01:00
|
|
|
} else if (op == "scd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string description;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, description);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::setChatDescription>(chat_id, description));
|
2019-09-14 04:35:56 +02:00
|
|
|
} else if (op == "scdg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
ChatId group_chat_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, group_chat_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::setChatDiscussionGroup>(chat_id, group_chat_id));
|
2019-10-14 18:07:31 +02:00
|
|
|
} else if (op == "scl") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2019-10-14 18:07:31 +02:00
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, latitude, longitude);
|
2019-10-14 18:07:31 +02:00
|
|
|
send_request(td_api::make_object<td_api::setChatLocation>(
|
2021-12-31 12:20:34 +01:00
|
|
|
chat_id, td_api::make_object<td_api::chatLocation>(as_location(latitude, longitude, string()), "address")));
|
2019-11-15 16:17:52 +01:00
|
|
|
} else if (op == "scsmd") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 slow_mode_delay;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, slow_mode_delay);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::setChatSlowModeDelay>(chat_id, slow_mode_delay));
|
2020-10-23 01:12:32 +02:00
|
|
|
} else if (op == "pcm" || op == "pcms" || op == "pcmo") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::pinChatMessage>(chat_id, message_id, op == "pcms", op == "pcmo"));
|
2019-02-01 13:19:32 +01:00
|
|
|
} else if (op == "upcm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::unpinChatMessage>(chat_id, message_id));
|
2020-10-23 00:56:06 +02:00
|
|
|
} else if (op == "uacm") {
|
2022-10-31 18:03:28 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::unpinAllChatMessages>(chat_id));
|
|
|
|
} else if (op == "uamtm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-10-31 17:44:01 +01:00
|
|
|
MessageThreadId message_thread_id;
|
|
|
|
get_args(args, chat_id, message_thread_id);
|
2022-10-31 18:03:28 +01:00
|
|
|
send_request(td_api::make_object<td_api::unpinAllMessageThreadMessages>(chat_id, message_thread_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "grib") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getRecentInlineBots>());
|
2021-01-14 17:39:51 +01:00
|
|
|
} else if (op == "spc" || op == "su") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchPublicChat>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "spcs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchPublicChats>(args));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sc") {
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, query);
|
|
|
|
send_request(td_api::make_object<td_api::searchChats>(query.query, query.limit));
|
2018-01-16 19:56:59 +01:00
|
|
|
} else if (op == "scos") {
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, query);
|
|
|
|
send_request(td_api::make_object<td_api::searchChatsOnServer>(query.query, query.limit));
|
2019-10-16 20:55:16 +02:00
|
|
|
} else if (op == "scn") {
|
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, latitude, longitude);
|
2021-10-19 17:11:16 +02:00
|
|
|
send_request(td_api::make_object<td_api::searchChatsNearby>(as_location(latitude, longitude, string())));
|
2020-02-14 14:17:45 +01:00
|
|
|
} else if (op == "sloc") {
|
|
|
|
string latitude;
|
|
|
|
string longitude;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, latitude, longitude);
|
2021-10-19 17:11:16 +02:00
|
|
|
send_request(td_api::make_object<td_api::setLocation>(as_location(latitude, longitude, string())));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sco") {
|
2020-12-26 18:47:51 +01:00
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, query);
|
|
|
|
send_request(td_api::make_object<td_api::searchContacts>(query.query, query.limit));
|
2023-05-16 20:41:19 +02:00
|
|
|
} else if (op == "srfc") {
|
|
|
|
SearchQuery query;
|
|
|
|
get_args(args, query);
|
|
|
|
send_request(td_api::make_object<td_api::searchRecentlyFoundChats>(query.query, query.limit));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "arfc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::addRecentlyFoundChat>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rrfc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::removeRecentlyFoundChat>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "crfcs") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::clearRecentlyFoundChats>());
|
2021-09-14 13:18:37 +02:00
|
|
|
} else if (op == "groc") {
|
|
|
|
send_request(td_api::make_object<td_api::getRecentlyOpenedChats>(as_limit(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gwpp") {
|
2023-02-15 13:05:37 +01:00
|
|
|
send_request(td_api::make_object<td_api::getWebPagePreview>(as_formatted_text(args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gwpiv") {
|
|
|
|
string url;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool force_full;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, url, force_full);
|
2020-12-26 17:59:45 +01:00
|
|
|
send_request(td_api::make_object<td_api::getWebPageInstantView>(url, force_full));
|
2023-03-29 21:42:19 +02:00
|
|
|
} else if (op == "spp" || op == "spppf") {
|
|
|
|
InputChatPhoto input_chat_photo;
|
|
|
|
get_args(args, input_chat_photo);
|
|
|
|
send_request(td_api::make_object<td_api::setProfilePhoto>(input_chat_photo, op == "sppf"));
|
2022-12-15 16:12:30 +01:00
|
|
|
} else if (op == "suppp") {
|
|
|
|
UserId user_id;
|
2023-03-29 21:42:19 +02:00
|
|
|
InputChatPhoto input_chat_photo;
|
|
|
|
get_args(args, user_id, input_chat_photo);
|
|
|
|
send_request(td_api::make_object<td_api::setUserPersonalProfilePhoto>(user_id, input_chat_photo));
|
2022-12-26 11:49:00 +01:00
|
|
|
} else if (op == "supp") {
|
2022-12-15 16:12:30 +01:00
|
|
|
UserId user_id;
|
2023-03-29 21:42:19 +02:00
|
|
|
InputChatPhoto input_chat_photo;
|
|
|
|
get_args(args, user_id, input_chat_photo);
|
|
|
|
send_request(td_api::make_object<td_api::suggestUserProfilePhoto>(user_id, input_chat_photo));
|
2023-04-17 11:23:21 +02:00
|
|
|
} else if (op == "gbi") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
get_args(args, bot_user_id, language_code);
|
|
|
|
send_request(td_api::make_object<td_api::getBotName>(bot_user_id, language_code));
|
|
|
|
send_request(td_api::make_object<td_api::getBotInfoDescription>(bot_user_id, language_code));
|
|
|
|
send_request(td_api::make_object<td_api::getBotInfoShortDescription>(bot_user_id, language_code));
|
2023-04-17 12:28:26 +02:00
|
|
|
} else if (op == "sbi") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
string name;
|
|
|
|
string description;
|
|
|
|
string short_description;
|
|
|
|
get_args(args, bot_user_id, language_code, name, description, short_description);
|
|
|
|
send_request(td_api::make_object<td_api::setBotName>(bot_user_id, language_code, name));
|
|
|
|
send_request(td_api::make_object<td_api::setBotInfoDescription>(bot_user_id, language_code, description));
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setBotInfoShortDescription>(bot_user_id, language_code, short_description));
|
2023-03-28 17:42:54 +02:00
|
|
|
} else if (op == "sbn") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
string name;
|
|
|
|
get_args(args, bot_user_id, language_code, name);
|
|
|
|
send_request(td_api::make_object<td_api::setBotName>(bot_user_id, language_code, name));
|
|
|
|
} else if (op == "gbn") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
get_args(args, bot_user_id, language_code);
|
|
|
|
send_request(td_api::make_object<td_api::getBotName>(bot_user_id, language_code));
|
2023-03-29 21:45:13 +02:00
|
|
|
} else if (op == "sbpp") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
InputChatPhoto input_chat_photo;
|
|
|
|
get_args(args, bot_user_id, input_chat_photo);
|
|
|
|
send_request(td_api::make_object<td_api::setBotProfilePhoto>(bot_user_id, input_chat_photo));
|
2023-03-30 15:41:03 +02:00
|
|
|
} else if (op == "tbunia") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string username;
|
|
|
|
bool is_active;
|
|
|
|
get_args(args, bot_user_id, username, is_active);
|
|
|
|
send_request(td_api::make_object<td_api::toggleBotUsernameIsActive>(bot_user_id, username, is_active));
|
2023-04-29 21:27:31 +02:00
|
|
|
} else if (op == "rbaun") {
|
2023-03-30 15:41:03 +02:00
|
|
|
UserId bot_user_id;
|
|
|
|
string usernames;
|
|
|
|
get_args(args, bot_user_id, usernames);
|
2023-04-29 21:27:31 +02:00
|
|
|
send_request(td_api::make_object<td_api::reorderBotActiveUsernames>(bot_user_id, autosplit_str(usernames)));
|
2023-03-28 16:49:48 +02:00
|
|
|
} else if (op == "sbid") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
string description;
|
|
|
|
get_args(args, bot_user_id, language_code, description);
|
|
|
|
send_request(td_api::make_object<td_api::setBotInfoDescription>(bot_user_id, language_code, description));
|
|
|
|
} else if (op == "gbid") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
get_args(args, bot_user_id, language_code);
|
|
|
|
send_request(td_api::make_object<td_api::getBotInfoDescription>(bot_user_id, language_code));
|
|
|
|
} else if (op == "sbisd") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
string short_description;
|
|
|
|
get_args(args, bot_user_id, language_code, short_description);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setBotInfoShortDescription>(bot_user_id, language_code, short_description));
|
|
|
|
} else if (op == "gbisd") {
|
|
|
|
UserId bot_user_id;
|
|
|
|
string language_code;
|
|
|
|
get_args(args, bot_user_id, language_code);
|
|
|
|
send_request(td_api::make_object<td_api::getBotInfoShortDescription>(bot_user_id, language_code));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "sh") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &prefix = args;
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::searchHashtags>(prefix, 10));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rrh") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &hashtag = args;
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeRecentHashtag>(hashtag));
|
2023-04-28 13:44:35 +02:00
|
|
|
} else if (op == "view" || op == "viewh" || op == "viewt" || op == "views") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-03-02 17:21:43 +01:00
|
|
|
string message_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_ids);
|
2023-02-07 19:08:54 +01:00
|
|
|
td_api::object_ptr<td_api::MessageSource> source;
|
2023-06-01 14:31:05 +02:00
|
|
|
if (op == "viewh") {
|
|
|
|
source = td_api::make_object<td_api::messageSourceChatHistory>();
|
|
|
|
} else if (op == "viewt") {
|
2023-02-07 19:08:54 +01:00
|
|
|
source = td_api::make_object<td_api::messageSourceMessageThreadHistory>();
|
2023-04-28 13:44:35 +02:00
|
|
|
} else if (op == "views") {
|
|
|
|
source = td_api::make_object<td_api::messageSourceScreenshot>();
|
2020-09-22 00:13:06 +02:00
|
|
|
}
|
2022-10-27 13:19:04 +02:00
|
|
|
send_request(
|
2023-02-07 19:08:54 +01:00
|
|
|
td_api::make_object<td_api::viewMessages>(chat_id, as_message_ids(message_ids), std::move(source), true));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "omc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::openMessageContent>(chat_id, message_id));
|
2021-09-15 23:41:40 +02:00
|
|
|
} else if (op == "caem") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2021-09-15 23:41:40 +02:00
|
|
|
get_args(args, chat_id, message_id);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::clickAnimatedEmojiMessage>(chat_id, message_id));
|
2021-06-01 04:41:32 +02:00
|
|
|
} else if (op == "gilt") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &link = args;
|
2021-06-01 04:41:32 +02:00
|
|
|
send_request(td_api::make_object<td_api::getInternalLinkType>(link));
|
2021-03-15 22:52:37 +01:00
|
|
|
} else if (op == "geli") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &link = args;
|
2021-03-15 22:52:37 +01:00
|
|
|
send_request(td_api::make_object<td_api::getExternalLinkInfo>(link));
|
|
|
|
} else if (op == "gel" || op == "gelw") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &link = args;
|
2021-03-15 22:52:37 +01:00
|
|
|
send_request(td_api::make_object<td_api::getExternalLink>(link, op == "gelw"));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "racm") {
|
2022-10-31 18:03:28 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::readAllChatMentions>(chat_id));
|
|
|
|
} else if (op == "ramtm") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2022-10-24 15:57:26 +02:00
|
|
|
get_args(args, chat_id, message_thread_id);
|
2022-10-31 18:03:28 +01:00
|
|
|
send_request(td_api::make_object<td_api::readAllMessageThreadMentions>(chat_id, message_thread_id));
|
2022-01-30 10:37:24 +01:00
|
|
|
} else if (op == "racr") {
|
2022-10-31 18:03:28 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::readAllChatReactions>(chat_id));
|
|
|
|
} else if (op == "ramtr") {
|
2022-01-30 10:37:24 +01:00
|
|
|
ChatId chat_id;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id;
|
2022-10-24 16:04:05 +02:00
|
|
|
get_args(args, chat_id, message_thread_id);
|
2022-10-31 18:03:28 +01:00
|
|
|
send_request(td_api::make_object<td_api::readAllMessageThreadReactions>(chat_id, message_thread_id));
|
2019-08-06 01:03:44 +02:00
|
|
|
} else if (op == "tre") {
|
|
|
|
send_request(td_api::make_object<td_api::testReturnError>(
|
|
|
|
args.empty() ? nullptr : td_api::make_object<td_api::error>(-1, args)));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "dpp") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int64 profile_photo_id;
|
|
|
|
get_args(args, profile_photo_id);
|
|
|
|
send_request(td_api::make_object<td_api::deleteProfilePhoto>(profile_photo_id));
|
2022-04-14 12:23:43 +02:00
|
|
|
} else if (op == "gns") {
|
2022-04-14 13:31:18 +02:00
|
|
|
int64 notification_sound_id;
|
|
|
|
get_args(args, notification_sound_id);
|
|
|
|
send_request(td_api::make_object<td_api::getSavedNotificationSound>(notification_sound_id));
|
2022-04-14 12:23:43 +02:00
|
|
|
} else if (op == "gnss") {
|
2022-04-13 21:14:40 +02:00
|
|
|
send_request(td_api::make_object<td_api::getSavedNotificationSounds>());
|
2022-04-14 21:39:25 +02:00
|
|
|
} else if (op == "asns") {
|
|
|
|
string sound;
|
|
|
|
get_args(args, sound);
|
|
|
|
send_request(td_api::make_object<td_api::addSavedNotificationSound>(as_input_file(sound)));
|
2022-04-14 13:31:18 +02:00
|
|
|
} else if (op == "rns") {
|
|
|
|
int64 notification_sound_id;
|
|
|
|
get_args(args, notification_sound_id);
|
|
|
|
send_request(td_api::make_object<td_api::removeSavedNotificationSound>(notification_sound_id));
|
2019-02-14 19:44:20 +01:00
|
|
|
} else if (op == "gcnse" || op == "gcnses") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatNotificationSettingsExceptions>(
|
2022-10-12 14:03:47 +02:00
|
|
|
as_notification_settings_scope(args), op == "gcnses"));
|
2018-04-09 18:30:27 +02:00
|
|
|
} else if (op == "gsns") {
|
2022-10-12 14:03:47 +02:00
|
|
|
send_request(td_api::make_object<td_api::getScopeNotificationSettings>(as_notification_settings_scope(args)));
|
2022-12-06 12:53:54 +01:00
|
|
|
} else if (op == "scns" || op == "ssns" || op == "sftns") {
|
|
|
|
string scope;
|
2018-12-31 20:04:05 +01:00
|
|
|
string mute_for;
|
2022-04-14 12:23:43 +02:00
|
|
|
int64 sound_id;
|
2019-01-08 20:48:43 +01:00
|
|
|
string show_preview;
|
2023-06-12 18:41:18 +02:00
|
|
|
string mute_stories;
|
2023-06-27 17:30:05 +02:00
|
|
|
int64 story_sound_id;
|
|
|
|
string hide_story_sender;
|
2019-01-10 18:54:46 +01:00
|
|
|
string disable_pinned_message_notifications;
|
|
|
|
string disable_mention_notifications;
|
2023-06-27 18:09:43 +02:00
|
|
|
get_args(args, scope, mute_for, sound_id, show_preview, mute_stories, story_sound_id, hide_story_sender,
|
|
|
|
disable_pinned_message_notifications, disable_mention_notifications);
|
2022-12-06 12:53:54 +01:00
|
|
|
if (op == "ssns") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setScopeNotificationSettings>(
|
2022-12-06 12:53:54 +01:00
|
|
|
as_notification_settings_scope(scope),
|
2019-02-21 17:48:05 +01:00
|
|
|
td_api::make_object<td_api::scopeNotificationSettings>(
|
2023-07-06 17:42:44 +02:00
|
|
|
to_integer<int32>(mute_for), sound_id, as_bool(show_preview), mute_stories.empty(),
|
|
|
|
as_bool(mute_stories), story_sound_id, as_bool(hide_story_sender),
|
|
|
|
as_bool(disable_pinned_message_notifications), as_bool(disable_mention_notifications))));
|
2022-12-06 12:53:54 +01:00
|
|
|
} else {
|
|
|
|
auto settings = td_api::make_object<td_api::chatNotificationSettings>(
|
|
|
|
mute_for.empty(), to_integer<int32>(mute_for), sound_id == -1, sound_id, show_preview.empty(),
|
2023-06-27 18:09:43 +02:00
|
|
|
as_bool(show_preview), mute_stories.empty(), as_bool(mute_stories), story_sound_id == -1, story_sound_id,
|
|
|
|
hide_story_sender.empty(), as_bool(hide_story_sender), disable_pinned_message_notifications.empty(),
|
|
|
|
as_bool(disable_pinned_message_notifications), disable_mention_notifications.empty(),
|
|
|
|
as_bool(disable_mention_notifications));
|
2022-12-06 12:53:54 +01:00
|
|
|
if (op == "scns") {
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::setChatNotificationSettings>(as_chat_id(scope), std::move(settings)));
|
|
|
|
} else {
|
|
|
|
string chat_id;
|
|
|
|
string message_id;
|
|
|
|
std::tie(chat_id, message_id) = split(scope, ',');
|
|
|
|
send_request(td_api::make_object<td_api::setForumTopicNotificationSettings>(
|
|
|
|
as_chat_id(chat_id), as_message_id(message_id), std::move(settings)));
|
|
|
|
}
|
2019-01-10 18:54:46 +01:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rans") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::resetAllNotificationSettings>());
|
2018-11-09 15:14:02 +01:00
|
|
|
} else if (op == "rn") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 group_id;
|
2018-12-04 00:25:29 +01:00
|
|
|
string notification_ids;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, group_id, notification_ids);
|
2019-12-18 16:09:32 +01:00
|
|
|
for (auto notification_id : to_integers<int32>(notification_ids)) {
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeNotification>(group_id, notification_id));
|
2018-12-04 00:25:29 +01:00
|
|
|
}
|
2018-11-09 23:56:00 +01:00
|
|
|
} else if (op == "rng") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 group_id;
|
|
|
|
int32 max_notification_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, group_id, max_notification_id);
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeNotificationGroup>(group_id, max_notification_id));
|
2019-10-11 02:28:41 +02:00
|
|
|
} else if (op == "rcab") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
get_args(args, chat_id);
|
|
|
|
send_request(td_api::make_object<td_api::removeChatActionBar>(chat_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "rc") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2018-03-02 17:21:43 +01:00
|
|
|
string message_ids;
|
2023-08-01 19:44:24 +02:00
|
|
|
ReportReason reason;
|
2021-02-19 17:11:27 +01:00
|
|
|
string text;
|
|
|
|
get_args(args, chat_id, message_ids, reason, text);
|
2023-08-01 19:44:24 +02:00
|
|
|
send_request(td_api::make_object<td_api::reportChat>(chat_id, as_message_ids(message_ids), reason, text));
|
2021-02-19 17:11:27 +01:00
|
|
|
} else if (op == "rcp") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2022-02-19 00:42:18 +01:00
|
|
|
FileId file_id;
|
2023-08-01 19:44:24 +02:00
|
|
|
ReportReason reason;
|
2021-02-12 18:14:59 +01:00
|
|
|
string text;
|
2021-02-19 17:11:27 +01:00
|
|
|
get_args(args, chat_id, file_id, reason, text);
|
2023-08-01 19:44:24 +02:00
|
|
|
send_request(td_api::make_object<td_api::reportChatPhoto>(chat_id, file_id, reason, text));
|
2022-09-09 14:56:45 +02:00
|
|
|
} else if (op == "reportmr") {
|
2022-08-23 13:39:10 +02:00
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
string sender_id;
|
|
|
|
get_args(args, chat_id, message_id, sender_id);
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::reportMessageReactions>(chat_id, message_id, as_message_sender(sender_id)));
|
2020-04-03 02:53:33 +02:00
|
|
|
} else if (op == "gcst") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_dark;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, is_dark);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getChatStatistics>(chat_id, is_dark));
|
2021-12-04 23:00:28 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op == "sgs") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2020-12-28 21:35:05 +01:00
|
|
|
int32 score;
|
|
|
|
get_args(args, chat_id, message_id, user_id, score);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::setGameScore>(chat_id, message_id, true, user_id, score, true));
|
2020-12-28 21:35:05 +01:00
|
|
|
} else if (op == "gghs") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2021-12-31 12:56:57 +01:00
|
|
|
UserId user_id;
|
2021-09-07 10:40:08 +02:00
|
|
|
get_args(args, chat_id, message_id, user_id);
|
2021-12-31 12:56:57 +01:00
|
|
|
send_request(td_api::make_object<td_api::getGameHighScores>(chat_id, message_id, user_id));
|
2020-08-01 04:19:54 +02:00
|
|
|
} else if (op == "gmst") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2020-12-26 17:59:45 +01:00
|
|
|
bool is_dark;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, is_dark);
|
2021-12-31 12:31:43 +01:00
|
|
|
send_request(td_api::make_object<td_api::getMessageStatistics>(chat_id, message_id, is_dark));
|
2020-08-01 04:19:54 +02:00
|
|
|
} else if (op == "gstg") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2020-04-03 02:53:33 +02:00
|
|
|
string token;
|
2020-12-26 18:26:19 +01:00
|
|
|
int64 x;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, token, x);
|
2021-12-31 12:20:34 +01:00
|
|
|
send_request(td_api::make_object<td_api::getStatisticalGraph>(chat_id, token, x));
|
2021-01-14 23:30:05 +01:00
|
|
|
} else if (op == "hsa") {
|
2020-07-12 14:04:49 +02:00
|
|
|
send_request(td_api::make_object<td_api::hideSuggestedAction>(as_suggested_action(args)));
|
2019-09-07 01:07:56 +02:00
|
|
|
} else if (op == "glui" || op == "glu" || op == "glua") {
|
2021-12-31 12:20:34 +01:00
|
|
|
ChatId chat_id;
|
2021-12-31 12:31:43 +01:00
|
|
|
MessageId message_id;
|
2023-02-19 09:21:42 +01:00
|
|
|
int32 button_id;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, chat_id, message_id, button_id);
|
2019-09-07 01:07:56 +02:00
|
|
|
if (op == "glui") {
|
2023-02-19 09:21:42 +01:00
|
|
|
send_request(td_api::make_object<td_api::getLoginUrlInfo>(chat_id, message_id, button_id));
|
2019-09-07 01:07:56 +02:00
|
|
|
} else {
|
2023-02-19 09:21:42 +01:00
|
|
|
send_request(td_api::make_object<td_api::getLoginUrl>(chat_id, message_id, button_id, op == "glua"));
|
2019-09-07 01:07:56 +02:00
|
|
|
}
|
2023-01-31 14:52:05 +01:00
|
|
|
} else if (op == "suwb" || op == "suwbc") {
|
2023-01-13 15:03:35 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
int32 button_id;
|
2023-01-23 16:19:35 +01:00
|
|
|
UserId shared_user_id;
|
|
|
|
get_args(args, chat_id, message_id, button_id, shared_user_id);
|
2023-01-31 14:52:05 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::shareUserWithBot>(chat_id, message_id, button_id, shared_user_id, op == "suwbc"));
|
|
|
|
} else if (op == "scwb" || op == "scwbc") {
|
2023-01-13 15:16:16 +01:00
|
|
|
ChatId chat_id;
|
|
|
|
MessageId message_id;
|
|
|
|
int32 button_id;
|
2023-01-23 16:19:35 +01:00
|
|
|
ChatId shared_chat_id;
|
|
|
|
get_args(args, chat_id, message_id, button_id, shared_chat_id);
|
2023-01-31 14:52:05 +01:00
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::shareChatWithBot>(chat_id, message_id, button_id, shared_chat_id, op == "scwbc"));
|
2021-11-19 15:12:38 +01:00
|
|
|
} else if (op == "rsgs") {
|
2018-12-31 20:04:05 +01:00
|
|
|
string supergroup_id;
|
2018-03-02 17:21:43 +01:00
|
|
|
string message_ids;
|
2021-11-19 15:12:38 +01:00
|
|
|
get_args(args, supergroup_id, message_ids);
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::reportSupergroupSpam>(as_supergroup_id(supergroup_id),
|
2021-11-19 15:12:38 +01:00
|
|
|
as_message_ids(message_ids)));
|
2022-11-25 14:38:00 +01:00
|
|
|
} else if (op == "rsgasfp") {
|
|
|
|
string supergroup_id;
|
|
|
|
MessageId message_id;
|
|
|
|
get_args(args, supergroup_id, message_id);
|
|
|
|
send_request(td_api::make_object<td_api::reportSupergroupAntiSpamFalsePositive>(as_supergroup_id(supergroup_id),
|
|
|
|
message_id));
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "gdiff") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::testGetDifference>());
|
2018-05-14 21:00:38 +02:00
|
|
|
} else if (op == "dproxy") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::disableProxy>());
|
2018-05-14 21:00:38 +02:00
|
|
|
} else if (op == "eproxy") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::enableProxy>(as_proxy_id(args)));
|
2018-05-14 21:00:38 +02:00
|
|
|
} else if (op == "rproxy") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::removeProxy>(as_proxy_id(args)));
|
2018-07-27 17:10:45 +02:00
|
|
|
} else if (op == "aproxy" || op == "aeproxy" || op == "aeproxytcp" || op == "editproxy" || op == "editeproxy" ||
|
2019-07-20 15:13:36 +02:00
|
|
|
op == "editeproxytcp" || op == "tproxy") {
|
2018-07-27 17:10:45 +02:00
|
|
|
string proxy_id;
|
2018-12-31 20:04:05 +01:00
|
|
|
string server;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 port;
|
2018-02-28 21:25:42 +01:00
|
|
|
string user;
|
|
|
|
string password;
|
2018-07-27 17:10:45 +02:00
|
|
|
if (op[0] == 'e') {
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, proxy_id, args);
|
2018-07-27 17:10:45 +02:00
|
|
|
}
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, server, port, user, password);
|
2018-07-27 17:10:45 +02:00
|
|
|
bool enable = op != "aproxy" && op != "editproxy";
|
2018-05-14 21:00:38 +02:00
|
|
|
td_api::object_ptr<td_api::ProxyType> type;
|
2018-05-08 16:48:30 +02:00
|
|
|
if (!user.empty() && password.empty()) {
|
2019-02-21 17:48:05 +01:00
|
|
|
type = td_api::make_object<td_api::proxyTypeMtproto>(user);
|
2018-05-08 16:48:30 +02:00
|
|
|
} else {
|
2020-12-26 18:26:19 +01:00
|
|
|
if (port == 80 || port == 8080) {
|
2019-02-21 17:48:05 +01:00
|
|
|
type = td_api::make_object<td_api::proxyTypeHttp>(user, password, op.back() != 'p');
|
2018-07-26 15:49:18 +02:00
|
|
|
} else {
|
2019-02-21 17:48:05 +01:00
|
|
|
type = td_api::make_object<td_api::proxyTypeSocks5>(user, password);
|
2018-07-26 15:49:18 +02:00
|
|
|
}
|
2018-05-08 16:48:30 +02:00
|
|
|
}
|
2018-07-27 17:10:45 +02:00
|
|
|
if (op[0] == 'e') {
|
2019-07-22 04:04:18 +02:00
|
|
|
send_request(
|
2020-12-26 18:26:19 +01:00
|
|
|
td_api::make_object<td_api::editProxy>(as_proxy_id(proxy_id), server, port, enable, std::move(type)));
|
2019-07-20 15:13:36 +02:00
|
|
|
} else if (op == "tproxy") {
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(td_api::make_object<td_api::testProxy>(server, port, std::move(type), 2, 10.0));
|
2018-07-27 17:10:45 +02:00
|
|
|
} else {
|
2020-12-26 18:26:19 +01:00
|
|
|
send_request(td_api::make_object<td_api::addProxy>(server, port, enable, std::move(type)));
|
2018-07-27 17:10:45 +02:00
|
|
|
}
|
2018-05-14 21:00:38 +02:00
|
|
|
} else if (op == "gproxy" || op == "gproxies") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getProxies>());
|
2018-05-17 20:08:51 +02:00
|
|
|
} else if (op == "gproxyl" || op == "gpl") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::getProxyLink>(as_proxy_id(args)));
|
2018-05-14 21:00:38 +02:00
|
|
|
} else if (op == "pproxy") {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::pingProxy>(as_proxy_id(args)));
|
2022-08-15 13:32:35 +02:00
|
|
|
} else if (op == "gusi") {
|
|
|
|
UserId user_id;
|
|
|
|
get_args(args, user_id);
|
|
|
|
send_request(td_api::make_object<td_api::getUserSupportInfo>(user_id));
|
2022-08-15 15:58:28 +02:00
|
|
|
} else if (op == "susi") {
|
|
|
|
UserId user_id;
|
|
|
|
string text;
|
|
|
|
get_args(args, user_id, text);
|
|
|
|
send_request(td_api::make_object<td_api::setUserSupportInfo>(user_id, as_formatted_text(text)));
|
2023-03-22 11:54:04 +01:00
|
|
|
} else if (op == "gsn") {
|
|
|
|
send_request(td_api::make_object<td_api::getSupportName>());
|
2018-04-27 19:41:10 +02:00
|
|
|
} else if (op == "touch") {
|
|
|
|
auto r_fd = FileFd::open(args, FileFd::Read | FileFd::Write);
|
|
|
|
if (r_fd.is_error()) {
|
|
|
|
LOG(ERROR) << r_fd.error();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto fd = r_fd.move_as_ok();
|
2019-06-19 16:31:25 +02:00
|
|
|
auto size = fd.get_size().move_as_ok();
|
2018-05-15 12:01:15 +02:00
|
|
|
fd.seek(size).ignore();
|
2018-04-27 19:41:10 +02:00
|
|
|
fd.write("a").ignore();
|
|
|
|
fd.seek(size).ignore();
|
|
|
|
fd.truncate_to_current_position(size).ignore();
|
2020-06-14 01:31:57 +02:00
|
|
|
} else if (op == "mem") {
|
|
|
|
auto r_mem_stats = mem_stat();
|
|
|
|
if (r_mem_stats.is_error()) {
|
|
|
|
LOG(ERROR) << r_mem_stats.error();
|
|
|
|
} else {
|
|
|
|
auto stats = r_mem_stats.move_as_ok();
|
2020-06-14 03:01:02 +02:00
|
|
|
LOG(ERROR) << "RSS = " << stats.resident_size_ << ", peak RSS = " << stats.resident_size_peak_ << ", VSZ "
|
|
|
|
<< stats.virtual_size_ << ", peak VSZ = " << stats.virtual_size_peak_;
|
|
|
|
}
|
|
|
|
} else if (op == "cpu") {
|
2021-10-20 00:27:02 +02:00
|
|
|
auto inc_count = to_integer<uint32>(args);
|
2020-06-14 03:01:02 +02:00
|
|
|
while (inc_count-- > 0) {
|
|
|
|
cpu_counter_++;
|
|
|
|
}
|
|
|
|
auto r_cpu_stats = cpu_stat();
|
|
|
|
if (r_cpu_stats.is_error()) {
|
|
|
|
LOG(ERROR) << r_cpu_stats.error();
|
|
|
|
} else {
|
|
|
|
auto stats = r_cpu_stats.move_as_ok();
|
2020-10-05 17:07:23 +02:00
|
|
|
LOG(ERROR) << cpu_counter_.load() << ", total ticks = " << stats.total_ticks_
|
2020-06-14 03:01:02 +02:00
|
|
|
<< ", user ticks = " << stats.process_user_ticks_
|
|
|
|
<< ", system ticks = " << stats.process_system_ticks_;
|
2020-06-14 01:31:57 +02:00
|
|
|
}
|
2021-05-17 16:33:26 +02:00
|
|
|
} else if (op[0] == 'v' && (op[1] == 'v' || is_digit(op[1]))) {
|
|
|
|
int new_verbosity_level = op[1] == 'v' ? static_cast<int>(op.size()) : to_integer<int>(op.substr(1));
|
|
|
|
SET_VERBOSITY_LEVEL(td::max(new_verbosity_level, VERBOSITY_NAME(DEBUG)));
|
|
|
|
combined_log.set_first_verbosity_level(new_verbosity_level);
|
2018-10-24 17:42:40 +02:00
|
|
|
} else if (op == "slse") {
|
|
|
|
execute(td_api::make_object<td_api::setLogStream>(td_api::make_object<td_api::logStreamEmpty>()));
|
|
|
|
} else if (op == "slsd") {
|
|
|
|
execute(td_api::make_object<td_api::setLogStream>(td_api::make_object<td_api::logStreamDefault>()));
|
|
|
|
} else if (op == "gls") {
|
|
|
|
execute(td_api::make_object<td_api::getLogStream>());
|
|
|
|
} else if (op == "slvl") {
|
2021-12-31 08:25:40 +01:00
|
|
|
int32 new_verbosity_level;
|
|
|
|
get_args(args, new_verbosity_level);
|
|
|
|
execute(td_api::make_object<td_api::setLogVerbosityLevel>(new_verbosity_level));
|
2018-10-24 17:42:40 +02:00
|
|
|
} else if (op == "glvl") {
|
|
|
|
execute(td_api::make_object<td_api::getLogVerbosityLevel>());
|
|
|
|
} else if (op == "gtags" || op == "glt") {
|
|
|
|
execute(td_api::make_object<td_api::getLogTags>());
|
2018-09-26 02:54:37 +02:00
|
|
|
} else if (op == "sltvl" || op == "sltvle" || op == "tag") {
|
2018-09-26 01:59:29 +02:00
|
|
|
string tag;
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 level;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, tag, level);
|
2020-12-26 18:26:19 +01:00
|
|
|
auto request = td_api::make_object<td_api::setLogTagVerbosityLevel>(tag, level);
|
2018-09-26 01:59:29 +02:00
|
|
|
if (op == "sltvl") {
|
|
|
|
send_request(std::move(request));
|
|
|
|
} else {
|
|
|
|
execute(std::move(request));
|
|
|
|
}
|
2018-10-24 17:42:40 +02:00
|
|
|
} else if (op == "gltvl" || op == "gltvle" || op == "gtag") {
|
2021-10-21 11:51:16 +02:00
|
|
|
const string &tag = args;
|
2019-02-21 17:48:05 +01:00
|
|
|
auto request = td_api::make_object<td_api::getLogTagVerbosityLevel>(tag);
|
2018-10-24 17:42:40 +02:00
|
|
|
if (op == "gltvl") {
|
|
|
|
send_request(std::move(request));
|
|
|
|
} else {
|
|
|
|
execute(std::move(request));
|
|
|
|
}
|
2019-04-13 20:40:31 +02:00
|
|
|
} else if (op == "alog" || op == "aloge") {
|
2020-12-26 18:26:19 +01:00
|
|
|
int32 level;
|
2019-04-13 20:40:31 +02:00
|
|
|
string text;
|
2020-12-26 17:40:46 +01:00
|
|
|
get_args(args, level, text);
|
2020-12-26 18:26:19 +01:00
|
|
|
auto request = td_api::make_object<td_api::addLogMessage>(level, text);
|
2019-04-13 20:40:31 +02:00
|
|
|
if (op == "alog") {
|
|
|
|
send_request(std::move(request));
|
|
|
|
} else {
|
|
|
|
execute(std::move(request));
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
} else if (op == "q" || op == "Quit") {
|
|
|
|
quit();
|
2021-06-20 02:05:58 +02:00
|
|
|
} else if (op == "dnq") {
|
2020-07-30 16:28:56 +02:00
|
|
|
dump_pending_network_queries(*net_query_stats_);
|
2018-01-24 16:45:57 +01:00
|
|
|
} else if (op == "fatal") {
|
|
|
|
LOG(FATAL) << "Fatal!";
|
|
|
|
} else if (op == "unreachable") {
|
|
|
|
UNREACHABLE();
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
|
|
|
op_not_found_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (op_not_found_count == OP_BLOCK_COUNT && !cmd.empty()) {
|
|
|
|
LOG(ERROR) << "Unknown command \"" << cmd << "\" of length " << cmd.size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-23 17:18:57 +02:00
|
|
|
bool is_inited_ = false;
|
2021-07-03 22:51:36 +02:00
|
|
|
void loop() final {
|
2019-07-23 17:18:57 +02:00
|
|
|
if (!is_inited_) {
|
|
|
|
is_inited_ = true;
|
2018-12-31 20:04:05 +01:00
|
|
|
init();
|
|
|
|
}
|
2018-09-10 17:09:08 +02:00
|
|
|
stdin_.flush_read().ensure();
|
2018-12-31 20:04:05 +01:00
|
|
|
#ifdef USE_READLINE
|
2018-09-10 17:09:08 +02:00
|
|
|
while (!stdin_.input_buffer().empty()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
rl_callback_read_char();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
while (true) {
|
|
|
|
auto cmd = process_stdin(&stdin_.input_buffer());
|
|
|
|
if (cmd.is_error()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
add_cmd(cmd.ok().as_slice().str());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while (!cmd_queue_.empty() && !close_flag_) {
|
|
|
|
auto cmd = std::move(cmd_queue_.front());
|
|
|
|
cmd_queue_.pop();
|
|
|
|
on_cmd(std::move(cmd));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ready_to_stop_ && close_flag_ && is_stdin_reader_stopped_) {
|
|
|
|
#ifdef USE_READLINE
|
|
|
|
rl_callback_handler_remove();
|
|
|
|
#endif
|
|
|
|
Scheduler::instance()->finish();
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void timeout_expired() final {
|
2018-01-05 15:45:17 +01:00
|
|
|
if (close_flag_) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-01 01:12:36 +02:00
|
|
|
for (auto it = pending_file_generations_.begin(); it != pending_file_generations_.end();) {
|
2018-12-31 20:04:05 +01:00
|
|
|
auto left_size = it->size - it->local_size;
|
|
|
|
CHECK(left_size > 0);
|
|
|
|
if (it->part_size > left_size) {
|
|
|
|
it->part_size = left_size;
|
|
|
|
}
|
2022-05-11 17:52:45 +02:00
|
|
|
BufferSlice block(narrow_cast<size_t>(it->part_size));
|
2023-02-02 15:40:47 +01:00
|
|
|
FileFd::open(it->source, FileFd::Flags::Read)
|
|
|
|
.move_as_ok()
|
|
|
|
.pread(block.as_mutable_slice(), it->local_size)
|
|
|
|
.ensure();
|
2020-12-26 19:01:57 +01:00
|
|
|
if (rand_bool()) {
|
2019-04-26 02:18:00 +02:00
|
|
|
auto open_flags = FileFd::Flags::Write | (it->local_size ? 0 : FileFd::Flags::Truncate | FileFd::Flags::Create);
|
|
|
|
FileFd::open(it->destination, open_flags).move_as_ok().pwrite(block.as_slice(), it->local_size).ensure();
|
|
|
|
} else {
|
|
|
|
send_request(
|
|
|
|
td_api::make_object<td_api::writeGeneratedFilePart>(it->id, it->local_size, block.as_slice().str()));
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
it->local_size += it->part_size;
|
|
|
|
if (it->local_size == it->size) {
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setFileGenerationProgress>(it->id, it->size, it->size));
|
|
|
|
send_request(td_api::make_object<td_api::finishFileGeneration>(it->id, nullptr));
|
2018-06-01 01:12:36 +02:00
|
|
|
it = pending_file_generations_.erase(it);
|
2018-12-31 20:04:05 +01:00
|
|
|
} else {
|
2018-11-21 11:56:14 +01:00
|
|
|
auto local_size = it->local_size;
|
|
|
|
if (it->test_local_size_decrease && local_size > it->size / 2) {
|
|
|
|
local_size = local_size * 2 - it->size;
|
|
|
|
}
|
2019-02-21 17:48:05 +01:00
|
|
|
send_request(td_api::make_object<td_api::setFileGenerationProgress>(it->id, (it->size + 3 * it->local_size) / 4,
|
|
|
|
local_size));
|
2018-12-31 20:04:05 +01:00
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-01 01:12:36 +02:00
|
|
|
if (!pending_file_generations_.empty()) {
|
2018-12-31 20:04:05 +01:00
|
|
|
set_timeout_in(0.01);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void notify() final {
|
2018-09-11 09:31:05 +02:00
|
|
|
auto guard = scheduler_->get_send_guard();
|
|
|
|
send_event_later(actor_id(), Event::yield());
|
|
|
|
}
|
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void hangup_shared() final {
|
2018-12-31 20:04:05 +01:00
|
|
|
CHECK(get_link_token() == 1);
|
|
|
|
LOG(INFO) << "StdinReader stopped";
|
|
|
|
is_stdin_reader_stopped_ = true;
|
|
|
|
yield();
|
|
|
|
}
|
|
|
|
|
|
|
|
void add_cmd(string cmd) {
|
|
|
|
cmd_queue_.push(std::move(cmd));
|
|
|
|
}
|
2018-09-10 17:09:08 +02:00
|
|
|
int stdin_getc() {
|
|
|
|
auto slice = stdin_.input_buffer().prepare_read();
|
|
|
|
if (slice.empty()) {
|
2018-09-10 20:45:34 +02:00
|
|
|
return EOF;
|
2018-09-10 17:09:08 +02:00
|
|
|
}
|
2021-10-18 11:57:13 +02:00
|
|
|
int res = static_cast<unsigned char>(slice[0]);
|
2018-09-10 17:09:08 +02:00
|
|
|
stdin_.input_buffer().confirm_read(1);
|
|
|
|
return res;
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-02-07 20:41:07 +01:00
|
|
|
FlatHashMap<int32, double> being_downloaded_files_;
|
2018-06-01 01:12:36 +02:00
|
|
|
|
2021-09-03 11:27:59 +02:00
|
|
|
int64 my_id_ = 0;
|
2022-01-02 10:19:14 +01:00
|
|
|
td_api::object_ptr<td_api::AuthorizationState> authorization_state_;
|
2019-12-06 01:08:11 +01:00
|
|
|
string schedule_date_;
|
2022-10-27 13:19:04 +02:00
|
|
|
MessageThreadId message_thread_id_;
|
2022-12-16 13:58:33 +01:00
|
|
|
bool has_spoiler_ = false;
|
2022-12-28 19:46:16 +01:00
|
|
|
int32 message_self_destruct_time_ = 0;
|
2021-11-28 09:49:46 +01:00
|
|
|
int64 opened_chat_id_ = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-09-11 12:37:44 +02:00
|
|
|
ConcurrentScheduler *scheduler_{nullptr};
|
2018-09-11 09:31:05 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool use_test_dc_ = false;
|
2020-07-30 16:28:56 +02:00
|
|
|
std::shared_ptr<NetQueryStats> net_query_stats_ = create_net_query_stats();
|
2018-10-28 18:30:47 +01:00
|
|
|
ActorOwn<ClientActor> td_client_;
|
2018-12-31 20:04:05 +01:00
|
|
|
std::queue<string> cmd_queue_;
|
|
|
|
bool close_flag_ = false;
|
|
|
|
bool ready_to_stop_ = false;
|
|
|
|
bool is_stdin_reader_stopped_ = false;
|
|
|
|
|
|
|
|
bool get_chat_list_ = false;
|
|
|
|
bool disable_network_ = false;
|
|
|
|
int api_id_ = 0;
|
|
|
|
std::string api_hash_;
|
2020-06-14 03:01:02 +02:00
|
|
|
|
2020-12-17 20:55:29 +01:00
|
|
|
int32 group_call_source_ = Random::fast(1, 1000000000);
|
|
|
|
|
2020-06-14 03:01:02 +02:00
|
|
|
static std::atomic<uint64> cpu_counter_;
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
CliClient *CliClient::instance_ = nullptr;
|
2020-06-14 03:01:02 +02:00
|
|
|
std::atomic<uint64> CliClient::cpu_counter_;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-01-24 17:11:39 +01:00
|
|
|
void quit() {
|
2018-12-31 20:04:05 +01:00
|
|
|
CliClient::quit_instance();
|
|
|
|
}
|
|
|
|
|
2018-01-24 16:45:57 +01:00
|
|
|
static void fail_signal(int sig) {
|
2018-12-31 20:04:05 +01:00
|
|
|
signal_safe_write_signal_number(sig);
|
|
|
|
while (true) {
|
|
|
|
// spin forever to allow debugger to attach
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-18 03:35:36 +02:00
|
|
|
static void on_log_message(int verbosity_level, const char *message) {
|
|
|
|
if (verbosity_level == 0) {
|
|
|
|
std::cerr << "Fatal error: " << message;
|
|
|
|
}
|
2022-10-11 22:36:23 +02:00
|
|
|
// std::cerr << "Log message: " << message;
|
2018-01-24 16:45:57 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
void main(int argc, char **argv) {
|
2020-10-11 13:45:22 +02:00
|
|
|
ExitGuard exit_guard;
|
2021-11-18 14:25:37 +01:00
|
|
|
detail::ThreadIdGuard thread_id_guard;
|
2018-12-31 20:04:05 +01:00
|
|
|
ignore_signal(SignalType::HangUp).ensure();
|
|
|
|
ignore_signal(SignalType::Pipe).ensure();
|
|
|
|
set_signal_handler(SignalType::Error, fail_signal).ensure();
|
|
|
|
set_signal_handler(SignalType::Abort, fail_signal).ensure();
|
2021-05-18 03:35:36 +02:00
|
|
|
ClientManager::set_log_message_callback(0, on_log_message);
|
2020-08-08 20:56:34 +02:00
|
|
|
init_openssl_threads();
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-12-24 13:12:14 +01:00
|
|
|
std::locale new_locale("C");
|
2018-02-09 22:52:03 +01:00
|
|
|
std::locale::global(new_locale);
|
2018-02-09 18:02:01 +01:00
|
|
|
SCOPE_EXIT {
|
|
|
|
std::locale::global(std::locale::classic());
|
2018-10-08 14:59:14 +02:00
|
|
|
static NullLog null_log;
|
|
|
|
log_interface = &null_log;
|
2018-02-09 18:02:01 +01:00
|
|
|
};
|
2018-02-03 20:40:06 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
CliLog cli_log;
|
|
|
|
|
2019-09-15 05:19:46 +02:00
|
|
|
FileLog file_log;
|
|
|
|
TsLog ts_log(&file_log);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-05-17 16:33:26 +02:00
|
|
|
combined_log.set_first(&cli_log);
|
|
|
|
|
|
|
|
log_interface = &combined_log;
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
int new_verbosity_level = VERBOSITY_NAME(INFO);
|
|
|
|
bool use_test_dc = false;
|
|
|
|
bool get_chat_list = false;
|
|
|
|
bool disable_network = false;
|
|
|
|
auto api_id = [](auto x) -> int32 {
|
|
|
|
if (x) {
|
2019-09-15 05:19:46 +02:00
|
|
|
return to_integer<int32>(Slice(x));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}(std::getenv("TD_API_ID"));
|
|
|
|
auto api_hash = [](auto x) -> std::string {
|
|
|
|
if (x) {
|
|
|
|
return x;
|
|
|
|
}
|
2018-09-11 12:37:44 +02:00
|
|
|
return std::string();
|
2018-12-31 20:04:05 +01:00
|
|
|
}(std::getenv("TD_API_HASH"));
|
2020-06-17 04:30:14 +02:00
|
|
|
|
2020-06-26 01:24:13 +02:00
|
|
|
OptionParser options;
|
2020-06-17 04:30:14 +02:00
|
|
|
options.set_description("TDLib test client");
|
2020-06-19 03:44:38 +02:00
|
|
|
options.add_option('\0', "test", "Use test DC", [&] { use_test_dc = true; });
|
2020-06-17 05:09:53 +02:00
|
|
|
options.add_option('v', "verbosity", "Set verbosity level", [&](Slice level) {
|
2020-06-17 04:30:14 +02:00
|
|
|
int new_verbosity = 1;
|
|
|
|
while (begins_with(level, "v")) {
|
|
|
|
new_verbosity++;
|
|
|
|
level.remove_prefix(1);
|
|
|
|
}
|
|
|
|
if (!level.empty()) {
|
|
|
|
new_verbosity += to_integer<int>(level) - (new_verbosity == 1);
|
|
|
|
}
|
|
|
|
new_verbosity_level = VERBOSITY_NAME(FATAL) + new_verbosity;
|
|
|
|
});
|
2020-06-17 05:09:53 +02:00
|
|
|
options.add_option('l', "log", "Log to file", [&](Slice file_name) {
|
2020-06-17 04:30:14 +02:00
|
|
|
if (file_log.init(file_name.str()).is_ok() && file_log.init(file_name.str()).is_ok() &&
|
|
|
|
file_log.init(file_name.str(), 1000 << 20).is_ok()) {
|
2021-05-17 16:33:26 +02:00
|
|
|
combined_log.set_first(&ts_log);
|
2020-06-17 04:30:14 +02:00
|
|
|
}
|
|
|
|
});
|
2020-06-19 03:44:38 +02:00
|
|
|
options.add_option('W', "", "Preload chat list", [&] { get_chat_list = true; });
|
|
|
|
options.add_option('n', "disable-network", "Disable network", [&] { disable_network = true; });
|
2020-12-26 18:26:19 +01:00
|
|
|
options.add_checked_option('\0', "api-id", "Set Telegram API ID", OptionParser::parse_integer(api_id));
|
2020-09-14 13:51:52 +02:00
|
|
|
options.add_option('\0', "api-hash", "Set Telegram API hash", OptionParser::parse_string(api_hash));
|
2020-06-19 04:50:18 +02:00
|
|
|
options.add_check([&] {
|
|
|
|
if (api_id == 0 || api_hash.empty()) {
|
|
|
|
return Status::Error("You must provide valid api-id and api-hash obtained at https://my.telegram.org");
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
});
|
2020-06-19 05:00:01 +02:00
|
|
|
auto r_non_options = options.run(argc, argv, 0);
|
|
|
|
if (r_non_options.is_error()) {
|
|
|
|
LOG(PLAIN) << argv[0] << ": " << r_non_options.error().message();
|
2020-06-17 04:30:14 +02:00
|
|
|
LOG(PLAIN) << options;
|
|
|
|
return;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
2021-05-17 16:33:26 +02:00
|
|
|
SET_VERBOSITY_LEVEL(td::max(new_verbosity_level, VERBOSITY_NAME(DEBUG)));
|
|
|
|
combined_log.set_first_verbosity_level(new_verbosity_level);
|
|
|
|
|
|
|
|
if (combined_log.get_first() == &cli_log) {
|
2021-06-11 16:04:00 +02:00
|
|
|
file_log.init("tg_cli.log", 1000 << 20, false).ensure();
|
2021-05-17 16:33:26 +02:00
|
|
|
file_log.lazy_rotate();
|
|
|
|
combined_log.set_second(&ts_log);
|
|
|
|
combined_log.set_second_verbosity_level(VERBOSITY_NAME(DEBUG));
|
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
{
|
2022-09-14 14:06:52 +02:00
|
|
|
ConcurrentScheduler scheduler(3, 0);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-07-04 04:58:54 +02:00
|
|
|
class CreateClient final : public Actor {
|
2019-07-07 05:09:07 +02:00
|
|
|
public:
|
|
|
|
CreateClient(ConcurrentScheduler *scheduler, bool use_test_dc, bool get_chat_list, bool disable_network,
|
|
|
|
int32 api_id, std::string api_hash)
|
|
|
|
: scheduler_(scheduler)
|
|
|
|
, use_test_dc_(use_test_dc)
|
|
|
|
, get_chat_list_(get_chat_list)
|
|
|
|
, disable_network_(disable_network)
|
|
|
|
, api_id_(api_id)
|
|
|
|
, api_hash_(std::move(api_hash)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2021-07-03 22:51:36 +02:00
|
|
|
void start_up() final {
|
2019-07-07 05:09:07 +02:00
|
|
|
create_actor<CliClient>("CliClient", scheduler_, use_test_dc_, get_chat_list_, disable_network_, api_id_,
|
|
|
|
api_hash_)
|
|
|
|
.release();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConcurrentScheduler *scheduler_;
|
|
|
|
bool use_test_dc_;
|
|
|
|
bool get_chat_list_;
|
|
|
|
bool disable_network_;
|
|
|
|
int32 api_id_;
|
|
|
|
std::string api_hash_;
|
|
|
|
};
|
2018-12-31 20:04:05 +01:00
|
|
|
scheduler
|
2019-07-07 05:09:07 +02:00
|
|
|
.create_actor_unsafe<CreateClient>(0, "CreateClient", &scheduler, use_test_dc, get_chat_list, disable_network,
|
|
|
|
api_id, api_hash)
|
2018-12-31 20:04:05 +01:00
|
|
|
.release();
|
|
|
|
|
|
|
|
scheduler.start();
|
2019-09-15 05:19:46 +02:00
|
|
|
while (scheduler.run_main(Timestamp::in(100))) {
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
scheduler.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
dump_memory_usage();
|
|
|
|
}
|
2019-01-17 21:12:31 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
td::main(argc, argv);
|
|
|
|
}
|