Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Apr 24, 2023
1 parent 720c7c0 commit 5509b47
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 24 deletions.
8 changes: 8 additions & 0 deletions package/telegram_client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.4.12

- add reply markup in jsonMessage tdlib

## 0.4.11

- add message_id tdlib to api and message_id api to tdlib

## 0.4.10

- Memperbaiki compile on flutter web
Expand Down
4 changes: 4 additions & 0 deletions package/telegram_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ Telegram client dart library untuk membuat telegram based flutter bot userbot bi
![](https://raw.githubusercontent.com/azkadev/telegram_client/main/.github/telegram_bot_api.gif)


### Information

Library hanya update jika ada feature yang saya ingin update jika kamu butuh library dengan dokumentasi lengkap sehingga bisa develop app / bot / userbot / apapun itu kamu bisa membeli layanan Azkadev (50k / bulan) akses semua feature library umum

## Examples App use Telegram Client


Expand Down
163 changes: 154 additions & 9 deletions package/telegram_client/lib/tdlib/tdlib_core.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: non_constant_identifier_names, empty_catches, unnecessary_type_check, void_checks, unnecessary_brace_in_string_interps
// ignore_for_file: non_constant_identifier_names, empty_catches, unnecessary_type_check, void_checks, unnecessary_brace_in_string_interps, unused_catch_stack

// ignore: slash_for_doc_comments
/**
Expand Down Expand Up @@ -163,20 +163,58 @@ class Tdlib extends LibTdJson {
}

/// getMessage real like bot api
num getMessageId(num message_id, [bool is_reverse = false]) {
if (is_reverse) {
return (message_id ~/ 1048576);
} else {
num getMessageId(dynamic message_id, [bool is_reverse = false]) {
if (message_id is num) {
if (is_reverse) {
return (message_id ~/ 1048576);
} else {
return (message_id * 1048576).toInt();
}
}
return 0;
}

num messageTdlibToApi(dynamic message_id) {
if (message_id is num) {
return (message_id ~/ 1048576).toInt();
}
return 0;
}

num messageApiToTdlib(dynamic message_id) {
if (message_id is num) {
return (message_id * 1048576).toInt();
}
return 0;
}

List<int> messagesTdlibToApi(dynamic message_ids) {
if (message_ids is List<int>) {
return message_ids
.map((message_id) => messageTdlibToApi(message_id).toInt())
.toList()
.cast<int>();
}
return [];
}

num messageTdlibToApi(num message_id) {
return (message_id ~/ 1048576);
List<int> messagesApiToTdlib(message_ids) {
if (message_ids is List<int>) {
return message_ids
.map((message_id) => messageApiToTdlib(message_id).toInt())
.toList()
.cast<int>();
}
return [];
}

num messageApiToTdlib(num message_id) {
return (message_id * 1048576);
int toSuperGroupId(dynamic chat_id) {
if (chat_id is int) {
if (chat_id.isNegative) {
return int.parse("${chat_id}".replaceAll(RegExp(r"-100"), ""));
}
}
return 0;
}

/// set up authorizationStateWaitTdlibParameters new client without more code
Expand Down Expand Up @@ -2561,6 +2599,113 @@ class Tdlib extends LibTdJson {
json["entities"] = new_entities;
}

if (update["reply_markup"] is Map) {
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);
}
if (update_reply_markup["one_time"] is bool) {
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);
}

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)
: "";
}
try {
if (update_reply_markup["@type"] == "replyMarkupShowKeyboard") {
List raw_keyboard = update_reply_markup["rows"];
List<List<Map>> keyboards_data = [];

for (var i = 0; i < raw_keyboard.length; i++) {
dynamic raw_keyboards = raw_keyboard[i];

if (raw_keyboards is List) {
List<Map> new_keyboard = [];
for (var ii = 0; ii < raw_keyboards.length; ii++) {
dynamic raw_keyboard_data = raw_keyboards[ii];
if (raw_keyboard_data is Map) {
Map jsonDataKeyboard = {
"text": raw_keyboard_data["text"],
};
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") {
jsonDataKeyboard["is_request_poll"] = true;
}
if (raw_keyboard_data["@type"] ==
"keyboardButtonTypeRequestLocation") {
jsonDataKeyboard["is_request_location"] = true;
}
//
if (raw_keyboard_data["@type"] ==
"keyboardButtonTypeRequestPhoneNumber") {
jsonDataKeyboard["is_request_phone_number"] = true;
}
}
new_keyboard.add(jsonDataKeyboard);
}
}
keyboards_data.add(new_keyboard);
}
}
json["reply_markup"]["keyboard"] = keyboards_data;
}
if (update_reply_markup["@type"] == "replyMarkupInlineKeyboard") {
List raw_keyboard = update_reply_markup["rows"];
List<List<Map>> keyboards_data = [];

for (var i = 0; i < raw_keyboard.length; i++) {
dynamic raw_keyboards = raw_keyboard[i];

if (raw_keyboards is List) {
List<Map> new_keyboard = [];
for (var ii = 0; ii < raw_keyboards.length; ii++) {
dynamic raw_keyboard_data = raw_keyboards[ii];
if (raw_keyboard_data is Map) {
Map jsonDataKeyboard = {
"text": raw_keyboard_data["text"],
};
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"]["data"] is String) {
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"]["url"] is String) {
jsonDataKeyboard["url"] =
raw_keyboard_data["type"]["url"];
}
}
}
new_keyboard.add(jsonDataKeyboard);
}
}
keyboards_data.add(new_keyboard);
}
}
json["reply_markup"]["inline_keyboard"] = keyboards_data;
}
} catch (e, stack) {}
}

if (is_detail) {
if (is_super_detail) {
if (json["chat"]["type"] != null) {
Expand Down
2 changes: 1 addition & 1 deletion package/telegram_client/lib/tdlib/tdlib_ffi/tdlib_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class LibTdJson {
}
}
if (extra_id.isEmpty) {
extra_id= generateUuid(15);
extra_id = generateUuid(15);
parameters["@extra"] = extra_id;
}

Expand Down
57 changes: 57 additions & 0 deletions package/telegram_client/lib/util/util.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,67 @@
// ignore_for_file: unnecessary_brace_in_string_interps, non_constant_identifier_names

import 'dart:convert';

/// telegram util
class TgUtils {
/// telegram utils
TgUtils();

/// getMessage real like bot api
num getMessageId(dynamic message_id, [bool is_reverse = false]) {
if (message_id is num) {
if (is_reverse) {
return (message_id ~/ 1048576);
} else {
return (message_id * 1048576).toInt();
}
}
return 0;
}

num messageTdlibToApi(dynamic message_id) {
if (message_id is num) {
return (message_id ~/ 1048576).toInt();
}
return 0;
}

num messageApiToTdlib(dynamic message_id) {
if (message_id is num) {
return (message_id * 1048576).toInt();
}
return 0;
}

List<int> messagesTdlibToApi(dynamic message_ids) {
if (message_ids is List<int>) {
return message_ids
.map((message_id) => messageTdlibToApi(message_id).toInt())
.toList()
.cast<int>();
}
return [];
}

List<int> messagesApiToTdlib(message_ids) {
if (message_ids is List<int>) {
return message_ids
.map((message_id) => messageApiToTdlib(message_id).toInt())
.toList()
.cast<int>();
}
return [];
}

int toSuperGroupId(dynamic chat_id) {
if (chat_id is int) {
if (chat_id.isNegative) {
return int.parse("${chat_id}".replaceAll(RegExp(r"-100"), ""));
}
}
return 0;
}

/// ccreate offset for tl
static List<String> splitByLength(String text, int length,
{bool ignoreEmpty = false}) {
Expand Down
4 changes: 2 additions & 2 deletions package/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.4.10
version: 0.4.12
homepage: https://youtube.com/@azkadev
repository: https://github.com/azkadev/telegram_client
issue_tracker: https://github.com/azkadev/telegram_client/issues
Expand All @@ -24,7 +24,7 @@ dev_dependencies:

dependencies:
ffi: ^2.0.1
galaxeus_lib: ^0.0.62
galaxeus_lib: ^0.0.63
http: ^0.13.5
path: ^1.8.3
universal_io: ^2.2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
galaxeus_lib: ^0.0.62
galaxeus_lib: ^0.0.63
url_launcher: ^6.1.10
universal_io: ^2.2.0
galaxeus_lib_flutter: ^0.0.6
galaxeus_lib_flutter: ^0.0.7
cool_alert: ^2.0.1
telegram_client: ^0.4.10
telegram_client: ^0.4.11
isar: ^3.0.5
isar_flutter_libs: ^3.0.5
path_provider: ^2.0.14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ environment:
sdk: '>=2.19.4 <3.0.0'

dependencies:
telegram_client: ^0.4.10
path: ^1.8.3
galaxeus_lib: ^0.0.62
telegram_client: ^0.4.11
path: ^1.8.2
galaxeus_lib: ^0.0.63
alfred: ^1.0.1+1
supabase_client: ^0.0.18
xendit: ^0.0.13
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ environment:
sdk: '>=2.19.4 <3.0.0'

dependencies:
telegram_client: ^0.4.10
path: ^1.8.3
galaxeus_lib: ^0.0.62
telegram_client: ^0.4.11
path: ^1.8.2
galaxeus_lib: ^0.0.63

dev_dependencies:
lints: ^2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ environment:
sdk: '>=2.19.4 <3.0.0'

dependencies:
telegram_client: ^0.4.10
path: ^1.8.3
galaxeus_lib: ^0.0.62
telegram_client: ^0.4.11
path: ^1.8.2
galaxeus_lib: ^0.0.63

dev_dependencies:
lints: ^2.0.0
Expand Down

0 comments on commit 5509b47

Please sign in to comment.