diff --git a/package/telegram_client/bin/generate_scheme.dart b/package/telegram_client/bin/generate_scheme.dart index e18477b9..6f2cdf4a 100644 --- a/package/telegram_client/bin/generate_scheme.dart +++ b/package/telegram_client/bin/generate_scheme.dart @@ -77,7 +77,7 @@ void main(List args) async { "created_at": "2022-12-26T05:26:40.500935+00:00", // "group": [], // "private": [], - "client_user_id": 0, + "client_tg_user_id": 0, "client_title": "", "client_token": "", "owner_user_id": 0, diff --git a/package/telegram_client/bin/tdlib_docs_to_json.dart b/package/telegram_client/bin/tdlib_docs_to_json.dart index 86d56a47..85a43bca 100644 --- a/package/telegram_client/bin/tdlib_docs_to_json.dart +++ b/package/telegram_client/bin/tdlib_docs_to_json.dart @@ -4,60 +4,18 @@ import 'package:general_lib/general_lib.dart'; void main(List args) async { String params = """ - -int64 id_ - Session identifier. - -bool is_current_ - True, if this session is the current session. - -bool is_password_pending_ - True, if a 2-step verification password is needed to complete authorization of the session. - -bool is_unconfirmed_ - True, if the session wasn't confirmed from another session. - -bool can_accept_secret_chats_ - True, if incoming secret chats can be accepted by the session. - -bool can_accept_calls_ - True, if incoming calls can be accepted by the session. - -object_ptr< SessionType > type_ - Session type based on the system and application version, which can be used to display a corresponding icon. - -int32 api_id_ - Telegram API identifier, as provided by the application. -string application_name_ - Name of the application, as provided by the application. - -string application_version_ - The version of the application, as provided by the application. - -bool is_official_application_ - True, if the application is an official application or uses the api_id of an official application. +string system_language_code_ + IETF language tag of the user's operating system language; must be non-empty. string device_model_ - Model of the device the application has been run or is running on, as provided by the application. - -string platform_ - Operating system the application has been run or is running on, as provided by the application. + Model of the device the application is being run on; must be non-empty. string system_version_ - Version of the operating system the application has been run or is running on, as provided by the application. + Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib. -int32 log_in_date_ - Point in time (Unix timestamp) when the user has logged in. - -int32 last_active_date_ - Point in time (Unix timestamp) when the session was last used. - -string ip_address_ - IP address from which the session was created, in human-readable format. - -string location_ - A human-readable description of the location from which the session was created, based on the IP address. +string application_version_ + Application version; must be non-empty. """ .trim(); diff --git a/package/telegram_client/lib/mtproto/mtproto_core.dart b/package/telegram_client/lib/mtproto/mtproto_core.dart index 5309a79d..c69af9db 100644 --- a/package/telegram_client/lib/mtproto/mtproto_core.dart +++ b/package/telegram_client/lib/mtproto/mtproto_core.dart @@ -76,8 +76,7 @@ class Mtproto { 'system_language_code': 'en', 'new_verbosity_level': 0, 'application_version': 'v1', - 'device_model': 'VGVsZWdyYW0gQ2xpZW50IEFaS0FERVYgR0xPQkFMIENPUlBPUkFUSU9O' - .general_lib_utils_decryptFromBase64(), + 'device_model': 'VGVsZWdyYW0gQ2xpZW50IEFaS0FERVYgR0xPQkFMIENPUlBPUkFUSU9O'.general_lib_utils_decryptFromBase64(), 'system_version': Platform.operatingSystemVersion, "database_key": "", "start": true, @@ -96,10 +95,8 @@ class Mtproto { Duration invoke_time_out = Duration(minutes: 10); late double timeOutUpdate; FutureOr Function(dynamic update, Mtproto Mtproto)? on_receive_update; - FutureOr Function(int client_id, Mtproto Mtproto)? - on_generate_extra_invoke; - FutureOr Function(String extra, int client_id, Mtproto Mtproto)? - on_get_invoke_data; + FutureOr Function(int client_id, Mtproto Mtproto)? on_generate_extra_invoke; + FutureOr Function(String extra, int client_id, Mtproto Mtproto)? on_get_invoke_data; Mtproto({ String? pathTdl, Map? clientOption, @@ -149,8 +146,7 @@ class Mtproto { } else if (update is MtprotoIsolateReceiveDataError) { MtprotoIsolateReceiveDataError tdlibIsolateReceiveDataError = update; try { - MtprotoClient? tdlibClient = - clients.getClientById(tdlibIsolateReceiveDataError.clientId); + MtprotoClient? tdlibClient = clients.getClientById(tdlibIsolateReceiveDataError.clientId); if (tdlibClient != null) { tdlibClient.close(); } @@ -237,7 +233,7 @@ class Mtproto { MtprotoClient? getClientByUserId(int clientUserId) { for (var i = 0; i < clients.length; i++) { MtprotoClient tdlibClient = clients[i]; - if (tdlibClient.client_user_id == clientUserId) { + if (tdlibClient.client_tg_user_id == clientUserId) { return tdlibClient; } } @@ -302,14 +298,11 @@ class Mtproto { } /// receive all update data - EventEmitterListener on( - String type_update, FutureOr Function(UpdateMt update) callback, - {void Function(Object data)? onError}) { + EventEmitterListener on(String type_update, FutureOr Function(UpdateMt update) callback, {void Function(Object data)? onError}) { return event_emitter.on(type_update, null, (Event ev, context) async { try { if (ev.eventData is MtprotoIsolateReceiveData) { - MtprotoIsolateReceiveData tdlibIsolateReceiveData = - (ev.eventData as MtprotoIsolateReceiveData); + MtprotoIsolateReceiveData tdlibIsolateReceiveData = (ev.eventData as MtprotoIsolateReceiveData); await callback(UpdateMt( update: tdlibIsolateReceiveData.updateData, client_id: tdlibIsolateReceiveData.clientId, @@ -345,10 +338,8 @@ class Mtproto { Duration? invokeTimeOut, String? extra, bool? iSAutoGetChat, - FutureOr Function(int client_id, Mtproto Mtproto)? - onGenerateExtraInvoke, - FutureOr Function(String extra, int client_id, Mtproto Mtproto)? - onGetInvokeData, + FutureOr Function(int client_id, Mtproto Mtproto)? onGenerateExtraInvoke, + FutureOr Function(String extra, int client_id, Mtproto Mtproto)? onGetInvokeData, bool isThrowOnError = true, }) async { onGetInvokeData ??= on_get_invoke_data; @@ -389,9 +380,7 @@ class Mtproto { parameters["@extra"] = generateUuid(15); } - if (iSAutoGetChat && - RegExp(r"^(sendMessage|getChatMember)$", caseSensitive: false) - .hashData(method)) { + if (iSAutoGetChat && RegExp(r"^(sendMessage|getChatMember)$", caseSensitive: false).hashData(method)) { if (parameters["chat_id"] is int) { client_send( clientId, diff --git a/package/telegram_client/lib/scheme/mtproto_client.dart b/package/telegram_client/lib/scheme/mtproto_client.dart index 7eab1dd3..59c799c8 100644 --- a/package/telegram_client/lib/scheme/mtproto_client.dart +++ b/package/telegram_client/lib/scheme/mtproto_client.dart @@ -40,13 +40,13 @@ import 'package:telegram_client/isolate/isolate.dart'; class MtprotoClient { int client_id; Isolate isolate; - int client_user_id; + int client_tg_user_id; DateTime join_date = DateTime.now(); MtprotoClient({ required this.client_id, required this.isolate, - this.client_user_id = 0, + this.client_tg_user_id = 0, }); /// close @@ -57,7 +57,7 @@ class MtprotoClient { Map toJson() { return { "client_id": client_id, - "client_user_id": client_user_id, + "client_tg_user_id": client_tg_user_id, "join_date": join_date.toString(), }; } @@ -73,7 +73,7 @@ extension MtprotoClients on List { MtprotoClient? getClientByUserId(int clientUserId) { for (var i = 0; i < length; i++) { MtprotoClient tdlibClient = this[i]; - if (tdlibClient.client_user_id == clientUserId) { + if (tdlibClient.client_tg_user_id == clientUserId) { return tdlibClient; } } diff --git a/package/telegram_client/lib/scheme/tdlib_client.dart b/package/telegram_client/lib/scheme/tdlib_client.dart index b6f4c27e..f9d4b481 100644 --- a/package/telegram_client/lib/scheme/tdlib_client.dart +++ b/package/telegram_client/lib/scheme/tdlib_client.dart @@ -37,7 +37,7 @@ import 'dart:convert'; /// add state data class TdlibClient { int client_id; - int client_user_id; + int client_tg_user_id; bool is_bot; Map client_option; Map client_dynamic = {}; @@ -49,14 +49,14 @@ class TdlibClient { required this.client_id, required this.client_option, this.is_bot = false, - this.client_user_id = 0, + this.client_tg_user_id = 0, }); /// add state data Map toJson() { return { "client_id": client_id, - "client_user_id": client_user_id, + "client_tg_user_id": client_tg_user_id, "join_date": join_date.millisecondsSinceEpoch, }; } diff --git a/package/telegram_client/lib/tdlib/tdlib_core.dart b/package/telegram_client/lib/tdlib/tdlib_core.dart index 090aae29..aa5ceeb8 100644 --- a/package/telegram_client/lib/tdlib/tdlib_core.dart +++ b/package/telegram_client/lib/tdlib/tdlib_core.dart @@ -216,8 +216,7 @@ class Tdlib extends TdlibNative { return await invoke( "checkDatabaseEncryptionKey", parameters: { - "encryption_key": - TgUtils.stringToBase64(value: client_option["database_key"]), + "encryption_key": TgUtils.stringToBase64(value: client_option["database_key"]), }, isUseCache: false, durationCacheExpire: null, @@ -230,8 +229,7 @@ class Tdlib extends TdlibNative { return await invoke( "setDatabaseEncryptionKey", parameters: { - "new_encryption_key": - TgUtils.stringToBase64(value: client_option["database_key"]), + "new_encryption_key": TgUtils.stringToBase64(value: client_option["database_key"]), }, clientId: clientId, isVoid: isVoid, @@ -244,15 +242,14 @@ class Tdlib extends TdlibNative { } if (authStateType == "authorizationStateClosed") { - await exitClientById(update.client_id, - isInvokeThrowOnError: isInvokeThrowOnError); + await exitClientById(update.client_id, isInvokeThrowOnError: isInvokeThrowOnError); return {"@type": "ok"}; } if (authStateType == "authorizationStateReady") { // TdlibClient? tdlibClient = getClientById(update.client_id); - // if (tdlibClient == null || tdlibClient.client_user_id != 0) { + // if (tdlibClient == null || tdlibClient.client_tg_user_id != 0) { // if (tdlibClient == null) { // return null; // } @@ -264,13 +261,13 @@ class Tdlib extends TdlibNative { ); if (clients[update.client_id] != null) { - clients[update.client_id]!.client_user_id = get_me["result"]["id"]; + clients[update.client_id]!.client_tg_user_id = get_me["result"]["id"]; } // for (var i = 0; i < clients.length; i++) { // TdlibClient tdlib_client = clients[i]; // if (tdlib_client.client_id == update.client_id) { - // tdlib_client.client_user_id = get_me["result"]["id"]; - // clients[i].client_user_id = get_me["result"]["id"]; + // tdlib_client.client_tg_user_id = get_me["result"]["id"]; + // clients[i].client_tg_user_id = get_me["result"]["id"]; // return null; // } // } @@ -422,10 +419,8 @@ class Tdlib extends TdlibNative { Map makeParametersApi(Map parameters) { Map jsonResult = {"@type": ""}; try { - String regexMethodSend = - r"^(sendMessage|sendPhoto|sendVideo|sendAudio|sendVoice|sendDocument|sendSticker|sendAnimation|editMessage(Text))$"; - if (RegExp(regexMethodSend, caseSensitive: false) - .hashData(parameters["@type"])) { + String regexMethodSend = r"^(sendMessage|sendPhoto|sendVideo|sendAudio|sendVoice|sendDocument|sendSticker|sendAnimation|editMessage(Text))$"; + if (RegExp(regexMethodSend, caseSensitive: false).hashData(parameters["@type"])) { jsonResult["@type"] = "sendMessage"; jsonResult["options"] = { "@type": "messageSendOptions", @@ -437,8 +432,7 @@ class Tdlib extends TdlibNative { } catch (e) {} } }); - if (RegExp("editMessage(Text)", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp("editMessage(Text)", caseSensitive: false).hashData(parameters["@type"])) { jsonResult["@type"] = parameters["@type"]; } @@ -456,8 +450,7 @@ class Tdlib extends TdlibNative { }; jsonResult["chat_id"] = parameters["chat_id"]; if (parameters["disable_notification"] is bool) { - jsonResult["disable_notification"] = - parameters["reply_to_message_id"]; + jsonResult["disable_notification"] = parameters["reply_to_message_id"]; } if (parameters["reply_to_message_id"] is int) { jsonResult["reply_to_message_id"] = parameters["reply_to_message_id"]; @@ -483,8 +476,7 @@ class Tdlib extends TdlibNative { if (parameters.containsKey("reply_markup")) { jsonResult["reply_markup"] = replyMarkup(parameters["reply_markup"]); } - if (RegExp(r"^(sendMessage|editMessageText)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendMessage|editMessageText)$", caseSensitive: false).hashData(parameters["@type"])) { var text = parseMode( parameters["text"].toString(), parameters["parse_mode"], @@ -493,58 +485,45 @@ class Tdlib extends TdlibNative { jsonResult["input_message_content"]["@type"] = "inputMessageText"; jsonResult["input_message_content"]["text"] = text; } - if (RegExp(r"^(sendPhoto)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendPhoto)$", caseSensitive: false).hashData(parameters["@type"])) { var getDetailFile = typeFile(parameters["photo"]); jsonResult["input_message_content"]["@type"] = "inputMessagePhoto"; jsonResult["input_message_content"]["photo"] = getDetailFile; } - if (RegExp(r"^(sendVoice)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendVoice)$", caseSensitive: false).hashData(parameters["@type"])) { var getDetailFile = typeFile(parameters["voice"]); - jsonResult["input_message_content"]["@type"] = - "inputMessageVoiceNote"; + jsonResult["input_message_content"]["@type"] = "inputMessageVoiceNote"; jsonResult["input_message_content"]["voice_note"] = getDetailFile; } - if (RegExp(r"^(sendSticker)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendSticker)$", caseSensitive: false).hashData(parameters["@type"])) { var getDetailFile = typeFile(parameters["sticker"]); jsonResult["input_message_content"]["@type"] = "inputMessageSticker"; jsonResult["input_message_content"]["sticker"] = getDetailFile; } - if (RegExp(r"^(sendAnimation)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendAnimation)$", caseSensitive: false).hashData(parameters["@type"])) { var getDetailFile = typeFile(parameters["animation"]); - jsonResult["input_message_content"]["@type"] = - "inputMessageAnimation"; + jsonResult["input_message_content"]["@type"] = "inputMessageAnimation"; jsonResult["input_message_content"]["animation"] = getDetailFile; } - if (RegExp(r"^(sendDocument)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendDocument)$", caseSensitive: false).hashData(parameters["@type"])) { var getDetailFile = typeFile(parameters["document"]); jsonResult["input_message_content"]["@type"] = "inputMessageDocument"; jsonResult["input_message_content"]["document"] = getDetailFile; } - if (RegExp(r"^(sendAudio)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendAudio)$", caseSensitive: false).hashData(parameters["@type"])) { var getDetailFile = typeFile(parameters["audio"]); jsonResult["input_message_content"]["@type"] = "inputMessageAudio"; jsonResult["input_message_content"]["audio"] = getDetailFile; } - if (RegExp(r"^(sendVideo)$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^(sendVideo)$", caseSensitive: false).hashData(parameters["@type"])) { var getDetailFile = typeFile(parameters["video"]); jsonResult["input_message_content"]["@type"] = "inputMessageVideo"; jsonResult["input_message_content"]["video"] = getDetailFile; } - if (!RegExp(r"^(sendMessage|sendLocation|sendSticker)$", - caseSensitive: false) - .hashData(parameters["@type"])) { + if (!RegExp(r"^(sendMessage|sendLocation|sendSticker)$", caseSensitive: false).hashData(parameters["@type"])) { if (parameters["caption"] != null) { var caption = parseMode( - (parameters["caption"] != null) - ? parameters["caption"].toString() - : "", + (parameters["caption"] != null) ? parameters["caption"].toString() : "", parameters["parse_mode"], parameters["entities"], ); @@ -554,8 +533,7 @@ class Tdlib extends TdlibNative { return jsonResult; } - if (RegExp(r"^answerInlineQuery$", caseSensitive: false) - .hashData(parameters["@type"])) { + if (RegExp(r"^answerInlineQuery$", caseSensitive: false).hashData(parameters["@type"])) { parameters["@type"] = "answerInlineQuery"; if (parameters["results"] is List) { @@ -564,8 +542,7 @@ class Tdlib extends TdlibNative { Map loop_data = parameters["results"][i]; if (loop_data["type"] is String) { - loop_data["@type"] = - "inputInlineQueryResult${loop_data["type"].toString().replaceAll(RegExp(r"inputInlineQueryResult", caseSensitive: false), "")}"; + loop_data["@type"] = "inputInlineQueryResult${loop_data["type"].toString().replaceAll(RegExp(r"inputInlineQueryResult", caseSensitive: false), "")}"; loop_data.remove("type"); } if (loop_data["id"] is String == false) { @@ -574,8 +551,7 @@ class Tdlib extends TdlibNative { } if (loop_data["reply_markup"] is Map) { - loop_data["reply_markup"] = - (replyMarkup(loop_data["reply_markup"])); + loop_data["reply_markup"] = (replyMarkup(loop_data["reply_markup"])); } array_results.add(loop_data); } @@ -598,8 +574,7 @@ class Tdlib extends TdlibNative { "@type": 'inputFileRemote', "id": content, }; - } else if (RegExp(r"^(\/|\.\.?\/|~\/)", caseSensitive: false) - .hashData(content)) { + } else if (RegExp(r"^(\/|\.\.?\/|~\/)", caseSensitive: false).hashData(content)) { data = { "@type": 'inputFileLocal', "path": content, @@ -704,8 +679,7 @@ class Tdlib extends TdlibNative { result["usernames"] = get_me["usernames"]; if (get_user_usernames["active_usernames"] is List) { if ((get_user_usernames["active_usernames"] as List).isNotEmpty) { - result["username"] = - (get_user_usernames["active_usernames"] as List).first; + result["username"] = (get_user_usernames["active_usernames"] as List).first; } } } @@ -713,14 +687,8 @@ class Tdlib extends TdlibNative { if (get_me["phone_number"].toString().isNotEmpty) { result["phone_number"] = get_me["phone_number"]; } - result["status"] = get_me["status"]["@type"] - .toString() - .toLowerCase() - .replaceAll(RegExp("userStatus", caseSensitive: false), ""); - result["type_account"] = get_me["type"]["@type"] - .toString() - .toLowerCase() - .replaceAll(RegExp("userType", caseSensitive: false), ""); + result["status"] = get_me["status"]["@type"].toString().toLowerCase().replaceAll(RegExp("userStatus", caseSensitive: false), ""); + result["type_account"] = get_me["type"]["@type"].toString().toLowerCase().replaceAll(RegExp("userType", caseSensitive: false), ""); result["type"] = "private"; if (result["type_account"] == "bot") { result["is_bot"] = true; @@ -749,15 +717,13 @@ class Tdlib extends TdlibNative { "file_id": "", }; if (get_me["profile_photo"]["big"] is Map) { - (get_me["profile_photo"]["big"]["local"] as Map) - .forEach((key, value) { + (get_me["profile_photo"]["big"]["local"] as Map).forEach((key, value) { if (key != "@type") { result["profile_photo"][key.toString()] = value; } }); if (get_me["profile_photo"]["big"]["remote"] is Map) { - result["profile_photo"]["file_id"] = - get_me["profile_photo"]["big"]["remote"]["id"]; + result["profile_photo"]["file_id"] = get_me["profile_photo"]["big"]["remote"]["id"]; } } } @@ -776,12 +742,10 @@ class Tdlib extends TdlibNative { Map json = { "@type": "replyMarkupRemoveKeyboard", }; - json["is_personal"] = - (keyboard["is_personal"] is bool) ? keyboard["is_personal"] : true; + json["is_personal"] = (keyboard["is_personal"] is bool) ? keyboard["is_personal"] : true; return json; } - if (keyboard["keyboard"] is List && - (keyboard["keyboard"] as List).isNotEmpty) { + if (keyboard["keyboard"] is List && (keyboard["keyboard"] as List).isNotEmpty) { Map json = { "@type": "replyMarkupShowKeyboard", }; @@ -802,12 +766,10 @@ class Tdlib extends TdlibNative { in_json_keyboard["text"] = in_loop_array_keyboard["text"]; } if (in_loop_array_keyboard["request_contact"] == true) { - in_json_keyboard["type"]["@type"] = - "keyboardButtonTypeRequestPhoneNumber"; + in_json_keyboard["type"]["@type"] = "keyboardButtonTypeRequestPhoneNumber"; } if (in_loop_array_keyboard["request_location"] == true) { - in_json_keyboard["type"]["@type"] = - "keyboardButtonTypeRequestLocation"; + in_json_keyboard["type"]["@type"] = "keyboardButtonTypeRequestLocation"; } array_loop.add(in_json_keyboard); } @@ -815,18 +777,13 @@ class Tdlib extends TdlibNative { array_rows.add(array_loop); } json["rows"] = array_rows; - json["resize_keyboard"] = (keyboard["resize_keyboard"] is bool) - ? keyboard["resize_keyboard"] - : true; - json["one_time"] = - (keyboard["one_time"] is bool) ? keyboard["one_time"] : true; - json["is_personal"] = - (keyboard["is_personal"] is bool) ? keyboard["is_personal"] : true; + json["resize_keyboard"] = (keyboard["resize_keyboard"] is bool) ? keyboard["resize_keyboard"] : true; + json["one_time"] = (keyboard["one_time"] is bool) ? keyboard["one_time"] : true; + json["is_personal"] = (keyboard["is_personal"] is bool) ? keyboard["is_personal"] : true; return json; } - if (keyboard["inline_keyboard"] is List && - keyboard["inline_keyboard"].length > 0) { + if (keyboard["inline_keyboard"] is List && keyboard["inline_keyboard"].length > 0) { Map json = { "@type": "replyMarkupInlineKeyboard", }; @@ -842,10 +799,7 @@ class Tdlib extends TdlibNative { } if (TgUtils.getBoolean(in_loop_array_keyboard["url"])) { - in_json_keyboard["type"] = { - "@type": "inlineKeyboardButtonTypeUrl", - "url": in_loop_array_keyboard["url"] - }; + in_json_keyboard["type"] = {"@type": "inlineKeyboardButtonTypeUrl", "url": in_loop_array_keyboard["url"]}; } if (TgUtils.getBoolean(in_loop_array_keyboard["login_url"])) { @@ -855,45 +809,21 @@ class Tdlib extends TdlibNative { }; } if (TgUtils.getBoolean(in_loop_array_keyboard["callback_data"])) { - in_json_keyboard["type"] = { - "@type": "inlineKeyboardButtonTypeCallback", - "data": convert.base64.encode(convert.utf8 - .encode(in_loop_array_keyboard["callback_data"])) - }; + in_json_keyboard["type"] = {"@type": "inlineKeyboardButtonTypeCallback", "data": convert.base64.encode(convert.utf8.encode(in_loop_array_keyboard["callback_data"]))}; } - if (TgUtils.getBoolean( - in_loop_array_keyboard["callback_data_password"])) { - in_json_keyboard["type"] = { - "@type": "inlineKeyboardButtonTypeCallbackWithPassword", - "data": convert.base64.encode(convert.utf8 - .encode(in_loop_array_keyboard["callback_data_password"])) - }; + if (TgUtils.getBoolean(in_loop_array_keyboard["callback_data_password"])) { + in_json_keyboard["type"] = {"@type": "inlineKeyboardButtonTypeCallbackWithPassword", "data": convert.base64.encode(convert.utf8.encode(in_loop_array_keyboard["callback_data_password"]))}; } - if (TgUtils.getBoolean( - in_loop_array_keyboard["switch_inline_query"])) { - in_json_keyboard["type"] = { - "@type": "inlineKeyboardButtonTypeSwitchInline", - "query": in_loop_array_keyboard["switch_inline_query"], - "in_current_chat": false - }; + if (TgUtils.getBoolean(in_loop_array_keyboard["switch_inline_query"])) { + in_json_keyboard["type"] = {"@type": "inlineKeyboardButtonTypeSwitchInline", "query": in_loop_array_keyboard["switch_inline_query"], "in_current_chat": false}; } - if (TgUtils.getBoolean( - in_loop_array_keyboard["switch_inline_query_current_chat"])) { - in_json_keyboard["type"] = { - "@type": "inlineKeyboardButtonTypeSwitchInline", - "query": - in_loop_array_keyboard["switch_inline_query_current_chat"], - "in_current_chat": true - }; + if (TgUtils.getBoolean(in_loop_array_keyboard["switch_inline_query_current_chat"])) { + in_json_keyboard["type"] = {"@type": "inlineKeyboardButtonTypeSwitchInline", "query": in_loop_array_keyboard["switch_inline_query_current_chat"], "in_current_chat": true}; } if (TgUtils.getBoolean(in_loop_array_keyboard["callback_game"])) { - in_json_keyboard["type"] = { - "@type": "inlineKeyboardButtonTypeSwitchInline", - "query": in_loop_array_keyboard["callback_game"], - "in_current_chat": false - }; + in_json_keyboard["type"] = {"@type": "inlineKeyboardButtonTypeSwitchInline", "query": in_loop_array_keyboard["callback_game"], "in_current_chat": false}; } if (TgUtils.getBoolean(in_loop_array_keyboard["user_id"])) { in_json_keyboard["type"] = { @@ -902,9 +832,7 @@ class Tdlib extends TdlibNative { }; } if (TgUtils.getBoolean(in_loop_array_keyboard["pay"])) { - in_json_keyboard["type"] = { - "@type": "inlineKeyboardButtonTypeBuy" - }; + in_json_keyboard["type"] = {"@type": "inlineKeyboardButtonTypeBuy"}; } array_loop.add(in_json_keyboard); } @@ -928,10 +856,8 @@ class Tdlib extends TdlibNative { Duration? invokeTimeOut, String? extra, bool? isAutoGetChat, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? onGetInvokeData, bool? isInvokeThrowOnError, bool isAutoExtendMessage = false, bool? isUseCache, @@ -941,9 +867,7 @@ class Tdlib extends TdlibNative { parameters ??= {}; isAutoGetChat ??= false; - if (parameters["chat_id"] is String && - RegExp(r"^(@)?[a-z0-9_]+", caseSensitive: false) - .hashData(parameters["chat_id"])) { + if (parameters["chat_id"] is String && RegExp(r"^(@)?[a-z0-9_]+", caseSensitive: false).hashData(parameters["chat_id"])) { isAutoGetChat = false; var search_public_chat = await invoke( "searchPublicChat", @@ -964,9 +888,7 @@ class Tdlib extends TdlibNative { parameters["chat_id"] = search_public_chat["id"]; } } - if (parameters["user_id"] is String && - RegExp(r"^(@)?[a-z0-9_]+", caseSensitive: false) - .hashData(parameters["user_id"])) { + if (parameters["user_id"] is String && RegExp(r"^(@)?[a-z0-9_]+", caseSensitive: false).hashData(parameters["user_id"])) { isAutoGetChat = false; var search_public_chat = await invoke( "searchPublicChat", @@ -987,16 +909,13 @@ class Tdlib extends TdlibNative { parameters["user_id"] = search_public_chat["id"]; } } - String regexMethodSend = - r"^(sendMessage|sendPhoto|sendVideo|sendAudio|sendVoice|sendDocument|sendSticker|sendAnimation)$"; + String regexMethodSend = r"^(sendMessage|sendPhoto|sendVideo|sendAudio|sendVoice|sendDocument|sendSticker|sendAnimation)$"; if (RegExp(regexMethodSend, caseSensitive: false).hashData(method)) { Map result_request = { "ok": false, }; result_request = await invoke( - (RegExp("editMessageText", caseSensitive: false).hashData(method)) - ? method - : "sendMessage", + (RegExp("editMessageText", caseSensitive: false).hashData(method)) ? method : "sendMessage", parameters: makeParametersApi( { "@type": method, @@ -1035,14 +954,11 @@ class Tdlib extends TdlibNative { return; } Map updateOrigin = update.raw; - if (!["updateMessageSendSucceeded", "updateMessageSendFailed"] - .contains(updateOrigin["@type"])) { + if (!["updateMessageSendSucceeded", "updateMessageSendFailed"].contains(updateOrigin["@type"])) { return; } - if (updateOrigin["message"] is Map && - updateOrigin["message"]["chat_id"] == result_request["chat_id"] && - updateOrigin["old_message_id"] == result_request["id"]) { + if (updateOrigin["message"] is Map && updateOrigin["message"]["chat_id"] == result_request["chat_id"] && updateOrigin["old_message_id"] == result_request["id"]) { // updateOrigin.printPretty(2); // completer.complete(updateOrigin); @@ -1140,37 +1056,24 @@ class Tdlib extends TdlibNative { message_id: parameters["message_id"], text: parameters["text"], inline_message_id: parameters["inline_message_id"], - parse_mode: (parameters["parse_mode"] is String) - ? parameters["parse_mode"] - : "html", - entities: - (parameters["entities"] is List) ? parameters["entities"] : [], - disable_web_page_preview: - (parameters["disable_web_page_preview"] is bool) - ? parameters["disable_web_page_preview"] - : false, + parse_mode: (parameters["parse_mode"] is String) ? parameters["parse_mode"] : "html", + entities: (parameters["entities"] is List) ? parameters["entities"] : [], + disable_web_page_preview: (parameters["disable_web_page_preview"] is bool) ? parameters["disable_web_page_preview"] : false, reply_markup: parameters["reply_markup"], clientId: clientId, isUseCache: isUseCache, durationCacheExpire: durationCacheExpire, ); } - if (RegExp(r"^editMessageCaption$", caseSensitive: false) - .hashData(method)) { + if (RegExp(r"^editMessageCaption$", caseSensitive: false).hashData(method)) { return await editMessageCaption( chat_id: parameters["chat_id"], message_id: parameters["message_id"], caption: parameters["caption"], inline_message_id: parameters["inline_message_id"], - parse_mode: (parameters["parse_mode"] is String) - ? parameters["parse_mode"] - : "html", - entities: - (parameters["entities"] is List) ? parameters["entities"] : [], - disable_web_page_preview: - (parameters["disable_web_page_preview"] is bool) - ? parameters["disable_web_page_preview"] - : false, + parse_mode: (parameters["parse_mode"] is String) ? parameters["parse_mode"] : "html", + entities: (parameters["entities"] is List) ? parameters["entities"] : [], + disable_web_page_preview: (parameters["disable_web_page_preview"] is bool) ? parameters["disable_web_page_preview"] : false, reply_markup: parameters["reply_markup"], clientId: clientId, isUseCache: isUseCache, @@ -1196,8 +1099,7 @@ class Tdlib extends TdlibNative { onGetInvokeData: onGetInvokeData, ); } - if (RegExp(r"^joinChatByInviteLink$", caseSensitive: false) - .hashData(method)) { + if (RegExp(r"^joinChatByInviteLink$", caseSensitive: false).hashData(method)) { return await invoke( "joinChatByInviteLink", parameters: { @@ -1292,8 +1194,7 @@ class Tdlib extends TdlibNative { durationCacheExpire: durationCacheExpire, ); } - if (RegExp(r"^answerCallbackQuery$", caseSensitive: false) - .hashData(method)) { + if (RegExp(r"^answerCallbackQuery$", caseSensitive: false).hashData(method)) { return await answerCallbackQuery( parameters["callback_query_id"], text: parameters["text"], @@ -1358,10 +1259,8 @@ class Tdlib extends TdlibNative { Duration? invokeTimeOut, String? extra, bool? isAutoGetChat, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? onGetInvokeData, bool? isInvokeThrowOnError, bool isAutoExtendMessage = false, bool? isUseCache, @@ -1381,8 +1280,7 @@ class Tdlib extends TdlibNative { try { await Future.delayed(Duration(milliseconds: 500)); parameters["text"] = loopData; - if (RegExp("(editMessageText)", caseSensitive: false) - .hasMatch(method)) { + if (RegExp("(editMessageText)", caseSensitive: false).hasMatch(method)) { if (i != 0) { method = "sendMessage"; } @@ -1421,8 +1319,7 @@ class Tdlib extends TdlibNative { try { await Future.delayed(Duration(milliseconds: 500)); parameters["caption"] = loopData; - if (RegExp("(editMessageCaption)", caseSensitive: false) - .hasMatch(method)) { + if (RegExp("(editMessageCaption)", caseSensitive: false).hasMatch(method)) { if (i != 0) { parameters["text"] = loopData; method = "sendMessage"; @@ -1693,8 +1590,7 @@ class Tdlib extends TdlibNative { extra: extra, ); - if (RegExp("^chatMember\$", caseSensitive: false) - .hashData(get_chat_member["@type"])) { + if (RegExp("^chatMember\$", caseSensitive: false).hashData(get_chat_member["@type"])) { var json = {}; var get_user = await getUser( @@ -1706,10 +1602,7 @@ class Tdlib extends TdlibNative { json["user"] = get_user["result"]; json["join_date"] = get_chat_member["joined_chat_date"]; var status = get_chat_member["status"]; - json["status"] = status["@type"] - .toString() - .toLowerCase() - .replaceAll(RegExp("chatmemberstatus", caseSensitive: false), ""); + json["status"] = status["@type"].toString().toLowerCase().replaceAll(RegExp("chatmemberstatus", caseSensitive: false), ""); json["custom_title"] = status["custom_title"]; json["can_be_edited"] = status["can_be_edited"]; json["can_manage_chat"] = status["can_manage_chat"]; @@ -1744,14 +1637,11 @@ class Tdlib extends TdlibNative { String? extra, }) async { try { - if (chat_id is String && - RegExp(r"^((@)?[a-z0-9_]+)$", caseSensitive: false) - .hashData(chat_id)) { + if (chat_id is String && RegExp(r"^((@)?[a-z0-9_]+)$", caseSensitive: false).hashData(chat_id)) { var search_public_chat = await invoke( "searchPublicChat", parameters: { - "username": - chat_id.replaceAll(RegExp(r"@", caseSensitive: false), ""), + "username": chat_id.replaceAll(RegExp(r"@", caseSensitive: false), ""), }, isUseCache: isUseCache, durationCacheExpire: durationCacheExpire, @@ -1773,20 +1663,14 @@ class Tdlib extends TdlibNative { extra: extra, ); Map json = {}; - if (RegExp(r"^(chat)$", caseSensitive: false) - .hashData(getchat["@type"])) { - var type_chat = getchat["type"]["@type"] - .toString() - .toLowerCase() - .replaceAll(RegExp("chattype", caseSensitive: false), ""); + if (RegExp(r"^(chat)$", caseSensitive: false).hashData(getchat["@type"])) { + var type_chat = getchat["type"]["@type"].toString().toLowerCase().replaceAll(RegExp("chattype", caseSensitive: false), ""); if (type_chat == "supergroup") { var getSupergroup = await invoke( "getSupergroup", parameters: { "supergroup_id": int.parse( - chat_id - .toString() - .replaceAll(RegExp("^-100", caseSensitive: false), ""), + chat_id.toString().replaceAll(RegExp("^-100", caseSensitive: false), ""), ), }, isUseCache: isUseCache, @@ -1805,52 +1689,15 @@ class Tdlib extends TdlibNative { json["usernames"] = getSupergroup["usernames"]; if (get_user_usernames["active_usernames"] is List) { if ((get_user_usernames["active_usernames"] as List).isNotEmpty) { - json["username"] = - (get_user_usernames["active_usernames"] as List).first; + json["username"] = (get_user_usernames["active_usernames"] as List).first; } } } if (getSupergroup["status"] is Map) { - json["status"] = getSupergroup["status"]["@type"] - .toString() - .toLowerCase() - .replaceAll( - RegExp("chatMemberStatus", caseSensitive: false), ""); + json["status"] = getSupergroup["status"]["@type"].toString().toLowerCase().replaceAll(RegExp("chatMemberStatus", caseSensitive: false), ""); } - json["type"] = - getchat["type"]["is_channel"] ? "channel" : "supergroup"; - json["detail"] = { - "member_count": getSupergroup["member_count"], - "administrator_count": 0, - "restricted_count": 0, - "banned_count": 0, - "has_protected_content": getchat["has_protected_content"] ?? false, - "is_marked_as_unread": getchat["is_marked_as_unread"] ?? false, - "is_blocked": getchat["is_blocked"] ?? false, - "has_scheduled_messages": - getchat["has_scheduled_messages"] ?? false, - "can_be_deleted_only_for_self": - getchat["can_be_deleted_only_for_self"] ?? false, - "can_be_deleted_for_all_users": - getchat["can_be_deleted_for_all_users"] ?? false, - "can_be_reported": getchat["can_be_reported"] ?? false, - "default_disable_notification": - getchat["default_disable_notification"] ?? false, - "unread_count": getchat["unread_count"] ?? 0, - "last_read_inbox_message_id": - getchat["last_read_inbox_message_id"] ?? 0, - "last_read_outbox_message_id": - getchat["last_read_outbox_message_id"] ?? 0, - "unread_mention_count": getchat["unread_mention_count"] ?? 0, - "has_linked_chat": getSupergroup["has_linked_chat"], - "has_location": getSupergroup["has_location"], - "sign_messages": getSupergroup["sign_messages"], - "is_slow_mode_enabled": getSupergroup["is_slow_mode_enabled"], - "is_broadcast_group": getSupergroup["is_broadcast_group"], - "is_verified": getSupergroup["is_verified"], - "is_scam": getSupergroup["is_scam"], - "is_fake": getSupergroup["is_fake"] - }; + json["type"] = getchat["type"]["is_channel"] ? "channel" : "supergroup"; + json["detail"] = {"member_count": getSupergroup["member_count"], "administrator_count": 0, "restricted_count": 0, "banned_count": 0, "has_protected_content": getchat["has_protected_content"] ?? false, "is_marked_as_unread": getchat["is_marked_as_unread"] ?? false, "is_blocked": getchat["is_blocked"] ?? false, "has_scheduled_messages": getchat["has_scheduled_messages"] ?? false, "can_be_deleted_only_for_self": getchat["can_be_deleted_only_for_self"] ?? false, "can_be_deleted_for_all_users": getchat["can_be_deleted_for_all_users"] ?? false, "can_be_reported": getchat["can_be_reported"] ?? false, "default_disable_notification": getchat["default_disable_notification"] ?? false, "unread_count": getchat["unread_count"] ?? 0, "last_read_inbox_message_id": getchat["last_read_inbox_message_id"] ?? 0, "last_read_outbox_message_id": getchat["last_read_outbox_message_id"] ?? 0, "unread_mention_count": getchat["unread_mention_count"] ?? 0, "has_linked_chat": getSupergroup["has_linked_chat"], "has_location": getSupergroup["has_location"], "sign_messages": getSupergroup["sign_messages"], "is_slow_mode_enabled": getSupergroup["is_slow_mode_enabled"], "is_broadcast_group": getSupergroup["is_broadcast_group"], "is_verified": getSupergroup["is_verified"], "is_scam": getSupergroup["is_scam"], "is_fake": getSupergroup["is_fake"]}; if (getSupergroup["username"].toString().isEmpty) { json.remove("username"); json["type"] = getchat["type"]["is_channel"] ? "channel" : "group"; @@ -1877,9 +1724,7 @@ class Tdlib extends TdlibNative { getSuperGroupFullInfo = await invoke( "getSupergroupFullInfo", parameters: { - "supergroup_id": int.parse(chat_id - .toString() - .replaceAll(RegExp("^-100", caseSensitive: false), "")), + "supergroup_id": int.parse(chat_id.toString().replaceAll(RegExp("^-100", caseSensitive: false), "")), }, isUseCache: isUseCache, durationCacheExpire: durationCacheExpire, @@ -1888,25 +1733,16 @@ class Tdlib extends TdlibNative { ); } catch (e) {} if (getSuperGroupFullInfo["photo"] is Map) { - json["profile_photo"] = { - "id": getSuperGroupFullInfo["photo"]["id"], - "path": "", - "file_id": "" - }; + json["profile_photo"] = {"id": getSuperGroupFullInfo["photo"]["id"], "path": "", "file_id": ""}; if (getSuperGroupFullInfo["photo"]["@type"] == "chatPhoto") { if (getSuperGroupFullInfo["photo"]["sizes"] is List) { try { - var getPhoto = getSuperGroupFullInfo["photo"]["sizes"] - [getSuperGroupFullInfo["photo"]["sizes"].length - 1]; - var getPathPhoto = - getPhoto["photo"]["local"]["path"] as String; + var getPhoto = getSuperGroupFullInfo["photo"]["sizes"][getSuperGroupFullInfo["photo"]["sizes"].length - 1]; + var getPathPhoto = getPhoto["photo"]["local"]["path"] as String; json["profile_photo"]["path"] = getPathPhoto; - (json["profile_photo"] as Map) - .addAll(getPhoto["photo"]["local"]); - json["profile_photo"]["file_id"] = - getPhoto["photo"]["remote"]["id"]; - json["profile_photo"]["file_unique_id"] = - getPhoto["photo"]["remote"]["unique_id"]; + (json["profile_photo"] as Map).addAll(getPhoto["photo"]["local"]); + json["profile_photo"]["file_id"] = getPhoto["photo"]["remote"]["id"]; + json["profile_photo"]["file_unique_id"] = getPhoto["photo"]["remote"]["unique_id"]; } catch (e) {} } } @@ -1932,12 +1768,9 @@ class Tdlib extends TdlibNative { }); } catch (e) {} - if (json["profile_photo"] is Map && - RegExp(r"^([0-9]+)$", caseSensitive: false) - .hashData(json["profile_photo"]["id"])) { + if (json["profile_photo"] is Map && RegExp(r"^([0-9]+)$", caseSensitive: false).hashData(json["profile_photo"]["id"])) { try { - json["profile_photo"]["id"] = - (int.parse(json["profile_photo"]["id"])); + json["profile_photo"]["id"] = (int.parse(json["profile_photo"]["id"])); } catch (e) {} } } @@ -1947,9 +1780,7 @@ class Tdlib extends TdlibNative { var getBasicGroup = await invoke( "getBasicGroup", parameters: { - "basic_group_id": int.parse(chat_id - .toString() - .replaceAll(RegExp("^-", caseSensitive: false), "")), + "basic_group_id": int.parse(chat_id.toString().replaceAll(RegExp("^-", caseSensitive: false), "")), }, isUseCache: isUseCache, durationCacheExpire: durationCacheExpire, @@ -1959,11 +1790,7 @@ class Tdlib extends TdlibNative { json["id"] = chat_id; json["title"] = getchat["title"]; if (getBasicGroup["status"] is Map) { - json["status"] = getBasicGroup["status"]["@type"] - .toString() - .toLowerCase() - .replaceAll( - RegExp("chatMemberStatus", caseSensitive: false), ""); + json["status"] = getBasicGroup["status"]["@type"].toString().toLowerCase().replaceAll(RegExp("chatMemberStatus", caseSensitive: false), ""); } json["type"] = "group"; json["detail"] = { @@ -1971,20 +1798,14 @@ class Tdlib extends TdlibNative { "has_protected_content": getchat["has_protected_content"] ?? false, "is_marked_as_unread": getchat["is_marked_as_unread"] ?? false, "is_blocked": getchat["is_blocked"] ?? false, - "has_scheduled_messages": - getchat["has_scheduled_messages"] ?? false, - "can_be_deleted_only_for_self": - getchat["can_be_deleted_only_for_self"] ?? false, - "can_be_deleted_for_all_users": - getchat["can_be_deleted_for_all_users"] ?? false, + "has_scheduled_messages": getchat["has_scheduled_messages"] ?? false, + "can_be_deleted_only_for_self": getchat["can_be_deleted_only_for_self"] ?? false, + "can_be_deleted_for_all_users": getchat["can_be_deleted_for_all_users"] ?? false, "can_be_reported": getchat["can_be_reported"] ?? false, - "default_disable_notification": - getchat["default_disable_notification"] ?? false, + "default_disable_notification": getchat["default_disable_notification"] ?? false, "unread_count": getchat["unread_count"] ?? 0, - "last_read_inbox_message_id": - getchat["last_read_inbox_message_id"] ?? 0, - "last_read_outbox_message_id": - getchat["last_read_outbox_message_id"] ?? 0, + "last_read_inbox_message_id": getchat["last_read_inbox_message_id"] ?? 0, + "last_read_outbox_message_id": getchat["last_read_outbox_message_id"] ?? 0, "unread_mention_count": getchat["unread_mention_count"] ?? 0, }; if (is_detail) { @@ -2015,13 +1836,11 @@ class Tdlib extends TdlibNative { clientId: clientId, extra: extra, ); - if (RegExp("^user\$", caseSensitive: false) - .hashData(get_user["@type"])) { + if (RegExp("^user\$", caseSensitive: false).hashData(get_user["@type"])) { var json = {}; json["id"] = get_user["id"]; try { - if (RegExp("^userTypeBot\$", caseSensitive: false) - .hashData(get_user["type"]["@type"])) { + if (RegExp("^userTypeBot\$", caseSensitive: false).hashData(get_user["type"]["@type"])) { json["is_bot"] = true; } else { json["is_bot"] = false; @@ -2041,10 +1860,8 @@ class Tdlib extends TdlibNative { Map get_user_usernames = (get_user["usernames"] as Map); json["usernames"] = get_user["usernames"]; if (get_user_usernames["active_usernames"] is List) { - if ((get_user_usernames["active_usernames"] as List) - .isNotEmpty) { - json["username"] = - (get_user_usernames["active_usernames"] as List).first; + if ((get_user_usernames["active_usernames"] as List).isNotEmpty) { + json["username"] = (get_user_usernames["active_usernames"] as List).first; } } } @@ -2056,34 +1873,7 @@ class Tdlib extends TdlibNative { json["language_code"] = get_user["language_code"]; } json["type"] = 'private'; - json["detail"] = { - "has_protected_content": - getchat["has_protected_content"] ?? false, - "is_marked_as_unread": getchat["is_marked_as_unread"] ?? false, - "is_blocked": getchat["is_blocked"] ?? false, - "has_scheduled_messages": - getchat["has_scheduled_messages"] ?? false, - "can_be_deleted_only_for_self": - getchat["can_be_deleted_only_for_self"] ?? false, - "can_be_deleted_for_all_users": - getchat["can_be_deleted_for_all_users"] ?? false, - "can_be_reported": getchat["can_be_reported"] ?? false, - "default_disable_notification": - getchat["default_disable_notification"] ?? false, - "unread_count": getchat["unread_count"] ?? 0, - "last_read_inbox_message_id": - getchat["last_read_inbox_message_id"] ?? 0, - "last_read_outbox_message_id": - getchat["last_read_outbox_message_id"] ?? 0, - "unread_mention_count": getchat["unread_mention_count"] ?? 0, - "is_contact": get_user["is_contact"], - "is_mutual_contact": get_user["is_mutual_contact"], - "is_verified": get_user["is_verified"], - "is_support": get_user["is_support"], - "is_scam": get_user["is_scam"], - "is_fake": get_user["is_fake"], - "have_acces": get_user["have_access"] - }; + json["detail"] = {"has_protected_content": getchat["has_protected_content"] ?? false, "is_marked_as_unread": getchat["is_marked_as_unread"] ?? false, "is_blocked": getchat["is_blocked"] ?? false, "has_scheduled_messages": getchat["has_scheduled_messages"] ?? false, "can_be_deleted_only_for_self": getchat["can_be_deleted_only_for_self"] ?? false, "can_be_deleted_for_all_users": getchat["can_be_deleted_for_all_users"] ?? false, "can_be_reported": getchat["can_be_reported"] ?? false, "default_disable_notification": getchat["default_disable_notification"] ?? false, "unread_count": getchat["unread_count"] ?? 0, "last_read_inbox_message_id": getchat["last_read_inbox_message_id"] ?? 0, "last_read_outbox_message_id": getchat["last_read_outbox_message_id"] ?? 0, "unread_mention_count": getchat["unread_mention_count"] ?? 0, "is_contact": get_user["is_contact"], "is_mutual_contact": get_user["is_mutual_contact"], "is_verified": get_user["is_verified"], "is_support": get_user["is_support"], "is_scam": get_user["is_scam"], "is_fake": get_user["is_fake"], "have_acces": get_user["have_access"]}; if (is_detail) { if (getchat["last_message"] is Map) { try { @@ -2118,27 +1908,17 @@ class Tdlib extends TdlibNative { ); } catch (e) {} if (getUserFullInfo["photo"] is Map) { - json["profile_photo"] = { - "id": getUserFullInfo["photo"]["id"], - "path": "", - "file_id": "" - }; + json["profile_photo"] = {"id": getUserFullInfo["photo"]["id"], "path": "", "file_id": ""}; if (getUserFullInfo["photo"]["@type"] == "chatPhoto") { if (getUserFullInfo["photo"]["sizes"] is List) { try { - var getPhoto = getUserFullInfo["photo"]["sizes"] - [getUserFullInfo["photo"]["sizes"].length - 1]; - var getPathPhoto = - getPhoto["photo"]["local"]["path"] as String; + var getPhoto = getUserFullInfo["photo"]["sizes"][getUserFullInfo["photo"]["sizes"].length - 1]; + var getPathPhoto = getPhoto["photo"]["local"]["path"] as String; json["profile_photo"]["path"] = getPathPhoto; - (json["profile_photo"] as Map) - .addAll(getPhoto["photo"]["local"]); - json["profile_photo"]["id"] = - getPhoto["photo"]["local"]["id"]; - json["profile_photo"]["file_id"] = - getPhoto["photo"]["remote"]["id"]; - json["profile_photo"]["file_unique_id"] = - getPhoto["photo"]["remote"]["unique_id"]; + (json["profile_photo"] as Map).addAll(getPhoto["photo"]["local"]); + json["profile_photo"]["id"] = getPhoto["photo"]["local"]["id"]; + json["profile_photo"]["file_id"] = getPhoto["photo"]["remote"]["id"]; + json["profile_photo"]["file_unique_id"] = getPhoto["photo"]["remote"]["unique_id"]; } catch (e) {} } } @@ -2164,12 +1944,9 @@ class Tdlib extends TdlibNative { }); } catch (e) {} - if (json["profile_photo"] is Map && - RegExp(r"^([0-9]+)$", caseSensitive: false) - .hashData(json["profile_photo"]["id"])) { + if (json["profile_photo"] is Map && RegExp(r"^([0-9]+)$", caseSensitive: false).hashData(json["profile_photo"]["id"])) { try { - json["profile_photo"]["id"] = - (int.parse(json["profile_photo"]["id"])); + json["profile_photo"]["id"] = (int.parse(json["profile_photo"]["id"])); } catch (e) {} } } catch (e) { @@ -2181,8 +1958,7 @@ class Tdlib extends TdlibNative { } } } catch (e) { - if (RegExp("^[0-9]+\$", caseSensitive: false) - .hashData(chat_id.toString())) { + if (RegExp("^[0-9]+\$", caseSensitive: false).hashData(chat_id.toString())) { try { return await getUser( chat_id, @@ -2274,12 +2050,10 @@ class Tdlib extends TdlibNative { chat_json["type"] = "channel"; chat_json["title"] = ""; } else { - if (RegExp("^-100", caseSensitive: false) - .hashData(update["chat_id"])) { + if (RegExp("^-100", caseSensitive: false).hashData(update["chat_id"])) { chat_json["type"] = "supergroup"; chat_json["title"] = ""; - } else if (RegExp("^-", caseSensitive: false) - .hashData(update["chat_id"])) { + } else if (RegExp("^-", caseSensitive: false).hashData(update["chat_id"])) { chat_json["type"] = "group"; chat_json["title"] = ""; } else { @@ -2327,20 +2101,12 @@ class Tdlib extends TdlibNative { json["is_outgoing"] = update["is_outgoing"] ?? false; json["is_pinned"] = update["is_pinned"] ?? false; if (update["sender_id"] is Map) { - Map from_json = { - "id": 0, - "first_name": "", - "title": "", - "type": "", - "detail": {}, - "last_message": {} - }; + Map from_json = {"id": 0, "first_name": "", "title": "", "type": "", "detail": {}, "last_message": {}}; if (update["sender_id"]["user_id"] != null) { from_json["id"] = update["sender_id"]["user_id"]; if (update["chat_id"] == from_json["id"]) { from_json["type"] = chat_json["type"]; - } else if (RegExp("^-", caseSensitive: false) - .hashData(from_json["chat_id"])) { + } else if (RegExp("^-", caseSensitive: false).hashData(from_json["chat_id"])) { from_json["type"] = "group"; } else { from_json["type"] = "private"; @@ -2378,8 +2144,7 @@ class Tdlib extends TdlibNative { from_json["id"] = update["sender_id"]["chat_id"]; if (update["chat_id"] == from_json["id"]) { from_json["type"] = chat_json["type"]; - } else if (RegExp("^-", caseSensitive: false) - .hashData(from_json["chat_id"])) { + } else if (RegExp("^-", caseSensitive: false).hashData(from_json["chat_id"])) { from_json["type"] = "group"; } else { from_json["type"] = "private"; @@ -2445,16 +2210,8 @@ class Tdlib extends TdlibNative { if (update["forward_info"] is Map) { var forward_info = update["forward_info"]; if (forward_info["origin"] is Map) { - if (forward_info["origin"]["@type"] == - "messageForwardOriginChannel") { - Map forward_json = { - "id": forward_info["origin"]["chat_id"], - "first_name": "", - "title": "", - "type": "", - "detail": {}, - "last_message": {} - }; + if (forward_info["origin"]["@type"] == "messageForwardOriginChannel") { + Map forward_json = {"id": forward_info["origin"]["chat_id"], "first_name": "", "title": "", "type": "", "detail": {}, "last_message": {}}; try { var getchat_forward = await getChat( forward_json["id"], @@ -2468,22 +2225,12 @@ class Tdlib extends TdlibNative { } } catch (e) {} json["forward_from_chat"] = forward_json; - json["forward_from_message_id"] = - forward_info["origin"]["message_id"] ?? 0; - json["api_forward_from_message_id"] = - TgUtils.messageTdlibToApi(json["forward_from_message_id"]); - json["forward_from_author_signature"] = - forward_info["origin"]["author_signature"] ?? ""; + json["forward_from_message_id"] = forward_info["origin"]["message_id"] ?? 0; + json["api_forward_from_message_id"] = TgUtils.messageTdlibToApi(json["forward_from_message_id"]); + json["forward_from_author_signature"] = forward_info["origin"]["author_signature"] ?? ""; } if (forward_info["origin"]["@type"] == "messageForwardOriginUser") { - Map forward_json = { - "id": forward_info["origin"]["sender_user_id"], - "first_name": "", - "title": "", - "type": "", - "detail": {}, - "last_message": {} - }; + Map forward_json = {"id": forward_info["origin"]["sender_user_id"], "first_name": "", "title": "", "type": "", "detail": {}, "last_message": {}}; try { var getuser_forward = await getUser( forward_json["id"], @@ -2519,9 +2266,7 @@ class Tdlib extends TdlibNative { } } } - if (update["reply_to_message_id"] != 0 && - update["reply_in_chat_id"] != 0 && - !is_skip_reply_message) { + if (update["reply_to_message_id"] != 0 && update["reply_in_chat_id"] != 0 && !is_skip_reply_message) { try { var get_message = await getMessage( update["reply_in_chat_id"], @@ -2536,11 +2281,8 @@ class Tdlib extends TdlibNative { ); if (get_message["ok"] == true) { json["reply_to_message"] = get_message["result"]; - json["reply_to_message"]["message_id"] = - json["reply_to_message"]["message_id"]; - json["reply_to_message"]["api_message_id"] = - TgUtils.messageTdlibToApi( - json["reply_to_message"]["message_id"]); + json["reply_to_message"]["message_id"] = json["reply_to_message"]["message_id"]; + json["reply_to_message"]["api_message_id"] = TgUtils.messageTdlibToApi(json["reply_to_message"]["message_id"]); } } catch (e) {} } @@ -2575,8 +2317,7 @@ class Tdlib extends TdlibNative { json_photo["file_id"] = photo_json["photo"]["remote"]["id"]; } if (photo_json["photo"]["remote"]["unique_id"] != null) { - json_photo["file_unique_id"] = - photo_json["photo"]["remote"]["unique_id"]; + json_photo["file_unique_id"] = photo_json["photo"]["remote"]["unique_id"]; } json_photo["file_size"] = photo_json["photo"]["size"]; json_photo["width"] = photo_json["width"]; @@ -2599,18 +2340,12 @@ class Tdlib extends TdlibNative { json_video["file_name"] = content_video["file_name"]; json_video["mime_type"] = content_video["mime_type"]; try { - if (update["content"]["video"]["thumbnail"] != null && - update["content"]["video"]["thumbnail"]["@type"] - .toString() - .toLowerCase() == - "thumbnail") { + if (update["content"]["video"]["thumbnail"] != null && update["content"]["video"]["thumbnail"]["@type"].toString().toLowerCase() == "thumbnail") { var content_thumb = content_video["thumbnail"]; var json_thumb = {}; json_video["thumb"] = json_thumb; - json_thumb["file_id"] = - content_thumb["file"]["remote"]["id"]; - json_thumb["file_unique_id"] = - content_thumb["file"]["remote"]["unique_id"]; + json_thumb["file_id"] = content_thumb["file"]["remote"]["id"]; + json_thumb["file_unique_id"] = content_thumb["file"]["remote"]["unique_id"]; json_thumb["file_size"] = content_thumb["file"]["size"]; json_thumb["width"] = content_thumb["width"]; json_thumb["height"] = content_thumb["height"]; @@ -2635,12 +2370,9 @@ class Tdlib extends TdlibNative { json_content["performer"] = content_update["performer"]; json_content["file_name"] = content_update["file_name"]; json_content["mime_type"] = content_update["mime_type"]; - json_content["file_id"] = - content_update[type_content]["remote"]["id"]; - json_content["unique_id"] = - content_update[type_content]["remote"]["unique_id"]; - json_content["file_size"] = - content_update[type_content]["size"]; + json_content["file_id"] = content_update[type_content]["remote"]["id"]; + json_content["unique_id"] = content_update[type_content]["remote"]["unique_id"]; + json_content["file_size"] = content_update[type_content]["size"]; json[type_content] = json_content; } } @@ -2662,29 +2394,20 @@ class Tdlib extends TdlibNative { json_content["has_stickers"] = content_update["has_stickers"]; try { - if (update["content"][type_content]["thumbnail"] != null && - update["content"][type_content]["thumbnail"]["@type"] - .toString() - .toLowerCase() == - "thumbnail") { + if (update["content"][type_content]["thumbnail"] != null && update["content"][type_content]["thumbnail"]["@type"].toString().toLowerCase() == "thumbnail") { var content_thumb = content_update["thumbnail"]; var json_thumb = {}; - json_thumb["file_id"] = - content_thumb["file"]["remote"]["id"]; - json_thumb["file_unique_id"] = - content_thumb["file"]["remote"]["unique_id"]; + json_thumb["file_id"] = content_thumb["file"]["remote"]["id"]; + json_thumb["file_unique_id"] = content_thumb["file"]["remote"]["unique_id"]; json_thumb["file_size"] = content_thumb["file"]["size"]; json_thumb["width"] = content_thumb["width"]; json_thumb["height"] = content_thumb["height"]; json_content["thumb"] = json_thumb; } } catch (e) {} - json_content["file_id"] = - content_update[type_content]["remote"]["id"]; - json_content["unique_id"] = - content_update[type_content]["remote"]["unique_id"]; - json_content["file_size"] = - content_update[type_content]["size"]; + json_content["file_id"] = content_update[type_content]["remote"]["id"]; + json_content["unique_id"] = content_update[type_content]["remote"]["unique_id"]; + json_content["file_size"] = content_update[type_content]["size"]; json[type_content] = json_content; } } @@ -2717,10 +2440,8 @@ class Tdlib extends TdlibNative { json_content["id"] = content_update["id"]; json_content["question"] = content_update["question"]; json_content["options"] = content_update["options"]; - json_content["total_voter_count"] = - content_update["total_voter_count"]; - json_content["recent_voter_user_ids"] = - content_update["recent_voter_user_ids"]; + json_content["total_voter_count"] = content_update["total_voter_count"]; + json_content["recent_voter_user_ids"] = content_update["recent_voter_user_ids"]; json_content["is_anonymous"] = content_update["is_anonymous"]; json_content["type"] = content_update["type"]; json_content["open_period"] = content_update["open_period"]; @@ -2741,12 +2462,9 @@ class Tdlib extends TdlibNative { json_content["file_name"] = content_update["file_name"]; json_content["mime_type"] = content_update["mime_type"]; - json_content["file_id"] = - content_update[type_content]["remote"]["id"]; - json_content["unique_id"] = - content_update[type_content]["remote"]["unique_id"]; - json_content["file_size"] = - content_update[type_content]["size"]; + json_content["file_id"] = content_update[type_content]["remote"]["id"]; + json_content["unique_id"] = content_update[type_content]["remote"]["unique_id"]; + json_content["file_size"] = content_update[type_content]["size"]; json[type_content] = json_content; } } @@ -2767,17 +2485,11 @@ class Tdlib extends TdlibNative { json_content["is_mask"] = content_update["is_mask"]; try { - if (update["content"][type_content]["thumbnail"] != null && - update["content"][type_content]["thumbnail"]["@type"] - .toString() - .toLowerCase() == - "thumbnail") { + if (update["content"][type_content]["thumbnail"] != null && update["content"][type_content]["thumbnail"]["@type"].toString().toLowerCase() == "thumbnail") { var content_thumb = content_update["thumbnail"]; var json_thumb = {}; - json_thumb["file_id"] = - content_thumb["file"]["remote"]["id"]; - json_thumb["file_unique_id"] = - content_thumb["file"]["remote"]["unique_id"]; + json_thumb["file_id"] = content_thumb["file"]["remote"]["id"]; + json_thumb["file_unique_id"] = content_thumb["file"]["remote"]["unique_id"]; json_thumb["file_size"] = content_thumb["file"]["size"]; json_thumb["width"] = content_thumb["width"]; json_thumb["height"] = content_thumb["height"]; @@ -2785,12 +2497,9 @@ class Tdlib extends TdlibNative { } } catch (e) {} - json_content["file_id"] = - content_update[type_content]["remote"]["id"]; - json_content["unique_id"] = - content_update[type_content]["remote"]["unique_id"]; - json_content["file_size"] = - content_update[type_content]["size"]; + json_content["file_id"] = content_update[type_content]["remote"]["id"]; + json_content["unique_id"] = content_update[type_content]["remote"]["unique_id"]; + json_content["file_size"] = content_update[type_content]["size"]; json[type_content] = json_content; } } @@ -2808,10 +2517,8 @@ class Tdlib extends TdlibNative { json_content["waveform"] = content_update["waveform"]; json_content["mime_type"] = content_update["mime_type"]; - json_content["file_id"] = - content_update["voice"]["remote"]["id"]; - json_content["unique_id"] = - content_update["voice"]["remote"]["unique_id"]; + json_content["file_id"] = content_update["voice"]["remote"]["id"]; + json_content["unique_id"] = content_update["voice"]["remote"]["unique_id"]; json_content["file_size"] = content_update["voice"]["size"]; json["voice"] = json_content; } @@ -2829,9 +2536,7 @@ class Tdlib extends TdlibNative { json["type_content"] = "new_member"; List new_members = []; if (is_super_detail) { - for (var i = 0; - i < update["content"]["member_user_ids"].length; - i++) { + for (var i = 0; i < update["content"]["member_user_ids"].length; i++) { var loop_data = update["content"]["member_user_ids"][i]; try { Map result_user = await getUser( @@ -2845,13 +2550,7 @@ class Tdlib extends TdlibNative { } catch (e) {} new_members.add(result_user["result"]); } catch (e) { - new_members.add({ - "id": loop_data, - "is_bot": false, - "first_name": "", - "last_name": "", - "type": "private" - }); + new_members.add({"id": loop_data, "is_bot": false, "first_name": "", "last_name": "", "type": "private"}); } } } else { @@ -2876,22 +2575,10 @@ class Tdlib extends TdlibNative { } catch (e) {} left_member.add(result_user["result"]); } catch (e) { - left_member.add({ - "id": update["content"]["user_id"], - "is_bot": false, - "first_name": "", - "last_name": "", - "type": "private" - }); + left_member.add({"id": update["content"]["user_id"], "is_bot": false, "first_name": "", "last_name": "", "type": "private"}); } } else { - left_member.add({ - "id": update["content"]["user_id"], - "is_bot": false, - "first_name": "", - "last_name": "", - "type": "private" - }); + left_member.add({"id": update["content"]["user_id"], "is_bot": false, "first_name": "", "last_name": "", "type": "private"}); } json["left_member"] = left_member; } @@ -2914,23 +2601,12 @@ class Tdlib extends TdlibNative { json_entities["offset"] = data_entities["offset"]; json_entities["length"] = data_entities["length"]; if (data_entities["type"]["@type"] != null) { - var type_entities = data_entities["type"]["@type"] - .toString() - .toLowerCase() - .replaceAll( - RegExp("textEntityType", caseSensitive: false), "") - .replaceAll( - RegExp("textUrl", caseSensitive: false), "text_link") - .replaceAll(RegExp("bot_command", caseSensitive: false), - "bot_command") - .replaceAll(RegExp("mentionname", caseSensitive: false), - "text_mention"); + var type_entities = data_entities["type"]["@type"].toString().toLowerCase().replaceAll(RegExp("textEntityType", caseSensitive: false), "").replaceAll(RegExp("textUrl", caseSensitive: false), "text_link").replaceAll(RegExp("bot_command", caseSensitive: false), "bot_command").replaceAll(RegExp("mentionname", caseSensitive: false), "text_mention"); json_entities["type"] = type_entities; if (data_entities["type"]["url"] != null) { json_entities["url"] = data_entities["type"]["url"]; } - if (type_entities == "text_mention" && - data_entities["type"]["user_id"] != null) { + if (type_entities == "text_mention" && data_entities["type"]["user_id"] != null) { var entitiesUserId = data_entities["type"]["user_id"]; var fromJson = {"id": entitiesUserId}; try { @@ -2958,23 +2634,17 @@ class Tdlib extends TdlibNative { Map update_reply_markup = update["reply_markup"]; json["reply_markup"] = {}; if (update_reply_markup["resize_keyboard"] is bool) { - json["reply_markup"]["resize_keyboard"] = - (update_reply_markup["resize_keyboard"] == true); + json["reply_markup"]["resize_keyboard"] = (update_reply_markup["resize_keyboard"] == true); } if (update_reply_markup["one_time"] is bool) { - json["reply_markup"]["one_time"] = - (update_reply_markup["one_time"] == true); + json["reply_markup"]["one_time"] = (update_reply_markup["one_time"] == true); } if (update_reply_markup["is_personal"] is bool) { - json["reply_markup"]["is_personal"] = - (update_reply_markup["is_personal"] == true); + json["reply_markup"]["is_personal"] = (update_reply_markup["is_personal"] == true); } if (update_reply_markup["input_field_placeholder"] is String) { - json["reply_markup"]["input_field_placeholder"] = - (update_reply_markup["input_field_placeholder"] is String) - ? (update_reply_markup["input_field_placeholder"] as String) - : ""; + json["reply_markup"]["input_field_placeholder"] = (update_reply_markup["input_field_placeholder"] is String) ? (update_reply_markup["input_field_placeholder"] as String) : ""; } try { if (update_reply_markup["@type"] == "replyMarkupShowKeyboard") { @@ -2994,17 +2664,14 @@ class Tdlib extends TdlibNative { }; if (raw_keyboard_data["type"] is Map) { // https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_inline_keyboard_button_type.html - if (raw_keyboard_data["@type"] == - "keyboardButtonTypeRequestPoll") { + if (raw_keyboard_data["@type"] == "keyboardButtonTypeRequestPoll") { jsonDataKeyboard["is_request_poll"] = true; } - if (raw_keyboard_data["@type"] == - "keyboardButtonTypeRequestLocation") { + if (raw_keyboard_data["@type"] == "keyboardButtonTypeRequestLocation") { jsonDataKeyboard["is_request_location"] = true; } // - if (raw_keyboard_data["@type"] == - "keyboardButtonTypeRequestPhoneNumber") { + if (raw_keyboard_data["@type"] == "keyboardButtonTypeRequestPhoneNumber") { jsonDataKeyboard["is_request_phone_number"] = true; } } @@ -3033,20 +2700,15 @@ class Tdlib extends TdlibNative { }; if (raw_keyboard_data["type"] is Map) { // https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1_inline_keyboard_button_type.html - if (raw_keyboard_data["@type"] == - "inlineKeyboardButtonTypeCallback") { + if (raw_keyboard_data["@type"] == "inlineKeyboardButtonTypeCallback") { if (raw_keyboard_data["type"]["data"] is String) { - jsonDataKeyboard["callback_data"] = convert.utf8 - .decode(convert.base64 - .decode(raw_keyboard_data["type"]["data"])); + jsonDataKeyboard["callback_data"] = convert.utf8.decode(convert.base64.decode(raw_keyboard_data["type"]["data"])); } } // - if (raw_keyboard_data["@type"] == - "inlineKeyboardButtonTypeUrl") { + if (raw_keyboard_data["@type"] == "inlineKeyboardButtonTypeUrl") { if (raw_keyboard_data["type"]["url"] is String) { - jsonDataKeyboard["url"] = - raw_keyboard_data["type"]["url"]; + jsonDataKeyboard["url"] = raw_keyboard_data["type"]["url"]; } } } @@ -3147,14 +2809,12 @@ class Tdlib extends TdlibNative { } } } catch (e) {} - json["api_message_id"] = - TgUtils.messageTdlibToApi(update["message_id"]); + json["api_message_id"] = TgUtils.messageTdlibToApi(update["message_id"]); json["message_id"] = update["message_id"]; json["from"] = from; json["chat"] = chat; json["chat_instance"] = update["chat_instance"]; - json["data"] = convert.utf8 - .decode(convert.base64.decode(update["payload"]["data"])); + json["data"] = convert.utf8.decode(convert.base64.decode(update["payload"]["data"])); // json["data"] = Buffer.from(update["payload"]["data"], 'base64').toStringEncode('utf8'); return { "ok": true, @@ -3196,11 +2856,8 @@ class Tdlib extends TdlibNative { json["date"] = update["date"]; if (update["old_chat_member"]["@type"] == "chatMember") { Map json_new_member = {}; - if (update["old_chat_member"]["member_id"]["@type"] == - "messageSenderUser") { - Map json_data_user = { - "id": update["old_chat_member"]["member_id"]["user_id"] - }; + if (update["old_chat_member"]["member_id"]["@type"] == "messageSenderUser") { + Map json_data_user = {"id": update["old_chat_member"]["member_id"]["user_id"]}; if (is_super_detail) { try { var fromResult = await getUser( @@ -3217,21 +2874,14 @@ class Tdlib extends TdlibNative { json_new_member["user"] = json_data_user; } - json_new_member["status"] = update["old_chat_member"]["status"] - ["@type"] - .toString() - .replaceAll(RegExp(r"chatMemberStatus", caseSensitive: false), "") - .toLowerCase(); + json_new_member["status"] = update["old_chat_member"]["status"]["@type"].toString().replaceAll(RegExp(r"chatMemberStatus", caseSensitive: false), "").toLowerCase(); json["old_member"] = json_new_member; } if (update["new_chat_member"]["@type"] == "chatMember") { Map json_new_member = {}; - if (update["new_chat_member"]["member_id"]["@type"] == - "messageSenderUser") { - Map json_data_user = { - "id": update["new_chat_member"]["member_id"]["user_id"] - }; + if (update["new_chat_member"]["member_id"]["@type"] == "messageSenderUser") { + Map json_data_user = {"id": update["new_chat_member"]["member_id"]["user_id"]}; if (is_super_detail) { try { var fromResult = await getUser( @@ -3248,11 +2898,7 @@ class Tdlib extends TdlibNative { json_new_member["user"] = json_data_user; } - json_new_member["status"] = update["new_chat_member"]["status"] - ["@type"] - .toString() - .replaceAll(RegExp(r"chatMemberStatus", caseSensitive: false), "") - .toLowerCase(); + json_new_member["status"] = update["new_chat_member"]["status"]["@type"].toString().replaceAll(RegExp(r"chatMemberStatus", caseSensitive: false), "").toLowerCase(); json["new_member"] = json_new_member; } @@ -3278,13 +2924,9 @@ class Tdlib extends TdlibNative { } } catch (e) {} json["from"] = from; - json["chat_type"] = update["chat_type"]["@type"] - .toString() - .replaceAll(RegExp("chatType", caseSensitive: false), "") - .toLowerCase(); + json["chat_type"] = update["chat_type"]["@type"].toString().replaceAll(RegExp("chatType", caseSensitive: false), "").toLowerCase(); try { - if (json["chat_type"] == "supergroup" && - update["chat_type"]["is_channel"]) { + if (json["chat_type"] == "supergroup" && update["chat_type"]["is_channel"]) { json["chat_type"] = "channel"; } } catch (e) {} @@ -3333,8 +2975,7 @@ class Tdlib extends TdlibNative { var json = {}; json["id"] = get_user["id"]; try { - if (RegExp(r"^userTypeBot$", caseSensitive: false) - .hashData(get_user["type"]["@type"])) { + if (RegExp(r"^userTypeBot$", caseSensitive: false).hashData(get_user["type"]["@type"])) { json["is_bot"] = true; } else { json["is_bot"] = false; @@ -3355,8 +2996,7 @@ class Tdlib extends TdlibNative { json["usernames"] = get_user["usernames"]; if (get_user_usernames["active_usernames"] is List) { if ((get_user_usernames["active_usernames"] as List).isNotEmpty) { - json["username"] = - (get_user_usernames["active_usernames"] as List).first; + json["username"] = (get_user_usernames["active_usernames"] as List).first; } } } @@ -3367,27 +3007,7 @@ class Tdlib extends TdlibNative { json["language_code"] = get_user["language_code"]; } json["type"] = "private"; - json["detail"] = { - "has_protected_content": false, - "is_marked_as_unread": false, - "is_blocked": false, - "has_scheduled_messages": false, - "can_be_deleted_only_for_self": false, - "can_be_deleted_for_all_users": false, - "can_be_reported": false, - "default_disable_notification": false, - "unread_count": 0, - "last_read_inbox_message_id": 0, - "last_read_outbox_message_id": 0, - "unread_mention_count": 0, - "is_contact": get_user["is_contact"], - "is_mutual_contact": get_user["is_mutual_contact"], - "is_verified": get_user["is_verified"], - "is_support": get_user["is_support"], - "is_scam": get_user["is_scam"], - "is_fake": get_user["is_fake"], - "have_acces": get_user["have_access"] - }; + json["detail"] = {"has_protected_content": false, "is_marked_as_unread": false, "is_blocked": false, "has_scheduled_messages": false, "can_be_deleted_only_for_self": false, "can_be_deleted_for_all_users": false, "can_be_reported": false, "default_disable_notification": false, "unread_count": 0, "last_read_inbox_message_id": 0, "last_read_outbox_message_id": 0, "unread_mention_count": 0, "is_contact": get_user["is_contact"], "is_mutual_contact": get_user["is_mutual_contact"], "is_verified": get_user["is_verified"], "is_support": get_user["is_support"], "is_scam": get_user["is_scam"], "is_fake": get_user["is_fake"], "have_acces": get_user["have_access"]}; return {"ok": true, "result": json}; } get_user["ok"] = false; diff --git a/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_io.dart b/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_io.dart index a5ee99e5..4b58d373 100644 --- a/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_io.dart +++ b/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_io.dart @@ -59,10 +59,8 @@ typedef TdStringNative = Pointer; typedef TdReceiveNative = TdStringNative Function(Double timout); typedef TdReceiveDart = TdStringNative Function(double timout); -typedef TdSendNative = Void Function( - TdPointerNative client, TdStringNative request); -typedef TdSendDart = void Function( - TdPointerNative client, TdStringNative request); +typedef TdSendNative = Void Function(TdPointerNative client, TdStringNative request); +typedef TdSendDart = void Function(TdPointerNative client, TdStringNative request); typedef TdExecuteNative = TdStringNative Function(TdStringNative parameters); @@ -89,8 +87,7 @@ class TdlibNative { final ReceivePort receivePort = ReceivePort(); final TdlibOptionParameter client_option = TdlibOptionParameter.create( api_id: num.tryParse("OTQ1NzU=".general_lib_utils_decryptFromBase64()), - api_hash: 'YTM0MDZkZThkMTcxYmI0MjJiYjZkZGYzYmJkODAwZTI=' - .general_lib_utils_decryptFromBase64(), + api_hash: 'YTM0MDZkZThkMTcxYmI0MjJiYjZkZGYzYmJkODAwZTI='.general_lib_utils_decryptFromBase64(), database_directory: "tg_db", files_directory: "tg_file", use_file_database: true, @@ -101,8 +98,7 @@ class TdlibNative { system_language_code: 'en', new_verbosity_level: 0, application_version: 'v1', - device_model: 'VGVsZWdyYW0gQ2xpZW50IEFaS0FERVYgR0xPQkFMIENPUlBPUkFUSU9O' - .general_lib_utils_decryptFromBase64(), + device_model: 'VGVsZWdyYW0gQ2xpZW50IEFaS0FERVYgR0xPQkFMIENPUlBPUkFUSU9O'.general_lib_utils_decryptFromBase64(), system_version: Platform.operatingSystemVersion, database_key: "", start: true, @@ -129,12 +125,9 @@ class TdlibNative { Duration invoke_time_out = Duration(minutes: 10); double timeOutUpdate; bool is_invoke_throw_on_error = false; - FutureOr Function(dynamic update, TdlibNative libTdJson)? - on_receive_update; - FutureOr Function(int client_id, TdlibNative libTdJson)? - on_generate_extra_invoke; - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - on_get_invoke_data; + FutureOr Function(dynamic update, TdlibNative libTdJson)? on_receive_update; + FutureOr Function(int client_id, TdlibNative libTdJson)? on_generate_extra_invoke; + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? on_get_invoke_data; static bool is_debug = false; int task_max_count; @@ -253,11 +246,8 @@ class TdlibNative { /// create client id for multi client int td_create_client_id() { int client_id_new = using((Arena arena) { - TdPointerFunctionNative td_pointer_native_function = tdLib.lookupFunction< - TdPointerFunctionNative, - TdPointerFunctionNative>('td_create_client_id', isLeaf: false); - Pointer td_pointer_native_result = - arena.using(td_pointer_native_function(), (p0) {}); + TdPointerFunctionNative td_pointer_native_function = tdLib.lookupFunction('td_create_client_id', isLeaf: false); + Pointer td_pointer_native_result = arena.using(td_pointer_native_function(), (p0) {}); int client_id_new = td_pointer_native_result.address; arena.releaseAll(); return client_id_new; @@ -268,11 +258,8 @@ class TdlibNative { /// create client id for multi client int td_json_client_create() { int client_id_new = using((Arena arena) { - TdPointerFunctionNative td_pointer_native_function = tdLib.lookupFunction< - TdPointerFunctionNative, - TdPointerFunctionNative>('td_json_client_create', isLeaf: false); - TdPointerNative td_pointer_native_result = - arena.using(td_pointer_native_function(), (p0) {}); + TdPointerFunctionNative td_pointer_native_function = tdLib.lookupFunction('td_json_client_create', isLeaf: false); + TdPointerNative td_pointer_native_result = arena.using(td_pointer_native_function(), (p0) {}); int client_id_new = td_pointer_native_result.address; arena.releaseAll(); return client_id_new; @@ -289,14 +276,11 @@ class TdlibNative { void td_send(int clientId, [Map? parameters]) { using((Arena arena) { Pointer client_id_addres_data = client_id_addres(clientId); - TdStringNative request_data = - convert.json.encode(parameters).toNativeUtf8(); + TdStringNative request_data = convert.json.encode(parameters).toNativeUtf8(); Arena arena = Arena(); - TdSendDart td_send_function = tdLib - .lookupFunction('td_send', isLeaf: false); + TdSendDart td_send_function = tdLib.lookupFunction('td_send', isLeaf: false); // void td_send_result = - arena.using( - td_send_function(client_id_addres_data, request_data), (p0) {}); + arena.using(td_send_function(client_id_addres_data, request_data), (p0) {}); arena.releaseAll(); malloc.free(request_data); }); @@ -307,16 +291,12 @@ class TdlibNative { void td_json_client_send(int clientId, [Map? parameters]) { using((Arena arena) { Pointer client_id_addres_data = client_id_addres(clientId); - TdStringNative request_data = - convert.json.encode(parameters).toNativeUtf8(); + TdStringNative request_data = convert.json.encode(parameters).toNativeUtf8(); Arena arena = Arena(); - TdSendDart td_send_function = - tdLib.lookupFunction('td_json_client_send', - isLeaf: false); + TdSendDart td_send_function = tdLib.lookupFunction('td_json_client_send', isLeaf: false); // void td_send_result = - arena.using( - td_send_function(client_id_addres_data, request_data), (p0) {}); + arena.using(td_send_function(client_id_addres_data, request_data), (p0) {}); arena.releaseAll(); malloc.free(request_data); }); @@ -327,17 +307,12 @@ class TdlibNative { /// client_execute Map td_execute(Map parameters) { Map result_data = using((Arena arena) { - TdStringNative request_data = - convert.json.encode(parameters).toNativeUtf8(); + TdStringNative request_data = convert.json.encode(parameters).toNativeUtf8(); - TdExecuteNative td_execute_native_function = - tdLib.lookupFunction('td_execute', - isLeaf: false); + TdExecuteNative td_execute_native_function = tdLib.lookupFunction('td_execute', isLeaf: false); - TdStringNative td_execute_native_result = - arena.using(td_execute_native_function(request_data), (p0) {}); - Map result_data = - convert.json.decode(td_execute_native_result.toDartString()); + TdStringNative td_execute_native_result = arena.using(td_execute_native_function(request_data), (p0) {}); + Map result_data = convert.json.decode(td_execute_native_result.toDartString()); arena.releaseAll(); malloc.free(request_data); @@ -350,10 +325,7 @@ class TdlibNative { void td_json_client_destroy(int clientId) { using((Arena arena) { Pointer client_id_addres_data = client_id_addres(clientId); - TdDestroyDart td_destroy_dart_function = - tdLib.lookupFunction( - 'td_json_client_destroy', - isLeaf: false); + TdDestroyDart td_destroy_dart_function = tdLib.lookupFunction('td_json_client_destroy', isLeaf: false); arena.using(td_destroy_dart_function(client_id_addres_data), (p0) {}); arena.releaseAll(); }); @@ -367,11 +339,8 @@ class TdlibNative { }) { try { Map? result = using((Arena arena) { - TdReceiveDart td_receive_function = - tdLib.lookupFunction('td_receive', - isLeaf: false); - TdStringNative update = - arena.using(td_receive_function(timeout), (p0) {}); + TdReceiveDart td_receive_function = tdLib.lookupFunction('td_receive', isLeaf: false); + TdStringNative update = arena.using(td_receive_function(timeout), (p0) {}); if (update.address != 0) { String update_string = update.toDartString(); arena.releaseAll(); @@ -433,15 +402,37 @@ class TdlibNative { TdlibOptionParameter? clientOption, bool isBot = false, bool isVoid = false, + bool isAutoSetOptionIfEmpty = true, }) async { final Map client_new_option = client_option.rawData.clone(); if (clientOption != null) { clientOption.rawData.remove("@type"); client_new_option.addAll(clientOption.rawData); } + if (isAutoSetOptionIfEmpty) { + final Map tdlib_option_should_not_empty = { + "system_language_code": "en", + "device_model": "Unknown", + "application_version": "v1", + }; + tdlib_option_should_not_empty.forEach((key, value) { + try { + if (client_new_option[key] is String == false) { + client_new_option[key] = value; + return; + } + final String value_default = client_new_option[key].toString().trim(); + if (value_default.isEmpty) { + client_new_option[key] = value; + } + } catch (e) { + client_new_option[key] = value; + } + }); + } clients[clientId] = TdlibClient( client_id: clientId, - client_user_id: clientUserId, + client_tg_user_id: clientUserId, is_bot: isBot, client_option: client_new_option, ); @@ -460,7 +451,7 @@ class TdlibNative { TdlibClient? getClientByUserId(int clientUserId) { List> entries = clients.entries.toList(); for (var i = 0; i < entries.length; i++) { - if (entries[i].value.client_user_id == clientUserId) { + if (entries[i].value.client_tg_user_id == clientUserId) { return entries[i].value; } } @@ -536,21 +527,17 @@ class TdlibNative { } /// receive all update data - EventEmitterListener on( - String type_update, FutureOr Function(UpdateTd update) callback, - {void Function(Object data)? onError}) { + EventEmitterListener on(String type_update, FutureOr Function(UpdateTd update) callback, {void Function(Object data)? onError}) { return event_emitter.on(type_update, null, (Event ev, context) async { try { if (ev.eventData is TdlibIsolateReceiveData) { - TdlibIsolateReceiveData tdlibIsolateReceiveData = - (ev.eventData as TdlibIsolateReceiveData); + TdlibIsolateReceiveData tdlibIsolateReceiveData = (ev.eventData as TdlibIsolateReceiveData); await callback(UpdateTd( update: tdlibIsolateReceiveData.updateData, client_id: tdlibIsolateReceiveData.clientId, client_option: () { try { - TdlibClient? tdlibClient = - clients[tdlibIsolateReceiveData.clientId]; + TdlibClient? tdlibClient = clients[tdlibIsolateReceiveData.clientId]; if (tdlibClient != null) { return tdlibClient.client_option; } @@ -591,10 +578,8 @@ class TdlibNative { String? extra, bool? isAutoGetChat, bool? isInvokeThrowOnError, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? onGetInvokeData, }) async { if (isVoid == false) { if (task_count >= task_max_count) { @@ -650,9 +635,7 @@ class TdlibNative { parameters["@extra"] = extra_id; } - if (isAutoGetChat && - RegExp(r"^(sendMessage|getChatMember)$", caseSensitive: false) - .hashData(method)) { + if (isAutoGetChat && RegExp(r"^(sendMessage|getChatMember)$", caseSensitive: false).hashData(method)) { if (parameters["chat_id"] is int) { td_send( clientId, @@ -812,10 +795,8 @@ class TdlibNative { bool? isUseCache, Duration? durationCacheExpire, bool? isAutoGetChat, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? onGetInvokeData, bool? isInvokeThrowOnError, }) async { return await invoke( diff --git a/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_none.dart b/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_none.dart index aad7339e..bf18edb0 100644 --- a/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_none.dart +++ b/package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_none.dart @@ -103,12 +103,9 @@ class TdlibNative { Duration invoke_time_out = Duration(minutes: 10); double timeOutUpdate; bool is_invoke_throw_on_error = false; - FutureOr Function(dynamic update, TdlibNative libTdJson)? - on_receive_update; - FutureOr Function(int client_id, TdlibNative libTdJson)? - on_generate_extra_invoke; - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - on_get_invoke_data; + FutureOr Function(dynamic update, TdlibNative libTdJson)? on_receive_update; + FutureOr Function(int client_id, TdlibNative libTdJson)? on_generate_extra_invoke; + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? on_get_invoke_data; int task_max_count; int task_min_cooldown; TdlibNative({ @@ -258,6 +255,7 @@ class TdlibNative { TdlibOptionParameter? clientOption, bool isBot = false, bool isVoid = false, + bool isAutoSetOptionIfEmpty = true, }) async { // Map client_new_option = client_option.rawData.clone(); @@ -266,7 +264,7 @@ class TdlibNative { } TdlibClient tdlibClient = TdlibClient( client_id: clientId, - client_user_id: clientUserId, + client_tg_user_id: clientUserId, client_option: client_new_option, ); if ((is_init_isolate == false)) { @@ -292,7 +290,7 @@ class TdlibNative { TdlibClient? getClientByUserId(int clientUserId) { List> entries = clients.entries.toList(); for (var i = 0; i < entries.length; i++) { - if (entries[i].value.client_user_id == clientUserId) { + if (entries[i].value.client_tg_user_id == clientUserId) { return entries[i].value; } } @@ -369,21 +367,17 @@ class TdlibNative { } /// receive all update data - EventEmitterListener on( - String type_update, FutureOr Function(UpdateTd update) callback, - {void Function(Object data)? onError}) { + EventEmitterListener on(String type_update, FutureOr Function(UpdateTd update) callback, {void Function(Object data)? onError}) { return event_emitter.on(type_update, null, (Event ev, context) async { try { if (ev.eventData is TdlibIsolateReceiveData) { - TdlibIsolateReceiveData tdlibIsolateReceiveData = - (ev.eventData as TdlibIsolateReceiveData); + TdlibIsolateReceiveData tdlibIsolateReceiveData = (ev.eventData as TdlibIsolateReceiveData); await callback(UpdateTd( update: tdlibIsolateReceiveData.updateData, client_id: tdlibIsolateReceiveData.clientId, client_option: () { try { - TdlibClient? tdlibClient = - clients[tdlibIsolateReceiveData.clientId]; + TdlibClient? tdlibClient = clients[tdlibIsolateReceiveData.clientId]; if (tdlibClient != null) { return tdlibClient.client_option; } @@ -424,10 +418,8 @@ class TdlibNative { String? extra, bool? isAutoGetChat, bool? isInvokeThrowOnError, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? onGetInvokeData, }) async { isUseCache ??= false; isInvokeThrowOnError ??= is_invoke_throw_on_error; @@ -467,9 +459,7 @@ class TdlibNative { parameters["@extra"] = extra_id; } - if (isAutoGetChat && - RegExp(r"^(sendMessage|getChatMember)$", caseSensitive: false) - .hashData(method)) { + if (isAutoGetChat && RegExp(r"^(sendMessage|getChatMember)$", caseSensitive: false).hashData(method)) { if (parameters["chat_id"] is int) { td_send( clientId, @@ -547,10 +537,8 @@ class TdlibNative { Duration? durationCacheExpire, String? extra, bool? isAutoGetChat, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr Function(String extra, int client_id, TdlibNative libTdJson)? onGetInvokeData, bool? isInvokeThrowOnError, }) async { return await invoke( diff --git a/package/telegram_client/lib/telegram_bot_api/scheme/tg_client_client_data.dart b/package/telegram_client/lib/telegram_bot_api/scheme/tg_client_client_data.dart index a6ef7d0d..50fdc6fc 100644 --- a/package/telegram_client/lib/telegram_bot_api/scheme/tg_client_client_data.dart +++ b/package/telegram_client/lib/telegram_bot_api/scheme/tg_client_client_data.dart @@ -6,25 +6,7 @@ class TgClientClientData extends JsonScheme { TgClientClientData(super.rawData); static Map get defaultData { - return { - "@type": "tgClientClientData", - "id": 0, - "created_at": "2022-12-26T05:26:40.500935+00:00", - "client_user_id": 0, - "client_title": "", - "client_token": "", - "owner_user_id": 0, - "client_type": "", - "from_bot_type": null, - "can_join_groups": false, - "can_read_all_group_messages": false, - "from_bot_user_id": 0, - "expire_date": 0, - "client_username": "", - "version": "", - "client_id": 0, - "client_data": "{}" - }; + return {"@type": "tgClientClientData", "id": 0, "created_at": "2022-12-26T05:26:40.500935+00:00", "client_tg_user_id": 0, "client_title": "", "client_token": "", "owner_user_id": 0, "client_type": "", "from_bot_type": null, "can_join_groups": false, "can_read_all_group_messages": false, "from_bot_user_id": 0, "expire_date": 0, "client_username": "", "version": "", "client_id": 0, "client_data": "{}"}; } String? get special_type { @@ -72,19 +54,19 @@ class TgClientClientData extends JsonScheme { rawData["created_at"] = value; } - num? get client_user_id { + num? get client_tg_user_id { try { - if (rawData["client_user_id"] is num == false) { + if (rawData["client_tg_user_id"] is num == false) { return null; } - return rawData["client_user_id"] as num; + return rawData["client_tg_user_id"] as num; } catch (e) { return null; } } - set client_user_id(num? value) { - rawData["client_user_id"] = value; + set client_tg_user_id(num? value) { + rawData["client_tg_user_id"] = value; } String? get client_title { @@ -286,7 +268,7 @@ class TgClientClientData extends JsonScheme { String special_type = "tgClientClientData", num? id, String? created_at, - num? client_user_id, + num? client_tg_user_id, String? client_title, String? client_token, num? owner_user_id, @@ -306,7 +288,7 @@ class TgClientClientData extends JsonScheme { "@type": special_type, "id": id, "created_at": created_at, - "client_user_id": client_user_id, + "client_tg_user_id": client_tg_user_id, "client_title": client_title, "client_token": client_token, "owner_user_id": owner_user_id, @@ -322,10 +304,8 @@ class TgClientClientData extends JsonScheme { "client_data": client_data, }; - tgClientClientData_data_create_json - .removeWhere((key, value) => value == null); - TgClientClientData tgClientClientData_data_create = - TgClientClientData(tgClientClientData_data_create_json); + tgClientClientData_data_create_json.removeWhere((key, value) => value == null); + TgClientClientData tgClientClientData_data_create = TgClientClientData(tgClientClientData_data_create_json); return tgClientClientData_data_create; } diff --git a/package/telegram_client/lib/telegram_bot_api/telegram_bot_api_core.dart b/package/telegram_client/lib/telegram_bot_api/telegram_bot_api_core.dart index 52c8dc57..5b23f687 100644 --- a/package/telegram_client/lib/telegram_bot_api/telegram_bot_api_core.dart +++ b/package/telegram_client/lib/telegram_bot_api/telegram_bot_api_core.dart @@ -139,8 +139,7 @@ class TelegramBotApi { if (is_init_server == false) { is_init_server = true; - serverUniverseNative!.post(telegram_url_webhook.path, - (HttpRequest req, HttpResponse res) async { + serverUniverseNative!.post(telegram_url_webhook.path, (HttpRequest req, HttpResponse res) async { try { Map query = (req.uri.queryParameters).clone(); Map body = await req.bodyAsJsonMap; @@ -174,12 +173,10 @@ class TelegramBotApi { if (query["tg"] is String == false) { query["tg"] = ""; } - Map decyprt = - convert.json.decode(telegram_crypto.decrypt(data_base64: query["tg"])); + Map decyprt = convert.json.decode(telegram_crypto.decrypt(data_base64: query["tg"])); - if (decyprt["client_user_id"] == null || decyprt["client_user_id"] == 0) { - decyprt["client_user_id"] = - TgUtils.parserBotUserIdFromToken(decyprt["client_token"]); + if (decyprt["client_tg_user_id"] == null || decyprt["client_tg_user_id"] == 0) { + decyprt["client_tg_user_id"] = TgUtils.parserBotUserIdFromToken(decyprt["client_token"]); } return TgClientClientData(decyprt); } @@ -210,8 +207,7 @@ class TelegramBotApi { "expire_date": expire_date, "version": version, }; - String query_telegram_webhook = - telegram_crypto.encryptMapToBase64(data: client_data); + String query_telegram_webhook = telegram_crypto.encryptMapToBase64(data: client_data); Map result_webhook = await request( "setWebhook", parameters: { @@ -263,8 +259,7 @@ class TelegramBotApi { /// }); /// ``` /// add this for handle update api - EventEmitterListener on(String type_update, - FutureOr Function(UpdateBot updateBot) callback) { + EventEmitterListener on(String type_update, FutureOr Function(UpdateBot updateBot) callback) { return event_emitter.on(type_update, null, (Event ev, context) async { try { if (ev.eventData is UpdateBot) { @@ -367,10 +362,7 @@ class TelegramBotApi { "media", ]; - if (methodForm - .map((e) => e.toLowerCase()) - .toList() - .contains(method.toLowerCase())) { + if (methodForm.map((e) => e.toLowerCase()).toList().contains(method.toLowerCase())) { parameters.forEach((key, value) { if (parameters == null) { return; @@ -424,16 +416,13 @@ class TelegramBotApi { var files = await MultipartFile.fromPath(key, value["file_path"]); form.files.add(files); } else if (value["is_post_buffer"] == true) { - var files = MultipartFile.fromBytes( - key, (value["buffer"] as List).cast(), - filename: value["name"], contentType: value["content_type"]); + var files = MultipartFile.fromBytes(key, (value["buffer"] as List).cast(), filename: value["name"], contentType: value["content_type"]); form.files.add(files); } else { form.fields[key] = convert.json.encode(value); } } else if (value is TelegramBotApiFileData) { - var files = MultipartFile.fromBytes(key, value.buffer_data, - filename: value.name, contentType: null); + var files = MultipartFile.fromBytes(key, value.buffer_data, filename: value.name, contentType: null); form.files.add(files); } else if (value is String) { form.fields[key] = value; @@ -541,8 +530,7 @@ class TelegramBotApi { if (method.toString().toLowerCase() == "getfile") { var getFile = convert.json.decode(response.body); var url = "${urlApi}file/${clientType}${tokenBot.toString()}"; - getFile["result"]["file_url"] = - "${url}/${getFile["result"]["file_path"]}"; + getFile["result"]["file_url"] = "${url}/${getFile["result"]["file_path"]}"; return getFile; } else { return convert.json.decode(response.body); @@ -559,8 +547,7 @@ class TelegramBotApi { } catch (e) { if (RegExp(r"^(send)", caseSensitive: false).hasMatch(method)) { if (e is Map) { - if (RegExp("Unsupported start tag", caseSensitive: false) - .hasMatch(e["description"])) { + if (RegExp("Unsupported start tag", caseSensitive: false).hasMatch(e["description"])) { parameters.remove("parse_mode"); return await invoke( method, @@ -652,8 +639,7 @@ class TelegramBotApi { try { await Future.delayed(Duration(milliseconds: 500)); parameters["text"] = loopData; - if (RegExp("(editMessageText)", caseSensitive: false) - .hashData(method)) { + if (RegExp("(editMessageText)", caseSensitive: false).hashData(method)) { if (i != 0) { method = "sendMessage"; } @@ -688,8 +674,7 @@ class TelegramBotApi { try { await Future.delayed(Duration(milliseconds: 500)); parameters["caption"] = loopData; - if (RegExp("(editMessageCaption)", caseSensitive: false) - .hashData(method)) { + if (RegExp("(editMessageCaption)", caseSensitive: false).hashData(method)) { if (i != 0) { parameters["text"] = loopData; method = "sendMessage"; @@ -773,8 +758,7 @@ class TelegramBotApi { }) async { final httpClient = HttpClient(); final request = await httpClient.getUrl(Uri.parse(url)); - request.headers - .add(HttpHeaders.contentTypeHeader, "application/octet-stream"); + request.headers.add(HttpHeaders.contentTypeHeader, "application/octet-stream"); var httpResponse = await request.close(); int byteCount = 0; int totalBytes = httpResponse.contentLength; diff --git a/package/telegram_client/lib/telegram_client/telegram_client_core.dart b/package/telegram_client/lib/telegram_client/telegram_client_core.dart index a071e2ad..61075ee2 100644 --- a/package/telegram_client/lib/telegram_client/telegram_client_core.dart +++ b/package/telegram_client/lib/telegram_client/telegram_client_core.dart @@ -81,8 +81,7 @@ import 'package:telegram_client/telegram_client/function/un_pin_all_chat_message import 'package:telegram_client/telegram_client/function/un_pin_chat_message.dart'; import 'package:telegram_client/telegram_client/function/view_message.dart'; import 'package:telegram_client/telegram_client/function/view_messages.dart'; -import "package:telegram_client/telegram_client/scheme/scheme.dart" - as telegram_client_scheme; +import "package:telegram_client/telegram_client/scheme/scheme.dart" as telegram_client_scheme; import 'package:universal_io/io.dart'; /// return original data json @@ -137,11 +136,9 @@ class TelegramClient { event_update: event_update, clientOption: telegramClientTelegramBotApiOption.clientOption, eventEmitter: event_emitter, - serverUniverseNative: - telegramClientTelegramBotApiOption.serverUniverseNative, + serverUniverseNative: telegramClientTelegramBotApiOption.serverUniverseNative, telegramCryptoKey: telegramClientTelegramBotApiOption.telegramCryptoKey, - telegramUrlWebhook: - telegramClientTelegramBotApiOption.telegramUrlWebhook, + telegramUrlWebhook: telegramClientTelegramBotApiOption.telegramUrlWebhook, httpClient: telegramClientTelegramBotApiOption.httpClient, ); telegramBotApi.initServer(); @@ -158,8 +155,7 @@ class TelegramClient { delayUpdate: telegramClientTdlibOption.delayUpdate, delayInvoke: telegramClientTdlibOption.delayInvoke, isAutoGetChat: telegramClientTdlibOption.isAutoGetChat, - on_generate_extra_invoke: - telegramClientTdlibOption.on_generate_extra_invoke, + on_generate_extra_invoke: telegramClientTdlibOption.on_generate_extra_invoke, on_get_invoke_data: telegramClientTdlibOption.on_get_invoke_data, on_receive_update: telegramClientTdlibOption.on_receive_update, isInvokeThrowOnError: telegramClientTdlibOption.isInvokeThrowOnError, @@ -171,8 +167,7 @@ class TelegramClient { } Future autoSetData(UpdateTelegramClient updateTelegramClient) async { - if (updateTelegramClient.telegramClientData.telegramClientType == - TelegramClientType.tdlib) { + if (updateTelegramClient.telegramClientData.telegramClientType == TelegramClientType.tdlib) { final Map update_raw = updateTelegramClient.rawData; if (update_raw["@type"] == "updateAuthorizationState") { @@ -198,21 +193,18 @@ class TelegramClient { return ""; }(); - TdlibClient? tdlibClient = tdlib.clients[ - updateTelegramClient.telegramClientData.tdlib_client_id]; + TdlibClient? tdlibClient = tdlib.clients[updateTelegramClient.telegramClientData.tdlib_client_id]; if (tdlibClient == null) { tdlibClient ??= TdlibClient( - client_id: - updateTelegramClient.telegramClientData.tdlib_client_id, + client_id: updateTelegramClient.telegramClientData.tdlib_client_id, client_option: updateTelegramClient.client_option, ); - tdlib.clients[updateTelegramClient - .telegramClientData.tdlib_client_id] = tdlibClient; + tdlib.clients[updateTelegramClient.telegramClientData.tdlib_client_id] = tdlibClient; } bool is_constain_update = false; - tdlibClient.client_user_id = user["id"]; + tdlibClient.client_tg_user_id = user["id"]; if (user["type"] is Map) { if (user["type"]["@type"] == "userTypeBot") { @@ -222,41 +214,32 @@ class TelegramClient { updateTelegramClient.telegramClientData.is_bot = true; } } - if (updateTelegramClient.client_option["client_first_name"] != - user["first_name"]) { + if (updateTelegramClient.client_option["client_first_name"] != user["first_name"]) { is_constain_update = true; - tdlibClient.client_option["client_first_name"] = - user["first_name"]; + tdlibClient.client_option["client_first_name"] = user["first_name"]; } - if (updateTelegramClient.client_option["client_first_name"] != - user["last_name"]) { + if (updateTelegramClient.client_option["client_first_name"] != user["last_name"]) { is_constain_update = true; tdlibClient.client_option["client_last_name"] = user["last_name"]; } - if (updateTelegramClient.client_option["client_title"] != - "${user["first_name"]} ${user["last_name"]}".trim()) { + if (updateTelegramClient.client_option["client_title"] != "${user["first_name"]} ${user["last_name"]}".trim()) { is_constain_update = true; - tdlibClient.client_option["client_title"] = - "${user["first_name"]} ${user["last_name"]}".trim(); + tdlibClient.client_option["client_title"] = "${user["first_name"]} ${user["last_name"]}".trim(); } - if (tdlibClient.client_option["client_user_id"] != user["id"]) { + if (tdlibClient.client_option["client_tg_user_id"] != user["id"]) { is_constain_update = true; - tdlibClient.client_option["client_user_id"] = user["id"]; + tdlibClient.client_option["client_tg_user_id"] = user["id"]; } - if (updateTelegramClient.client_option["client_username"] != - user_usename) { + if (updateTelegramClient.client_option["client_username"] != user_usename) { is_constain_update = true; tdlibClient.client_option["client_username"] = user_usename; - updateTelegramClient.telegramClientData.client_user_name = - user_usename; + updateTelegramClient.telegramClientData.client_user_name = user_usename; } if (is_constain_update) { - await tdlib.updateClientById( - updateTelegramClient.telegramClientData.tdlib_client_id, - newTdlibClient: tdlibClient); + await tdlib.updateClientById(updateTelegramClient.telegramClientData.tdlib_client_id, newTdlibClient: tdlibClient); } } } @@ -266,8 +249,7 @@ class TelegramClient { if (update_raw["user"] is Map) { final Map user = update_raw["user"]; - if (user["id"] == - updateTelegramClient.telegramClientData.client_user_id) { + if (user["id"] == updateTelegramClient.telegramClientData.client_tg_user_id) { // int user_id = user["id"]; final String user_usename = () { if (user["usernames"] is Map) { @@ -278,18 +260,15 @@ class TelegramClient { return ""; }(); - TdlibClient? tdlibClient = tdlib.clients[ - updateTelegramClient.telegramClientData.tdlib_client_id]; + TdlibClient? tdlibClient = tdlib.clients[updateTelegramClient.telegramClientData.tdlib_client_id]; bool is_constain_update = false; if (tdlibClient == null) { tdlibClient ??= TdlibClient( - client_id: - updateTelegramClient.telegramClientData.tdlib_client_id, + client_id: updateTelegramClient.telegramClientData.tdlib_client_id, client_option: updateTelegramClient.client_option, ); - tdlib.clients[updateTelegramClient - .telegramClientData.tdlib_client_id] = tdlibClient; + tdlib.clients[updateTelegramClient.telegramClientData.tdlib_client_id] = tdlibClient; is_constain_update = true; } @@ -301,41 +280,32 @@ class TelegramClient { updateTelegramClient.telegramClientData.is_bot = true; } } - if (updateTelegramClient.client_option["client_first_name"] != - user["first_name"]) { + if (updateTelegramClient.client_option["client_first_name"] != user["first_name"]) { is_constain_update = true; - tdlibClient.client_option["client_first_name"] = - user["first_name"]; + tdlibClient.client_option["client_first_name"] = user["first_name"]; } - if (updateTelegramClient.client_option["client_first_name"] != - user["last_name"]) { + if (updateTelegramClient.client_option["client_first_name"] != user["last_name"]) { is_constain_update = true; tdlibClient.client_option["client_last_name"] = user["last_name"]; } - if (updateTelegramClient.client_option["client_title"] != - "${user["first_name"]} ${user["last_name"]}".trim()) { + if (updateTelegramClient.client_option["client_title"] != "${user["first_name"]} ${user["last_name"]}".trim()) { is_constain_update = true; - tdlibClient.client_option["client_title"] = - "${user["first_name"]} ${user["last_name"]}".trim(); + tdlibClient.client_option["client_title"] = "${user["first_name"]} ${user["last_name"]}".trim(); } - if (tdlibClient.client_option["client_user_id"] != user["id"]) { + if (tdlibClient.client_option["client_tg_user_id"] != user["id"]) { is_constain_update = true; - tdlibClient.client_option["client_user_id"] = user["id"]; + tdlibClient.client_option["client_tg_user_id"] = user["id"]; } - if (updateTelegramClient.client_option["client_username"] != - user_usename) { + if (updateTelegramClient.client_option["client_username"] != user_usename) { is_constain_update = true; tdlibClient.client_option["client_username"] = user_usename; - updateTelegramClient.telegramClientData.client_user_name = - user_usename; + updateTelegramClient.telegramClientData.client_user_name = user_usename; } if (is_constain_update) { - await tdlib.updateClientById( - updateTelegramClient.telegramClientData.tdlib_client_id, - newTdlibClient: tdlibClient); + await tdlib.updateClientById(updateTelegramClient.telegramClientData.tdlib_client_id, newTdlibClient: tdlibClient); } } } @@ -346,11 +316,8 @@ class TelegramClient { /// return original data json EventEmitterListener on({ required String event_name, - required FutureOr Function( - UpdateTelegramClient updateTelegramClient) - onUpdate, - required FutureOr Function(Object error, StackTrace stackTrace) - onError, + required FutureOr Function(UpdateTelegramClient updateTelegramClient) onUpdate, + required FutureOr Function(Object error, StackTrace stackTrace) onError, }) { return event_emitter.on(event_name, null, (ev, context) async { try { @@ -373,11 +340,9 @@ class TelegramClient { } if (ev.eventData is TdlibIsolateReceiveData) { - final TdlibIsolateReceiveData tdlibIsolateReceiveData = - (ev.eventData as TdlibIsolateReceiveData); + final TdlibIsolateReceiveData tdlibIsolateReceiveData = (ev.eventData as TdlibIsolateReceiveData); - final TdlibClient? tdlibClient = - tdlib.clients[tdlibIsolateReceiveData.clientId]; + final TdlibClient? tdlibClient = tdlib.clients[tdlibIsolateReceiveData.clientId]; final UpdateTd updateTd = UpdateTd( update: tdlibIsolateReceiveData.updateData, @@ -405,8 +370,7 @@ class TelegramClient { client_user_name: () { try { if (tdlibClient != null) { - if (tdlibClient.client_option["client_username"] - is String) { + if (tdlibClient.client_option["client_username"] is String) { return tdlibClient.client_option["client_username"]; } } @@ -414,10 +378,10 @@ class TelegramClient { return ""; }(), - client_user_id: () { + client_tg_user_id: () { try { if (tdlibClient != null) { - return tdlibClient.client_user_id; + return tdlibClient.client_tg_user_id; } } catch (e) {} return 0; @@ -459,15 +423,11 @@ class TelegramClient { bool? isAutoGetChat, bool isInvokeThrowOnError = true, bool isAutoExtendMessage = false, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr> Function( - String, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr> Function(String, int client_id, TdlibNative libTdJson)? onGetInvokeData, }) async { // telegramClientLib ??= telegram_client_lib; - if (telegramClientData.telegramClientType == - TelegramClientType.telegam_bot_api) { + if (telegramClientData.telegramClientType == TelegramClientType.telegam_bot_api) { final Map respond = await telegramBotApi.request( parameters["@type"], tokenBot: telegramClientData.telegram_bot_api_token_bot, @@ -499,8 +459,7 @@ class TelegramClient { )); return respond; } - final telegram_client_scheme.Error error = - telegram_client_scheme.Error.create( + final telegram_client_scheme.Error error = telegram_client_scheme.Error.create( special_extra: "error", code: 500, message: "telegram_client_type_not_found", @@ -554,11 +513,8 @@ class TelegramClient { bool? isAutoGetChat, bool isInvokeThrowOnError = true, bool isAutoExtendMessage = false, - FutureOr Function(int client_id, TdlibNative libTdJson)? - onGenerateExtraInvoke, - FutureOr> Function( - String, int client_id, TdlibNative libTdJson)? - onGetInvokeData, + FutureOr Function(int client_id, TdlibNative libTdJson)? onGenerateExtraInvoke, + FutureOr> Function(String, int client_id, TdlibNative libTdJson)? onGetInvokeData, }) async { if (telegramClientData.telegramClientType != TelegramClientType.tdlib) { return await invoke( @@ -611,8 +567,7 @@ class TelegramClient { ); } - if (RegExp(r"^(answerCallbackQuery)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(answerCallbackQuery)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await answerCallbackQuery( @@ -622,8 +577,7 @@ class TelegramClient { ); } - if (RegExp(r"^(answerInlineQuery)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(answerInlineQuery)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await answerInlineQuery( @@ -642,8 +596,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(banChatSenderChat)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(banChatSenderChat)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await banChatSenderChat( @@ -662,8 +615,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(createInvoiceLink)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(createInvoiceLink)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await createInvoiceLink( @@ -700,8 +652,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(editMessageCaption)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(editMessageCaption)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await editMessageCaption( @@ -711,8 +662,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(editMessageMedia)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(editMessageMedia)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await editMessageMedia( @@ -722,8 +672,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(editMessageReplyMarkup)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(editMessageReplyMarkup)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await editMessageReplyMarkup( @@ -744,8 +693,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(getChatAdministrators)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(getChatAdministrators)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await getChatAdministrators( @@ -847,8 +795,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(sendChatScreenshotTakenNotification)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(sendChatScreenshotTakenNotification)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await sendChatScreenshotTakenNotification( @@ -1028,8 +975,7 @@ class TelegramClient { ); } - if (RegExp(r"^(unPinAllChatMessages)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(unPinAllChatMessages)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await unPinAllChatMessages( @@ -1038,8 +984,7 @@ class TelegramClient { ), ); } - if (RegExp(r"^(unPinChatMessage)$", caseSensitive: false) - .hasMatch(method)) { + if (RegExp(r"^(unPinChatMessage)$", caseSensitive: false).hasMatch(method)) { return requestReturnAsApi( is_return_as_api: is_return_as_api, result: await unPinChatMessage( diff --git a/package/telegram_client/lib/telegram_client/telegram_client_data.dart b/package/telegram_client/lib/telegram_client/telegram_client_data.dart index 9102320b..ea80aae5 100644 --- a/package/telegram_client/lib/telegram_client/telegram_client_data.dart +++ b/package/telegram_client/lib/telegram_client/telegram_client_data.dart @@ -37,7 +37,7 @@ import 'package:telegram_client/telegram_client/telegram_client_type.dart'; /// return original data json class TelegramClientData { final TelegramClientType telegramClientType; - final int client_user_id; + final int client_tg_user_id; int tdlib_client_id; String telegram_bot_api_token_bot; @@ -51,7 +51,7 @@ class TelegramClientData { required this.telegramClientType, required this.tdlib_client_id, this.client_user_name = "", - this.client_user_id = 0, + this.client_tg_user_id = 0, this.is_bot = false, }); @@ -59,7 +59,7 @@ class TelegramClientData { static TelegramClientData tdlib({ required int tdlib_client_id, String client_user_name = "", - int client_user_id = 0, + int client_tg_user_id = 0, bool is_bot = true, }) { return TelegramClientData( @@ -67,7 +67,7 @@ class TelegramClientData { telegramClientType: TelegramClientType.tdlib, tdlib_client_id: tdlib_client_id, client_user_name: client_user_name, - client_user_id: client_user_id, + client_tg_user_id: client_tg_user_id, is_bot: is_bot, ); } @@ -76,7 +76,7 @@ class TelegramClientData { static TelegramClientData telegramBotApi({ required String token_bot, String client_user_name = "", - int client_user_id = 0, + int client_tg_user_id = 0, bool is_bot = true, }) { return TelegramClientData( @@ -84,7 +84,7 @@ class TelegramClientData { telegramClientType: TelegramClientType.telegam_bot_api, tdlib_client_id: 0, client_user_name: client_user_name, - client_user_id: client_user_id, + client_tg_user_id: client_tg_user_id, is_bot: is_bot, ); } diff --git a/package/telegram_client/lib/telegram_client/update_telegram_client.dart b/package/telegram_client/lib/telegram_client/update_telegram_client.dart index 047495d5..d7140b10 100644 --- a/package/telegram_client/lib/telegram_client/update_telegram_client.dart +++ b/package/telegram_client/lib/telegram_client/update_telegram_client.dart @@ -60,14 +60,11 @@ class UpdateTelegramClient { }); Map tgClientData() { - if (telegramClientData.telegramClientType == - TelegramClientType.telegam_bot_api) { - final Map decyprt = json.decode( - tg.telegramBotApi.telegram_crypto.decrypt(data_base64: query["tg"])); - - if (decyprt["client_user_id"] == null || decyprt["client_user_id"] == 0) { - decyprt["client_user_id"] = - TgUtils.parserBotUserIdFromToken(decyprt["client_token"]); + if (telegramClientData.telegramClientType == TelegramClientType.telegam_bot_api) { + final Map decyprt = json.decode(tg.telegramBotApi.telegram_crypto.decrypt(data_base64: query["tg"])); + + if (decyprt["client_tg_user_id"] == null || decyprt["client_tg_user_id"] == 0) { + decyprt["client_tg_user_id"] = TgUtils.parserBotUserIdFromToken(decyprt["client_token"]); } return decyprt; } @@ -79,16 +76,14 @@ class UpdateTelegramClient { required bool is_lite, required UpdataOptionTelegramClient updataOptionTelegramClient, }) async { - if (telegramClientData.telegramClientType == - TelegramClientType.telegam_bot_api) { + if (telegramClientData.telegramClientType == TelegramClientType.telegam_bot_api) { return rawData; } if (rawData["@type"] == "updateAuthorizationState") { return rawData; } - if (rawData["@type"] == "updateNewCallbackQuery" || - rawData["@type"] == "updateNewInlineCallbackQuery") { + if (rawData["@type"] == "updateNewCallbackQuery" || rawData["@type"] == "updateNewInlineCallbackQuery") { return await tg.callbackQuery_toJson( update: rawData, telegramClientData: telegramClientData,