Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
￴￴ committed Nov 12, 2024
1 parent df7f78a commit 83f53cc
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 55 deletions.
3 changes: 0 additions & 3 deletions package/telegram_client/activate.sh

This file was deleted.

2 changes: 0 additions & 2 deletions package/telegram_client/alias.sh

This file was deleted.

3 changes: 0 additions & 3 deletions package/telegram_client/dev.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand All @@ -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<String, dynamic> body = await req.bodyAsJsonMap;
Expand Down Expand Up @@ -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<Map> initIsolate({
String? tokenBot,
Expand Down Expand Up @@ -224,7 +219,7 @@ class TelegramBotApi {
queryParameters: {
"tg": query_telegram_webhook,
},
).toString();
).toString();

if (url_webhook_old == url_webhook_new) {
final Map new_scheme = {
Expand Down Expand Up @@ -279,8 +274,7 @@ class TelegramBotApi {
/// });
/// ```
/// add this for handle update api
EventEmitterListener on(String type_update,
FutureOr<dynamic> Function(UpdateBot updateBot) callback) {
EventEmitterListener on(String type_update, FutureOr<dynamic> Function(UpdateBot updateBot) callback) {
return event_emitter.on(
eventName: type_update,
onCallback: (listener, update) async {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<int>(),
filename: value["name"], contentType: value["content_type"]);
var files = MultipartFile.fromBytes(key, (value["buffer"] as List).cast<int>(), 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;
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ enum TelegramClientType {
tdlib,
telegam_bot_api,
}

enum TelegramClientTelegramType {
bot,
userbot,
telegram,
}
65 changes: 53 additions & 12 deletions package/telegram_client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -683,3 +723,4 @@ packages:
version: "0.2.3"
sdks:
dart: ">=3.5.1 <4.0.0"
flutter: ">=3.3.0"
3 changes: 2 additions & 1 deletion package/telegram_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 83f53cc

Please sign in to comment.