Allow to create forum supergroups.
This commit is contained in:
parent
ad8ecec67c
commit
f0d0ac6b78
@ -6437,12 +6437,13 @@ createNewBasicGroupChat user_ids:vector<int53> title:string message_auto_delete_
|
|||||||
|
|
||||||
//@description Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat
|
//@description Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat
|
||||||
//@title Title of the new chat; 1-128 characters
|
//@title Title of the new chat; 1-128 characters
|
||||||
//@is_channel Pass true to create a channel chat
|
//@is_forum Pass true to create a forum supergroup chat
|
||||||
|
//@is_channel Pass true to create a channel chat; ignored if a forum is created
|
||||||
//@param_description Chat description; 0-255 characters
|
//@param_description Chat description; 0-255 characters
|
||||||
//@location Chat location if a location-based supergroup is being created; pass null to create an ordinary supergroup chat
|
//@location Chat location if a location-based supergroup is being created; pass null to create an ordinary supergroup chat
|
||||||
//@message_auto_delete_time Message auto-delete time value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
|
//@message_auto_delete_time Message auto-delete time value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren't deleted automatically
|
||||||
//@for_import Pass true to create a supergroup for importing messages using importMessage
|
//@for_import Pass true to create a supergroup for importing messages using importMessage
|
||||||
createNewSupergroupChat title:string is_channel:Bool description:string location:chatLocation message_auto_delete_time:int32 for_import:Bool = Chat;
|
createNewSupergroupChat title:string is_forum:Bool is_channel:Bool description:string location:chatLocation message_auto_delete_time:int32 for_import:Bool = Chat;
|
||||||
|
|
||||||
//@description Creates a new secret chat. Returns the newly created chat @user_id Identifier of the target user
|
//@description Creates a new secret chat. Returns the newly created chat @user_id Identifier of the target user
|
||||||
createNewSecretChat user_id:int53 = Chat;
|
createNewSecretChat user_id:int53 = Chat;
|
||||||
|
@ -1037,10 +1037,12 @@ class CreateChannelQuery final : public Td::ResultHandler {
|
|||||||
explicit CreateChannelQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
explicit CreateChannelQuery(Promise<Unit> &&promise) : promise_(std::move(promise)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(const string &title, bool is_megagroup, const string &about, const DialogLocation &location,
|
void send(const string &title, bool is_forum, bool is_megagroup, const string &about, const DialogLocation &location,
|
||||||
bool for_import, MessageTtl message_ttl, int64 random_id) {
|
bool for_import, MessageTtl message_ttl, int64 random_id) {
|
||||||
int32 flags = telegram_api::channels_createChannel::TTL_PERIOD_MASK;
|
int32 flags = telegram_api::channels_createChannel::TTL_PERIOD_MASK;
|
||||||
if (is_megagroup) {
|
if (is_forum) {
|
||||||
|
flags |= telegram_api::channels_createChannel::FORUM_MASK;
|
||||||
|
} else if (is_megagroup) {
|
||||||
flags |= telegram_api::channels_createChannel::MEGAGROUP_MASK;
|
flags |= telegram_api::channels_createChannel::MEGAGROUP_MASK;
|
||||||
} else {
|
} else {
|
||||||
flags |= telegram_api::channels_createChannel::BROADCAST_MASK;
|
flags |= telegram_api::channels_createChannel::BROADCAST_MASK;
|
||||||
@ -21155,9 +21157,10 @@ DialogId MessagesManager::create_new_group_chat(const vector<UserId> &user_ids,
|
|||||||
return DialogId();
|
return DialogId();
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_megagroup, const string &description,
|
DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_forum, bool is_megagroup,
|
||||||
const DialogLocation &location, bool for_import,
|
const string &description, const DialogLocation &location,
|
||||||
MessageTtl message_ttl, int64 &random_id, Promise<Unit> &&promise) {
|
bool for_import, MessageTtl message_ttl, int64 &random_id,
|
||||||
|
Promise<Unit> &&promise) {
|
||||||
LOG(INFO) << "Trying to create " << (is_megagroup ? "supergroup" : "broadcast") << " with title \"" << title
|
LOG(INFO) << "Trying to create " << (is_megagroup ? "supergroup" : "broadcast") << " with title \"" << title
|
||||||
<< "\", description \"" << description << "\" and " << location;
|
<< "\", description \"" << description << "\" and " << location;
|
||||||
|
|
||||||
@ -21190,8 +21193,8 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_m
|
|||||||
created_dialogs_[random_id]; // reserve place for result
|
created_dialogs_[random_id]; // reserve place for result
|
||||||
|
|
||||||
td_->create_handler<CreateChannelQuery>(std::move(promise))
|
td_->create_handler<CreateChannelQuery>(std::move(promise))
|
||||||
->send(new_title, is_megagroup, strip_empty_characters(description, MAX_DESCRIPTION_LENGTH), location, for_import,
|
->send(new_title, is_forum, is_megagroup, strip_empty_characters(description, MAX_DESCRIPTION_LENGTH), location,
|
||||||
message_ttl, random_id);
|
for_import, message_ttl, random_id);
|
||||||
return DialogId();
|
return DialogId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ class MessagesManager final : public Actor {
|
|||||||
DialogId create_new_group_chat(const vector<UserId> &user_ids, const string &title, MessageTtl message_ttl,
|
DialogId create_new_group_chat(const vector<UserId> &user_ids, const string &title, MessageTtl message_ttl,
|
||||||
int64 &random_id, Promise<Unit> &&promise);
|
int64 &random_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
DialogId create_new_channel_chat(const string &title, bool is_megagroup, const string &description,
|
DialogId create_new_channel_chat(const string &title, bool is_forum, bool is_megagroup, const string &description,
|
||||||
const DialogLocation &location, bool for_import, MessageTtl message_ttl,
|
const DialogLocation &location, bool for_import, MessageTtl message_ttl,
|
||||||
int64 &random_id, Promise<Unit> &&promise);
|
int64 &random_id, Promise<Unit> &&promise);
|
||||||
|
|
||||||
|
@ -1683,6 +1683,7 @@ class CreateNewSecretChatRequest final : public RequestActor<SecretChatId> {
|
|||||||
|
|
||||||
class CreateNewSupergroupChatRequest final : public RequestActor<> {
|
class CreateNewSupergroupChatRequest final : public RequestActor<> {
|
||||||
string title_;
|
string title_;
|
||||||
|
bool is_forum_;
|
||||||
bool is_megagroup_;
|
bool is_megagroup_;
|
||||||
string description_;
|
string description_;
|
||||||
DialogLocation location_;
|
DialogLocation location_;
|
||||||
@ -1693,8 +1694,9 @@ class CreateNewSupergroupChatRequest final : public RequestActor<> {
|
|||||||
DialogId dialog_id_;
|
DialogId dialog_id_;
|
||||||
|
|
||||||
void do_run(Promise<Unit> &&promise) final {
|
void do_run(Promise<Unit> &&promise) final {
|
||||||
dialog_id_ = td_->messages_manager_->create_new_channel_chat(
|
dialog_id_ =
|
||||||
title_, is_megagroup_, description_, location_, for_import_, message_ttl_, random_id_, std::move(promise));
|
td_->messages_manager_->create_new_channel_chat(title_, is_forum_, is_megagroup_, description_, location_,
|
||||||
|
for_import_, message_ttl_, random_id_, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_send_result() final {
|
void do_send_result() final {
|
||||||
@ -1703,11 +1705,12 @@ class CreateNewSupergroupChatRequest final : public RequestActor<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreateNewSupergroupChatRequest(ActorShared<Td> td, uint64 request_id, string title, bool is_megagroup,
|
CreateNewSupergroupChatRequest(ActorShared<Td> td, uint64 request_id, string title, bool is_forum, bool is_megagroup,
|
||||||
string description, td_api::object_ptr<td_api::chatLocation> &&location,
|
string description, td_api::object_ptr<td_api::chatLocation> &&location,
|
||||||
bool for_import, int32 message_ttl)
|
bool for_import, int32 message_ttl)
|
||||||
: RequestActor(std::move(td), request_id)
|
: RequestActor(std::move(td), request_id)
|
||||||
, title_(std::move(title))
|
, title_(std::move(title))
|
||||||
|
, is_forum_(is_forum)
|
||||||
, is_megagroup_(is_megagroup)
|
, is_megagroup_(is_megagroup)
|
||||||
, description_(std::move(description))
|
, description_(std::move(description))
|
||||||
, location_(std::move(location))
|
, location_(std::move(location))
|
||||||
@ -5717,7 +5720,7 @@ void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) {
|
|||||||
CHECK_IS_USER();
|
CHECK_IS_USER();
|
||||||
CLEAN_INPUT_STRING(request.title_);
|
CLEAN_INPUT_STRING(request.title_);
|
||||||
CLEAN_INPUT_STRING(request.description_);
|
CLEAN_INPUT_STRING(request.description_);
|
||||||
CREATE_REQUEST(CreateNewSupergroupChatRequest, std::move(request.title_), !request.is_channel_,
|
CREATE_REQUEST(CreateNewSupergroupChatRequest, std::move(request.title_), request.is_forum_, !request.is_channel_,
|
||||||
std::move(request.description_), std::move(request.location_), request.for_import_,
|
std::move(request.description_), std::move(request.location_), request.for_import_,
|
||||||
request.message_auto_delete_time_);
|
request.message_auto_delete_time_);
|
||||||
}
|
}
|
||||||
|
@ -4340,17 +4340,21 @@ class CliClient final : public Actor {
|
|||||||
send_request(td_api::make_object<td_api::createNewBasicGroupChat>(as_user_ids(user_ids_string), title,
|
send_request(td_api::make_object<td_api::createNewBasicGroupChat>(as_user_ids(user_ids_string), title,
|
||||||
message_auto_delete_time));
|
message_auto_delete_time));
|
||||||
} else if (op == "cnchc" || op == "cnchcadt") {
|
} else if (op == "cnchc" || op == "cnchcadt") {
|
||||||
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, true, "Description", nullptr,
|
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, false, true, "Description", nullptr,
|
||||||
op == "cnchcadt" ? 86400 : 0, false));
|
op == "cnchcadt" ? 86400 : 0, false));
|
||||||
} else if (op == "cnsgc" || op == "cnsgcadt") {
|
} else if (op == "cnsgc" || op == "cnsgcadt") {
|
||||||
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, false, "Description", nullptr,
|
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, false, false, "Description", nullptr,
|
||||||
op == "cnsgcadt" ? 86400 : 0, false));
|
op == "cnsgcadt" ? 86400 : 0, false));
|
||||||
|
} 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));
|
||||||
} else if (op == "cnsgcloc") {
|
} else if (op == "cnsgcloc") {
|
||||||
send_request(td_api::make_object<td_api::createNewSupergroupChat>(
|
send_request(td_api::make_object<td_api::createNewSupergroupChat>(
|
||||||
args, false, "Description",
|
args, false, false, "Description",
|
||||||
td_api::make_object<td_api::chatLocation>(as_location("40.0", "60.0", ""), "address"), 0, false));
|
td_api::make_object<td_api::chatLocation>(as_location("40.0", "60.0", ""), "address"), 0, false));
|
||||||
} else if (op == "cnsgcimport") {
|
} else if (op == "cnsgcimport") {
|
||||||
send_request(td_api::make_object<td_api::createNewSupergroupChat>(args, false, "Description", nullptr, 0, true));
|
send_request(
|
||||||
|
td_api::make_object<td_api::createNewSupergroupChat>(args, false, false, "Description", nullptr, 0, true));
|
||||||
} else if (op == "UpgradeBasicGroupChatToSupergroupChat") {
|
} else if (op == "UpgradeBasicGroupChatToSupergroupChat") {
|
||||||
ChatId chat_id;
|
ChatId chat_id;
|
||||||
get_args(args, chat_id);
|
get_args(args, chat_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user