telegram_client 0.5.19 telegram_client: ^0.5.19 copied to clipboard
Telegram Client Lightweight, blazing and Highly customizable for make application telegram based tdlib, mtproto, or bot api and support server side.
import 'package:galaxeus_lib/galaxeus_lib.dart';
import 'package:telegram_client/telegram_client.dart';
void main(List<String> args) async {
/// ignore: unused_local_variable
TelegramClient tg = TelegramClient();
tg.on(
event_name: tg.event_update,
onUpdate: (UpdateTelegramClient updateTelegramClient) async {
if (updateTelegramClient.telegramClientData.telegramClientType ==
TelegramClientType.tdlib) {
if (updateTelegramClient.rawData["@type"] == "updateConnectionState") {
var res = await updateTelegramClient.tg.invoke(
parameters: {
"@type": "getAuthorizationState",
},
telegramClientData: updateTelegramClient.telegramClientData,
);
print(res.rawData.toStringifyPretty(2));
}
// ignore: unused_local_variable
Map? update = await updateTelegramClient.update;
if (updateTelegramClient.rawData["@type"] == "updateNewMessage") {
Map message = updateTelegramClient.rawData["message"];
print(message.toStringifyPretty(2));
}
}
},
onError: (error, stackTrace) {},
);
await tg.init(
pathTdlib: TgUtils.pathTdlib(),
);
await tg.tdlib.initIsolate();
}