|
| 1 | +/* <!-- START LICENSE --> |
| 2 | +
|
| 3 | +
|
| 4 | +This Software / Program / Source Code Created By Developer From Company GLOBAL CORPORATION |
| 5 | +Social Media: |
| 6 | +
|
| 7 | + - Youtube: https://youtube.com/@Global_Corporation |
| 8 | + - Github: https://github.com/globalcorporation |
| 9 | + - TELEGRAM: https://t.me/GLOBAL_CORP_ORG_BOT |
| 10 | +
|
| 11 | +All code script in here created 100% original without copy / steal from other code if we copy we add description source at from top code |
| 12 | +
|
| 13 | +If you wan't edit you must add credit me (don't change) |
| 14 | +
|
| 15 | +If this Software / Program / Source Code has you |
| 16 | +
|
| 17 | +Jika Program ini milik anda dari hasil beli jasa developer di (Global Corporation / apapun itu dari turunan itu jika ada kesalahan / bug / ingin update segera lapor ke sub) |
| 18 | +
|
| 19 | +Misal anda beli Beli source code di Slebew CORPORATION anda lapor dahulu di slebew jangan lapor di GLOBAL CORPORATION! |
| 20 | +
|
| 21 | +Jika ada kendala program ini (Pastikan sebelum deal project tidak ada negosiasi harga) |
| 22 | +Karena jika ada negosiasi harga kemungkinan |
| 23 | +
|
| 24 | +1. Software Ada yang di kurangin |
| 25 | +2. Informasi tidak lengkap |
| 26 | +3. Bantuan Tidak Bisa remote / full time (Ada jeda) |
| 27 | +
|
| 28 | +Sebelum program ini sampai ke pembeli developer kami sudah melakukan testing |
| 29 | +
|
| 30 | +jadi sebelum nego kami sudah melakukan berbagai konsekuensi jika nego tidak sesuai ? |
| 31 | +Bukan maksud kami menipu itu karena harga yang sudah di kalkulasi + bantuan tiba tiba di potong akhirnya bantuan / software kadang tidak lengkap |
| 32 | +
|
| 33 | +
|
| 34 | +<!-- END LICENSE --> */ |
| 35 | +// ignore_for_file: empty_catches, unnecessary_brace_in_string_interps |
| 36 | + |
| 37 | +import 'dart:convert'; |
| 38 | + |
| 39 | +import 'package:general_lib/fork/mason_logger/mason_logger.dart'; |
| 40 | +import 'package:general_lib/general_lib.dart'; |
| 41 | +import 'package:telegram_client/telegram_client.dart'; |
| 42 | +import 'package:io_universe/io_universe.dart'; |
| 43 | + |
| 44 | +Logger logger = Logger(); |
| 45 | +void main(List<String> args) async { |
| 46 | + TelegramClient telegramClient = TelegramClient(); |
| 47 | + telegramClient.ensureInitialized(); |
| 48 | + telegramClient.on( |
| 49 | + event_name: telegramClient.event_update, |
| 50 | + onUpdate: (updateTelegramClient) async { |
| 51 | + try { |
| 52 | + final update = await updateTelegramClient.update; |
| 53 | + if (update == null) { |
| 54 | + return; |
| 55 | + } |
| 56 | + |
| 57 | + // ignore: dead_code |
| 58 | + if (update["@type"] == "updateAuthorizationState") { |
| 59 | + if (update["authorization_state"] is Map) { |
| 60 | + Map authorizationState = update["authorization_state"]; |
| 61 | + if (authorizationState["@type"] == |
| 62 | + "authorizationStateWaitPhoneNumber") { |
| 63 | + final token = logger.prompt("token?: "); |
| 64 | + Map res = await telegramClient.invoke( |
| 65 | + parameters: { |
| 66 | + "@type": "checkAuthenticationBotToken", |
| 67 | + "token": token, |
| 68 | + }, |
| 69 | + telegramClientData: updateTelegramClient.telegramClientData, |
| 70 | + ); |
| 71 | + print(res); |
| 72 | + } |
| 73 | + |
| 74 | + if (authorizationState["@type"] == "authorizationStateWaitCode") { |
| 75 | + Map res = await telegramClient.invoke( |
| 76 | + parameters: { |
| 77 | + "@type": "checkAuthenticationCode", |
| 78 | + "code": "xxxxx", |
| 79 | + }, |
| 80 | + telegramClientData: updateTelegramClient.telegramClientData, |
| 81 | + ); |
| 82 | + print(res); |
| 83 | + } |
| 84 | + |
| 85 | + if (authorizationState["@type"] == "authorizationStateReady") { |
| 86 | + Map getMe = await telegramClient.invoke( |
| 87 | + parameters: { |
| 88 | + "@type": "getMe", |
| 89 | + }, |
| 90 | + telegramClientData: updateTelegramClient.telegramClientData, |
| 91 | + ); |
| 92 | + getMe.printPretty(); |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + if (update["message"] is Map) { |
| 97 | + update.printPretty(); |
| 98 | + } |
| 99 | + } catch (e, stack) { |
| 100 | + print("${e} ${stack}"); |
| 101 | + } |
| 102 | + }, |
| 103 | + onError: (error, stackTrace) {}, |
| 104 | + ); |
| 105 | + await telegramClient.tdlib.closeClients(); |
| 106 | + final res = await telegramClient.tdlib |
| 107 | + .createclient(clientId: telegramClient.tdlib.td_create_client_id()); |
| 108 | + res.printPretty(); |
| 109 | + |
| 110 | + stdin.listen((event) async { |
| 111 | + try { |
| 112 | + final text = utf8.decode(event).trim(); |
| 113 | + await telegramCommand(text: text, telegramClient: telegramClient); |
| 114 | + } catch (e, stack) { |
| 115 | + print("${e} ${stack}"); |
| 116 | + } |
| 117 | + }); |
| 118 | +} |
| 119 | + |
| 120 | +Future<void> telegramCommand({ |
| 121 | + required String text, |
| 122 | + required TelegramClient telegramClient, |
| 123 | +}) async { |
| 124 | + TelegramClientData telegramClientData = TelegramClientData.tdlib( |
| 125 | + tdlib_client_id: telegramClient.tdlib.first_client_id); |
| 126 | + if (text == "getForumTopics") { |
| 127 | + final chat = await telegramClient.request( |
| 128 | + parameters: { |
| 129 | + "@type": "getChat", |
| 130 | + "chat_id": "@DEVELOPER_GLOBAL_PUBLIC", |
| 131 | + }, |
| 132 | + telegramClientData: telegramClientData, |
| 133 | + ); |
| 134 | + chat.printPretty(); |
| 135 | + final result = await telegramClient.invoke( |
| 136 | + parameters: { |
| 137 | + "@type": "getForumTopics", |
| 138 | + "chat_id": chat["result"]["id"], |
| 139 | + "limit": 100, |
| 140 | + }, |
| 141 | + telegramClientData: telegramClientData, |
| 142 | + ); |
| 143 | + result.printPretty(); |
| 144 | + |
| 145 | + await telegramClient.request(parameters: { |
| 146 | + "@type": "sendMessage", |
| 147 | + "chat_id": chat["result"]["id"], |
| 148 | + "message_thread_id": 45, |
| 149 | + "text": "hello", |
| 150 | + }, telegramClientData: telegramClientData); |
| 151 | + } |
| 152 | + if (text == "getForumTopic") { |
| 153 | + final chat = await telegramClient.request( |
| 154 | + parameters: { |
| 155 | + "@type": "getChat", |
| 156 | + "chat_id": "@DEVELOPER_GLOBAL_PUBLIC", |
| 157 | + }, |
| 158 | + telegramClientData: telegramClientData, |
| 159 | + ); |
| 160 | + chat.printPretty(); |
| 161 | + // final result = await telegramClient.invoke( |
| 162 | + // parameters: { |
| 163 | + // "@type": "getForumTopic", |
| 164 | + // "chat_id": chat["result"]["id"], |
| 165 | + // "message_thread_id": TgUtils.messageApiToTdlib(45), |
| 166 | + // }, |
| 167 | + // telegramClientData: telegramClientData, |
| 168 | + // ); |
| 169 | + // result.printPretty(); |
| 170 | + |
| 171 | + await telegramClient.request(parameters: { |
| 172 | + "@type": "sendMessage", |
| 173 | + "chat_id": chat["result"]["id"], |
| 174 | + "message_thread_id": 3637, |
| 175 | + "text": "Hell New", |
| 176 | + }, telegramClientData: telegramClientData); |
| 177 | + } |
| 178 | +} |
0 commit comments