Skip to content

Commit

Permalink
i[dayte
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Jun 30, 2022
1 parent 2b276f8 commit a84e382
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
11 changes: 10 additions & 1 deletion dart/telegram_client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,13 @@
- fix log tdlib android.

## 0.3.5
- update api structur.
- update api structur.

## 0.3.6
- set message_id tdlib to message_id api

## 0.3.7
- add method appRequest for make easy app

## 0.3.8
- update
61 changes: 51 additions & 10 deletions dart/telegram_client/lib/tdlib/tdlib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,12 @@ class Tdlib {
/// return result like bot api:
/// {
/// }
getChat(dynamic chat_id,
{bool is_detail = false, bool is_super_detail = false}) async {
getChat(
dynamic chat_id, {
bool is_detail = false,
bool is_super_detail = false,
bool is_more_detail = false,
}) async {
try {
if (RegExp(r"^@.*$", caseSensitive: false).hasMatch(chat_id.toString())) {
var search_public_chat =
Expand Down Expand Up @@ -1130,7 +1134,7 @@ class Tdlib {
}
}
}
if (is_super_detail) {
if (is_more_detail) {
var getSuperGroupFullInfo = {};
try {
getSuperGroupFullInfo = await invoke("getSupergroupFullInfo", {
Expand Down Expand Up @@ -1311,7 +1315,7 @@ class Tdlib {
} catch (e) {}
}
}
if (is_super_detail) {
if (is_more_detail) {
try {
var getUserFullInfo = {};
try {
Expand Down Expand Up @@ -1432,6 +1436,7 @@ class Tdlib {
Map? chat_data,
bool is_detail = false,
bool is_super_detail = false,
bool is_more_detail = false,
}) async {
try {
if (update["@type"] == "message") {
Expand Down Expand Up @@ -1479,8 +1484,12 @@ class Tdlib {
} catch (e) {}
if (is_chat_not_same) {
try {
var chatResult = await getChat(update["chat_id"],
is_detail: is_detail, is_super_detail: is_super_detail);
var chatResult = await getChat(
update["chat_id"],
is_detail: is_detail,
is_super_detail: is_super_detail,
is_more_detail: is_more_detail,
);
if (chatResult["ok"]) {
chat_json = chatResult["result"];
}
Expand All @@ -1490,7 +1499,7 @@ class Tdlib {

json["is_outgoing"] = update["is_outgoing"] ?? false;
json["is_pinned"] = update["is_pinned"] ?? false;
if (typeof(update["sender_id"]) == "object") {
if (update["sender_id"] is Map) {
Map from_json = {
"id": 0,
"first_name": "",
Expand Down Expand Up @@ -1579,8 +1588,8 @@ class Tdlib {

json["chat"] = chat_json;
json["date"] = update["date"];
json["message_id"] = update["id"];
json["api_message_id"] = getMessageId(json["message_id"], true);
json["message_id"] = getMessageId(update["id"], true);
json["raw_message_id"] = update["id"];
update.forEach((key, value) {
try {
if (typeof(value) == "boolean") {
Expand Down Expand Up @@ -2118,7 +2127,8 @@ class Tdlib {
}
}
} catch (e) {}
json["message_id"] = update["message_id"];
json["message_id"] = getMessageId(update["message_id"], true);
json["raw_message_id"] = update["message_id"];
json["from"] = from;
json["chat"] = chat;
json["chat_instance"] = update["chat_instance"];
Expand Down Expand Up @@ -2342,6 +2352,37 @@ class Tdlib {
return callback(result);
} else {}
}

/// if you build flutter apps recommended to call this for call api
Future<Map> appRequest(
String method, {
Map<String, dynamic>? parameters,
bool is_sync = false,
bool is_raw = false,
bool is_log = false,
}) async {
var result = {};
try {
parameters ??= {};
if (is_sync) {
result = invokeSync(method, parameters);
} else {
if (is_raw) {
result = await invoke(method, parameters);
} else {
result = await request(method, parameters);
}
}
} catch (e) {
if (e is Map) {
result = e;
}
}
if (is_log) {
print(result);
}
return result;
}
}

/// Update td for make update support raw, raw api, raw api light
Expand Down
2 changes: 1 addition & 1 deletion dart/telegram_client/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: telegram_client
description: Telegram Client Lightweight, blazing and Highly customizable for make application telegram based tdlib, mtproto, or bot api and support server side.
version: 0.3.5
version: 0.3.8
homepage: https://github.com/azkadev/telegram_client/tree/main/dart/telegram_client/doc
repository: https://github.com/azkadev/telegram_client/tree/main/dart/telegram_client
issue_tracker: https://github.com/azkadev/telegram_client/issues
Expand Down

0 comments on commit a84e382

Please sign in to comment.