Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 15, 2022
1 parent b08c53f commit e9db0dc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
18 changes: 16 additions & 2 deletions example/dart/tdlib/bin/tdlib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,26 @@ void main(List<String> arguments) async {
if (update.raw["message"] is Map) {
/// tdlib scheme is not full real because i generate file origin to dart with my script but you can still use
tdlib_scheme.Message message = tdlib_scheme.Message(update.raw["message"]);
int chat_id = message.chat_id ?? 0;
if (message.content.toJson()["@type"] == "messageText") {
int chat_id = message.chat_id ?? 0;
if (message.content.special_type == "messageText") {
if (update.raw["message"]["content"]["text"] is Map && update.raw["message"]["content"]["text"]["text"] is String) {
String text = (update.raw["message"]["content"]["text"]["text"] as String);
if (RegExp(r"^/alive$", caseSensitive: false).hasMatch(text)) {
// / use request if you wan't call api more easy and pretty like telegram bot api
await tg.callApi(
tdlibFunction: tdlib_scheme.TdlibFunction.sendMessage(
chat_id: chat_id,
options: tdlib_scheme.MessageSendOptions.create(
from_background: true
),
input_message_content: tdlib_scheme.InputMessageContent.create(
text: tdlib_scheme.FormattedText.create(
text: "Native Tdlib Scheme"
)
),
),
);

return await tg.request(
"sendMessage",
parameters: {"chat_id": chat_id, "text": "alive telegram client @azkadev"},
Expand Down
2 changes: 1 addition & 1 deletion example/dart/tdlib/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ packages:
name: telegram_client
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.63"
version: "0.3.64"
term_glyph:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/dart/tdlib/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ environment:
dev_dependencies:
lints: ^2.0.0
test: ^1.16.0
dependencies: { telegram_client: ^0.3.63 }
dependencies: { telegram_client: ^0.3.64 }
10 changes: 10 additions & 0 deletions example/dart/tdlib/test/test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:telegram_client/scheme/tdlib_scheme.dart' as tdlib_scheme;

void main() {
try {
var res = tdlib_scheme.TdlibFunction.sendMessage(chat_id: 1);
print(res.toString());
} catch (e) {
print(e);
}
}
Binary file not shown.

0 comments on commit e9db0dc

Please sign in to comment.