Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
azkadev committed Feb 8, 2022
1 parent a99b293 commit 7d7af08
Show file tree
Hide file tree
Showing 6 changed files with 621 additions and 170 deletions.
4 changes: 2 additions & 2 deletions node-js/tdl-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "tdl-lib",
"version": "0.0.27",
"version": "0.0.60",
"description": "",
"main": "src/js/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"author": "azkadev",
"license": "ISC",
"dependencies": {
"tdl": "^7.0.0",
Expand Down
30 changes: 20 additions & 10 deletions node-js/tdl-lib/src/js/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
var { Client } = require("tdl");
var { TDLib } = require("tdl-tdlib-addon");
var lib = require("./index");
var folder = process.cwd();
class telegram {
constructor(api_id, api_hash, pathDb = "./client/", pathTdLib = "./libtdjson.so") {
constructor(pathDb = "./client/", client= {}) {
if (typeof client != "object"){
client = {};
}
if (!client){
client = {};
}
var option = {
"apiId": api_id,
"apiHash": api_hash,
"apiId": 1917085,
"apiHash": "a612212e6ac3ff1f97a99b2e0f050894",
"databaseDirectory": `${folder}/${pathDb}`,
"filesDirectory": `${folder}/${pathDb}`,
"skipOldUpdates": true,
Expand All @@ -15,11 +20,14 @@ class telegram {
"enable_storage_optimizer": true,
"system_language_code": 'en',
"application_version": "v1",
"device_model": "node js",
"device_model": "Desktop",
"system_version": "v5"
}
},
"pathTdLib": `${folder}/./libtdjson.so`,
...client
};
var tdlib = new TDLib(`${folder}/${pathTdLib}`);
var tdlib = new TDLib(option["pathTdLib"]);
this.option = option;
this.client = new Client(tdlib, option);
}

Expand All @@ -32,13 +40,13 @@ class telegram {
this.client.connect().catch(e => {
console.log(e.message);
return false;
})
});
this.client.login(() => {
type: 'user'
}).catch(e => {
console.log(e.message);
return false;
})
});
return true;
} catch (e) {
console.log(e.message);
Expand All @@ -60,13 +68,15 @@ class telegram {
async on(type, callback) {
if (RegExp("^update$", "i").exec(type)) {
var clients = this.client;
var option = this.option;
this.client.on("update", async function (updateTd) {
var lib = require("./index");
var tg = new lib.telegramApi(clients);
var updateApi = new lib.updateApi(tg);
var update = await updateApi.update(updateTd);
return callback(update, updateTd);
return callback(update, updateTd, tg, option);
});

}
if (RegExp("^raw$", "i").exec(type)) {
this.client.on("update", async function (updateTd) {
Expand Down
Loading

0 comments on commit 7d7af08

Please sign in to comment.