Skip to content

Commit

Permalink
udpate
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Jan 27, 2022
1 parent bbaabdc commit c9d6c51
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 13 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ Telegram client is a library to make it easier for you to build your own telegra

### Docs

- [Dart / Flutter](https://github.com/azkadev/telegram_client/tree/main/dart/telegram_client/docs) - [Wiki]()
- [Node JS](https://github.com/azkadev/telegram_client)
- [Script Google](https://github.com/azkadev/telegram_client)
- Just Read On [Wiki](https://github.com/azkadev/telegram_client/wiki)

### Update
<!-- replacer_start -->
Expand All @@ -21,14 +19,14 @@ Telegram client is a library to make it easier for you to build your own telegra
- ✅️ support bot and userbot
- ✅️ support telegram-bot-api local server
- ✅️ support telegram database library ( Tdlib )
- 🔜️ Add more Api Humanize pretty update and method api humanize
- ️ Add more Api Humanize pretty update and method api humanize

- ```telegram client node```
- ✅️ support multi token ( bot / userbot )
- ✅️ support bot and userbot
- ✅️ support telegram-bot-api local server
- ✅️ support telegram database library ( [TDLIB](https://github.com/azkadev/telegram_client/tree/main/node-js/tdl-lib) )
- 🔜️ Add more Api Humanize pretty update and method api humanize
- ️ Add more Api Humanize pretty update and method api humanize

- ```telegram client google apps script```
- ✅️ support multi token ( bot / userbot )
Expand Down
Binary file modified dart/telegram_client/bin/bot/td.binlog
Binary file not shown.
82 changes: 82 additions & 0 deletions dart/telegram_client/bin/event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2019, iMeshAcademy authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:eventify/eventify.dart';
import 'dart:async';

Future parseStores(Object config) {
return new Future(() {
print("Inside the future.");
Map<String, Map<String, dynamic>> storeConfigs =
config as Map<String, Map<String, dynamic>>;
storeConfigs.forEach((str, val) {
print("${str}:${val}");
val.forEach((store, details) {
print("${store}:${details}");
});
});
});
}

void main() {
Map<String, dynamic> data = {
"stores": {
"store1": {"generator": 1, "config": {}},
"store2": {"generator": 2, "config": {}}
},
"models": {
"model1": {"generator": 1, "name": "modelel1", "linkedStore": "store1"}
}
};

Function parseModels = (config) {};

print(data.runtimeType);
data.forEach((key, val) {
switch (key) {
case "stores":
parseStores(val).then((res) {
print("Store is parsed");
});
break;
case "models":
parseModels(val);
break;
default:
}
});

print("After the loop!!");

EventEmitter emitter = new EventEmitter();
emitter.on("test", null, (ev, context) {
print("${ev.eventName} - ${ev.eventData}");
});

emitter.emit("test", null, "Test data");

int count = 0;

ExtendedEmitter timer = new ExtendedEmitter();
timer.on("timer", null, (ev, context) {
count++;
print("Received ${ev.eventName} event from ${ev.sender}!");
if (count == 10) {
Timer t = ev.eventData as Timer;
t.cancel();
}
});

timer.doSomeOperation();
}

class ExtendedEmitter extends EventEmitter {
void timerCallback(Timer timer) {
emit("timer", this, timer);
}

void doSomeOperation() {
Timer.periodic(Duration(seconds: 1), timerCallback);
}
}
2 changes: 1 addition & 1 deletion dart/telegram_client/bin/testtdlibbot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void main() {
}
};
var anu = tdl.clientSend(option);
print(JSON.stringify(anu, null, 2));
print(JSON.stringify(anu, null,2));
}
}
});
Expand Down
27 changes: 20 additions & 7 deletions dart/telegram_client/lib/tdlib/tdlib.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Tdlib {
_optionDefault[key.toString().toLowerCase()] = value;
});

clientSend({
clientRequest({
"@type": "setLogVerbosityLevel",
"new_verbosity_level": _optionDefault['new_verbosity_level']
});
Expand Down Expand Up @@ -103,10 +103,12 @@ class Tdlib {
'td_json_client_destroy')
.asFunction();
}


Map clientSend(jsonsend) {
clientSend(jsonsend) {
_client_send(client, convert.json.encode(jsonsend).toNativeUtf8());

clienReceive(1.0);
clienReceive(1.0);
var receive = clienReceive(1.0);
if (typeData(receive) == "string") {
return convert.json.decode(receive);
Expand All @@ -115,6 +117,17 @@ class Tdlib {
}
}

clientRequest(jsonsend) {
_client_send(client, convert.json.encode(jsonsend).toNativeUtf8());
var receive = clienReceive(1.0);
if (typeData(receive) == "string") {
return convert.json.decode(receive);
} else {
return {};
}
}


void clientDestroy() {
return _client_destroy(client);
}
Expand Down Expand Up @@ -145,7 +158,7 @@ class Tdlib {
"@type": 'setTdlibParameters',
'parameters': _optionDefault
};
clientSend(optin);
clientRequest(optin);
/*
clientSend({
'@type': 'setDatabaseEncryptionKey',
Expand All @@ -155,7 +168,7 @@ class Tdlib {
}

if (authState["@type"] == "authorizationStateWaitEncryptionKey") {
clientSend({
clientRequest({
"@type": 'checkDatabaseEncryptionKey',
'encryption_key': _optionDefault["database_key"]
});
Expand All @@ -164,9 +177,9 @@ class Tdlib {
}
if (updateOrigin["@type"] == "updateConnectionState" &&
updateOrigin["state"]["@type"] == "connectionStateReady") {
clientSend({
clientRequest({
"@type": "checkAuthenticationBotToken",
"token": "5059078949:"
"token": "5059078949:AAF0lFQGmcWyDjLPaCMYc6Xcp3kgcS_lFQU"
});
}
callback(updateOrigin);
Expand Down
7 changes: 7 additions & 0 deletions dart/telegram_client/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
eventify:
dependency: "direct main"
description:
name: eventify
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
ffi:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions dart/telegram_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ dev_dependencies:
lints: ^1.0.0

dependencies:
eventify: ^1.0.0
ffi: ^1.1.2
switchscript: ^0.0.1

0 comments on commit c9d6c51

Please sign in to comment.