From 83f53cc918da45f7644cae3949ffac623f306932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BF=B4=EF=BF=B4?= <￴￴> Date: Tue, 12 Nov 2024 18:01:15 +0700 Subject: [PATCH] update --- package/telegram_client/activate.sh | 3 - package/telegram_client/alias.sh | 2 - package/telegram_client/dev.sh | 3 - .../telegram_bot_api_core.dart | 51 +++++---------- .../telegram_client/telegram_client_type.dart | 6 ++ package/telegram_client/pubspec.lock | 65 +++++++++++++++---- package/telegram_client/pubspec.yaml | 3 +- 7 files changed, 78 insertions(+), 55 deletions(-) delete mode 100755 package/telegram_client/activate.sh delete mode 100755 package/telegram_client/alias.sh delete mode 100755 package/telegram_client/dev.sh diff --git a/package/telegram_client/activate.sh b/package/telegram_client/activate.sh deleted file mode 100755 index d959b3e0..00000000 --- a/package/telegram_client/activate.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -dart pub global activate --source path ./ --overwrite \ No newline at end of file diff --git a/package/telegram_client/alias.sh b/package/telegram_client/alias.sh deleted file mode 100755 index 4fa4945d..00000000 --- a/package/telegram_client/alias.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -alias telegram_client_dev="dart run /home/galaxeus/Documents/galaxeus/app/telegram_client/package/telegram_client/bin/telegram_client.dart" \ No newline at end of file diff --git a/package/telegram_client/dev.sh b/package/telegram_client/dev.sh deleted file mode 100755 index 26c7b250..00000000 --- a/package/telegram_client/dev.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# dart run --observe --enable-asserts /home/galaxeus/Documents/galaxeus/app/general_machine_system_services/library/general_api_server/bin/general_api_dev.dart -dart run --enable-asserts --disable-service-auth-codes --observe=4910:0.0.0.0 --enable-vm-service=4910:0.0.0.0 test/tdlib.dart \ No newline at end of file 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 b4d31d0b..18c4d20f 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 @@ -65,7 +65,7 @@ class TelegramBotApi { ServerUniverseNative? serverUniverseNative; bool is_init_server = false; Uri telegram_url_webhook = Uri.parse("http://0.0.0.0:8080/telegram/webhook"); - final Crypto telegram_crypto = Crypto(key: ""); + final Crypto telegram_crypto; Client http_client = Client(); final Map client_option = { "api_id": 0, @@ -115,11 +115,11 @@ class TelegramBotApi { this.event_update = "update", Uri? telegramUrlWebhook, Client? httpClient, - }) { + }) : telegram_crypto = Crypto(key: telegramCryptoKey) { if (httpClient != null) { http_client = httpClient; } - telegram_crypto.defaultKey = telegramCryptoKey; + if (telegramUrlWebhook != null) { telegram_url_webhook = telegramUrlWebhook; } @@ -138,8 +138,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; @@ -172,17 +171,13 @@ 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_tg_user_id"] == null || - decyprt["client_tg_user_id"] == 0) { - decyprt["client_tg_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 TelegramClientLibraryClientData(decyprt); } - Future initIsolate({ String? tokenBot, @@ -224,7 +219,7 @@ class TelegramBotApi { queryParameters: { "tg": query_telegram_webhook, }, - ).toString(); + ).toString(); if (url_webhook_old == url_webhook_new) { final Map new_scheme = { @@ -279,8 +274,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( eventName: type_update, onCallback: (listener, update) async { @@ -386,10 +380,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; @@ -443,16 +434,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; @@ -560,8 +548,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); @@ -578,8 +565,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, @@ -671,8 +657,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"; } @@ -707,8 +692,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"; @@ -792,8 +776,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_type.dart b/package/telegram_client/lib/telegram_client/telegram_client_type.dart index fae84514..f756d5c8 100644 --- a/package/telegram_client/lib/telegram_client/telegram_client_type.dart +++ b/package/telegram_client/lib/telegram_client/telegram_client_type.dart @@ -37,3 +37,9 @@ enum TelegramClientType { tdlib, telegam_bot_api, } + +enum TelegramClientTelegramType { + bot, + userbot, + telegram, +} \ No newline at end of file diff --git a/package/telegram_client/pubspec.lock b/package/telegram_client/pubspec.lock index 44709da6..ad6985a0 100644 --- a/package/telegram_client/pubspec.lock +++ b/package/telegram_client/pubspec.lock @@ -81,6 +81,14 @@ packages: url: "https://pub.dev" source: hosted version: "8.9.2" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" charcode: dependency: transitive description: @@ -109,10 +117,10 @@ packages: dependency: "direct main" description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.18.0" console: dependency: transitive description: @@ -185,6 +193,11 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + flutter: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" freezed_annotation: dependency: transitive description: @@ -237,10 +250,10 @@ packages: dependency: transitive description: name: http_parser - sha256: "40f592dd352890c3b60fec1b68e786cefb9603e05ff303dbc4dda49b304ecdf4" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "4.0.2" image: dependency: transitive description: @@ -305,6 +318,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + url: "https://pub.dev" + source: hosted + version: "0.11.1" meta: dependency: transitive description: @@ -361,6 +382,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.0.2" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" pointycastle: dependency: "direct overridden" description: @@ -421,10 +450,10 @@ packages: dependency: transitive description: name: shelf - sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 url: "https://pub.dev" source: hosted - version: "1.4.2" + version: "1.4.1" shelf_packages_handler: dependency: transitive description: @@ -449,6 +478,11 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" source_gen: dependency: transitive description: @@ -505,14 +539,20 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" - system_info_fetch: + system_information: dependency: "direct dev" description: - name: system_info_fetch - sha256: cf1de46ddd67411cc74de16bc42a725daf1c96fb6e6245c519af38d24452c8c9 - url: "https://pub.dev" - source: hosted - version: "0.0.24" + path: "/home/galaxeus/Documents/galaxeus/app/system_information/library/system_information" + relative: false + source: path + version: "0.0.0" + system_information_flutter: + dependency: transitive + description: + path: "../../../system_information/library/system_information_flutter" + relative: true + source: path + version: "0.0.1" term_glyph: dependency: transitive description: @@ -683,3 +723,4 @@ packages: version: "0.2.3" sdks: dart: ">=3.5.1 <4.0.0" + flutter: ">=3.3.0" diff --git a/package/telegram_client/pubspec.yaml b/package/telegram_client/pubspec.yaml index 7f9e3fe2..180d264b 100644 --- a/package/telegram_client/pubspec.yaml +++ b/package/telegram_client/pubspec.yaml @@ -26,7 +26,8 @@ environment: dev_dependencies: lints: '^4.0.0' test: 'any' - system_info_fetch: '^0.0.24' + system_information: + path: '/home/galaxeus/Documents/galaxeus/app/system_information/library/system_information' dependencies: ffi: '^2.1.3' http: '>=1.1.2 <=2.1.2'