Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
￴￴ committed Jul 31, 2024
1 parent d695f20 commit 4518e22
Show file tree
Hide file tree
Showing 57 changed files with 1,058 additions and 486 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.8.5
## 0.8.22

- Fix pub score.
- Support Tdlib Latest 1.8.34.
2 changes: 1 addition & 1 deletion bin/replace/update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import "package:path/path.dart" as path;
import "package:yaml/yaml.dart" as yaml;
import "package:yaml_writer/yaml_writer.dart";

String version_package = "0.8.21";
String version_package = "0.8.22";
Future<void> pubspecUpdate({
required File filePubspec,
}) async {
Expand Down
4 changes: 2 additions & 2 deletions package/mtproto/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.8.21
## 0.8.22

- Update: 2024-07-09 03:35:40.406818 - update librarry.
- Update: 2024-08-01 04:26:35.969422 - update librarry.
2 changes: 1 addition & 1 deletion package/mtproto/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'mtproto'
description: 'Telegram Client Lightweight, blazing and Highly customizable for make application telegram based tdlib, mtproto, or bot api and support server side.'
version: '0.8.21'
version: '0.8.22'
homepage: 'https://github.com/azkadev/telegram_client'
repository: 'https://github.com/azkadev/telegram_client.git'
issue_tracker: 'https://github.com/azkadev/telegram_client/issues'
Expand Down
4 changes: 2 additions & 2 deletions package/telegram_client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## 0.8.21
## 0.8.22

- Update: 2024-07-09 03:35:40.423434 - update librarry.
- Update: 2024-08-01 04:26:35.980408 - update librarry.
226 changes: 163 additions & 63 deletions package/telegram_client/lib/api/telegram_client_api_core.dart

Large diffs are not rendered by default.

67 changes: 48 additions & 19 deletions package/telegram_client/lib/cli/telegram_client_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ Future<void> telegramClientCli(List<String> args_raw) async {
}

if (command == "create") {
final List<TelegramClientProjectTemplate> telegramClientProjectTemplates = TelegramClientProjectTemplate.templates;
final List<TelegramClientProjectTemplate> telegramClientProjectTemplates =
TelegramClientProjectTemplate.templates;
telegramClientProjectTemplates.sort((a, b) => a.name.compareTo(b.name));
if (["--help", "-h"].contains(args.after(command) ?? "")) {
final String help_create = """
Expand All @@ -113,7 +114,8 @@ Example: ${executable} create name_project --template ${telegramClientProjectTem
}
Directory directory_current = Directory.current;
String new_project_name = await Future(() async {
String new_project_name_from_command = (args.after(command) ?? "").toLowerCase();
String new_project_name_from_command =
(args.after(command) ?? "").toLowerCase();
if (new_project_name_from_command.isNotEmpty) {
return new_project_name_from_command;
}
Expand All @@ -131,16 +133,21 @@ Example: ${executable} create name_project --template ${telegramClientProjectTem
}
return "";
});
TelegramClientProjectTemplate telegramClientProjectTemplate = await Future(() async {
String type_procces = (args.after("--template") ?? "").toLowerCase().trim();
TelegramClientProjectTemplate? telegramClientProjectTemplate = telegramClientProjectTemplates.firstWhereOrNull((element) => element.name.toLowerCase() == type_procces);
TelegramClientProjectTemplate telegramClientProjectTemplate =
await Future(() async {
String type_procces =
(args.after("--template") ?? "").toLowerCase().trim();
TelegramClientProjectTemplate? telegramClientProjectTemplate =
telegramClientProjectTemplates.firstWhereOrNull(
(element) => element.name.toLowerCase() == type_procces);
if (telegramClientProjectTemplate != null) {
return telegramClientProjectTemplate;
}
if (is_interactive) {
while (true) {
await Future.delayed(Duration(microseconds: 1));
TelegramClientProjectTemplate telegramClientProjectTemplate = logger.chooseOne(
TelegramClientProjectTemplate telegramClientProjectTemplate =
logger.chooseOne(
"Template: ",
choices: telegramClientProjectTemplates,
display: (choice) {
Expand All @@ -157,7 +164,12 @@ Example: ${executable} create name_project --template ${telegramClientProjectTem
print("Failed");
exit(1);
}
var strm = packageFullTemplateDartApi.create(newName: new_project_name, directoryBase: directory_current, telegramClientProjectTemplate: telegramClientProjectTemplate).listen((event) {
var strm = packageFullTemplateDartApi
.create(
newName: new_project_name,
directoryBase: directory_current,
telegramClientProjectTemplate: telegramClientProjectTemplate)
.listen((event) {
printed(event);
});

Expand Down Expand Up @@ -231,13 +243,15 @@ Example: ${executable} install library ${library_types.first}
print(help_create.trim());
exit(0);
}
TelegramClientLibraryType telegramClientLibraryType = await Future(() async {
TelegramClientLibraryType telegramClientLibraryType =
await Future(() async {
// TelegramClientLibraryType? telegramClientLibraryType = TelegramClientLibraryType.values.firstWhereOrNull((element) => element.name.toLowerCase() == command_after_library);

if (is_interactive) {
while (true) {
await Future.delayed(Duration(microseconds: 1));
TelegramClientLibraryType telegramClientLibraryType = logger.chooseOne(
TelegramClientLibraryType telegramClientLibraryType =
logger.chooseOne(
"Library Type: ",
choices: TelegramClientLibraryType.values,
display: (choice) {
Expand All @@ -250,7 +264,9 @@ Example: ${executable} install library ${library_types.first}
}
return TelegramClientLibraryType.tdlib;
});
var strm = packageFullTemplateDartApi.installLibrary(telegramClientLibraryType: telegramClientLibraryType).listen((event) {
var strm = packageFullTemplateDartApi
.installLibrary(telegramClientLibraryType: telegramClientLibraryType)
.listen((event) {
printed(event);
});

Expand All @@ -263,7 +279,8 @@ Example: ${executable} install library ${library_types.first}
}
if (command == "telegram_bot_api") {
List<Map<dynamic, dynamic>> parametersRequest = [];
String input_file = (args.after("-i") ?? args.after("--input") ?? "").trim();
String input_file =
(args.after("-i") ?? args.after("--input") ?? "").trim();

File file_input = File(input_file);
if (file_input.existsSync()) {
Expand All @@ -276,7 +293,8 @@ Example: ${executable} install library ${library_types.first}
if (args.contains("--@type") || args.contains("-@type")) {
String parameters_key = "";
for (var element in args.arguments) {
if (RegExp(r"(-(-)?(@)?[a-z]+)", caseSensitive: false).hasMatch(element)) {
if (RegExp(r"(-(-)?(@)?[a-z]+)", caseSensitive: false)
.hasMatch(element)) {
parameters_key = element.replaceAll(RegExp("-(-)?"), "");
json_data[parameters_key] = "";
continue;
Expand All @@ -292,7 +310,8 @@ Example: ${executable} install library ${library_types.first}
].contains(parameters_key)) {
if (RegExp("^(@)", caseSensitive: false).hasMatch(element)) {
json_data[parameters_key] = element;
} else if (RegExp("([a-z_]+)", caseSensitive: false).hasMatch(element)) {
} else if (RegExp("([a-z_]+)", caseSensitive: false)
.hasMatch(element)) {
json_data[parameters_key] = "@${element.trim()}";
} else {
json_data[parameters_key] = (num.tryParse(element) ?? 0).toInt();
Expand All @@ -310,7 +329,9 @@ Example: ${executable} install library ${library_types.first}
}
}

await packageFullTemplateDartApi.telegramBotApi(parametersRequest: parametersRequest).listen((event) {
await packageFullTemplateDartApi
.telegramBotApi(parametersRequest: parametersRequest)
.listen((event) {
printed(event);
}).asFuture();

Expand All @@ -322,7 +343,8 @@ Example: ${executable} install library ${library_types.first}
exit(1);
}
Directory directory = file.parent.parent;
Directory directory_pub = Directory(path.join(directory.path, ".dart_tool", "pub"));
Directory directory_pub =
Directory(path.join(directory.path, ".dart_tool", "pub"));
if (directory_pub.existsSync()) {
await directory_pub.delete(recursive: true);
}
Expand Down Expand Up @@ -356,8 +378,13 @@ File? getPackageDirectory({
List<Progress> progresss = [];
// Progress progress = logger.progress("message");
void printed(TelegramClientApiStatus event) {
if ([TelegramClientApiStatusType.progress_start, TelegramClientApiStatusType.progress_complete, TelegramClientApiStatusType.progress].contains(event.telegramClientApiStatusType)) {
if (event.telegramClientApiStatusType == TelegramClientApiStatusType.progress_start) {
if ([
TelegramClientApiStatusType.progress_start,
TelegramClientApiStatusType.progress_complete,
TelegramClientApiStatusType.progress
].contains(event.telegramClientApiStatusType)) {
if (event.telegramClientApiStatusType ==
TelegramClientApiStatusType.progress_start) {
progresss.add(logger.progress(event.value));
// progress.cancel();
// progress = logger.progress(event.value);
Expand All @@ -372,11 +399,13 @@ void printed(TelegramClientApiStatus event) {
return progresss.last;
}
}();
if (event.telegramClientApiStatusType == TelegramClientApiStatusType.progress) {
if (event.telegramClientApiStatusType ==
TelegramClientApiStatusType.progress) {
progress.update(event.value);
return;
}
if (event.telegramClientApiStatusType == TelegramClientApiStatusType.progress_complete) {
if (event.telegramClientApiStatusType ==
TelegramClientApiStatusType.progress_complete) {
progress.complete(event.value);

// progress.cancel();
Expand Down
Loading

0 comments on commit 4518e22

Please sign in to comment.