Skip to content

Commit

Permalink
added prebuild-tdlib and dep update
Browse files Browse the repository at this point in the history
  • Loading branch information
tejado committed Sep 23, 2023
1 parent 4f92efa commit 94d92d0
Show file tree
Hide file tree
Showing 11 changed files with 4,190 additions and 3,017 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Telegram Nearby Map uses OpenStreetMap and the official Telegram library to find the position of nearby users.

**Please note:** Telegram's API was updated a while ago to make nearby user distances less precise, preventing exact location calculations. Therefore, Telegram Nearby Map displays users nearby, but does not show their exact location.

Inspired by [Ahmed's blog post](https://blog.ahmed.nyc/2021/01/if-you-use-this-feature-on-telegram.html) and a [Hacker News discussion](https://news.ycombinator.com/item?id=25641399).
Developed by [github.com/tejado](https://github.com/tejado).

Expand All @@ -24,11 +26,13 @@ Requirements: node.js and an Telegram account
6. Look carefully at the output: you will need to confirm your Telegram login
7. Go to http:https://localhost:3000 and have fun

## Dependencies
To avoid that you have to build TDLib yourself (https://github.com/tdlib/td#building), I added [tdlib.native](https://github.com/ForNeVeR/tdlib.native/releases) in the lib/tdlib folder. Please note that this is an external dependency that has not been fully reviewed by me!

## Changelog

### 2023-09-23
- Switched to [prebuild-tdlib](https://github.com/Bannerets/tdl)
- Updated all dependencies
- Bugfix of the search distance field

### 2021-11-13
- Added [tdlib.native](https://github.com/ForNeVeR/tdlib.native/releases) for Linux (now it works in GitHub Codespaces)
- Updated all dependencies
Expand Down
Binary file removed lib/tdlib/libcrypto-1_1-x64.dll
Binary file not shown.
Binary file removed lib/tdlib/libssl-1_1-x64.dll
Binary file not shown.
Binary file removed lib/tdlib/libtdjson.dylib
Binary file not shown.
Binary file removed lib/tdlib/libtdjson.so
Binary file not shown.
Binary file removed lib/tdlib/tdjson.dll
Binary file not shown.
Binary file removed lib/tdlib/zlib1.dll
Binary file not shown.
23 changes: 7 additions & 16 deletions lib/telegram-nearby.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { Client } = require('tdl');
const { TDLib } = require('tdl-tdlib-addon');
const tdl = require('tdl');
const { to } = require('await-to-js');
const path = require('path');
const log = require('./logger.js');
const { getTdjson } = require('prebuilt-tdlib')

function sleep(ms) {
return new Promise((resolve) => {
Expand All @@ -12,25 +12,16 @@ function sleep(ms) {

class TelegramNearby {
constructor(apiId, apiHash) {
let root = process.cwd();
process.chdir('lib/tdlib/');

let tdLibraryPath = "./libtdjson.so";
if (process.platform === "win32") {
tdLibraryPath = "tdjson.dll";
} else if(process.platform === "darwin") {
tdLibraryPath = "./libtdjson.dylib";
}

console.log(`Current WD: ${process.cwd()}`)
const tdLibraryPath = getTdjson();
console.log(`Lib Path: ${tdLibraryPath}`)
this.client = new Client(new TDLib(tdLibraryPath), {

tdl.configure({ tdjson: tdLibraryPath })

this.client = tdl.createClient({
apiId: apiId,
apiHash: apiHash,
});

process.chdir(root);

this.client.connectAndLogin();
this.client.on('error', log.warn);
}
Expand Down
Loading

0 comments on commit 94d92d0

Please sign in to comment.