Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added JSON logger and coordinates stored with mongo #36

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c9d3294
c
SupremoIntra Apr 28, 2022
24c03db
2804_8.50
SupremoIntra Apr 28, 2022
8988992
a
SupremoIntra Apr 28, 2022
1fcc3ef
Update README.md
SupremoIntra Apr 28, 2022
0ff4241
first
SupremoIntra Apr 29, 2022
29f231c
first
SupremoIntra Apr 29, 2022
f38ee7c
Merge branch 'main' of https://github.com/SupremoIntra/telegram-nearb…
SupremoIntra Apr 29, 2022
be0dcb7
29-04
SupremoIntra Apr 29, 2022
9d5b3e5
13/05
SupremoIntra May 13, 2022
22ec483
19.05
SupremoIntra May 19, 2022
a790d05
26.05
SupremoIntra May 26, 2022
f138a32
05/06
SupremoIntra Jun 5, 2022
91f874c
logger e mongo
SupremoIntra Jun 5, 2022
2bb6384
Merge branch 'main' of https://github.com/SupremoIntra/telegram-nearb…
SupremoIntra Jun 5, 2022
390afbe
10/06
SupremoIntra Jun 11, 2022
add2b44
11/06
SupremoIntra Jun 11, 2022
e0d6117
Merge branch 'main' of https://github.com/SupremoIntra/telegram-nearb…
SupremoIntra Jun 11, 2022
3b13b62
11/06
SupremoIntra Jun 11, 2022
476afaa
Merge branch 'main' of https://github.com/SupremoIntra/telegram-nearb…
SupremoIntra Jun 11, 2022
3992cfb
13/06
SupremoIntra Jun 13, 2022
1c9e3f3
13/06
SupremoIntra Jun 13, 2022
69fc86b
Merge branch 'main' of https://github.com/SupremoIntra/telegram-nearb…
SupremoIntra Jun 13, 2022
55b8e40
gamma funzionante 13.06
SupremoIntra Jun 13, 2022
eaa20e7
Merge branch 'main' of https://github.com/SupremoIntra/telegram-nearb…
SupremoIntra Jun 21, 2022
b291e42
21/06 home
SupremoIntra Jun 21, 2022
0812972
21/06 news
SupremoIntra Jun 21, 2022
5d88186
22.06 - no warn, preloader, news
SupremoIntra Jun 22, 2022
578160b
24/06_before_possibile_disastro
SupremoIntra Jun 24, 2022
e094eb7
24/06 display map point not trilaterated
SupremoIntra Jun 24, 2022
f33c772
26/06_ultime modifiche
SupremoIntra Jun 26, 2022
6e475e4
28.06_ultime_piccole_correzioni
SupremoIntra Jun 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,19 @@ bot.log
config.js

web-build/*
!web-build/no_photo.png
!web-build/no_photo.png
<<<<<<< HEAD
package.json
lib/jsonlog.json
=======
package-lock.json
package-lock.json
package.json
package-lock.json
package-lock.json
package-lock.json
package.json
>>>>>>> 3992cfb1937a0f7eb6ab848d3270df9e8bf40687
package-lock.json
package.json
lib/jsonlog.json
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

35 changes: 0 additions & 35 deletions README.md

This file was deleted.

15 changes: 0 additions & 15 deletions config.example.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/jsonlog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"lon":31.254278345842916,"lat":50.73295093207716,"_id":"62b86812d583de680e2e002c"},{"lon":31.25876992226351,"lat":50.73295093207716,"_id":"62b86836d583de680e2e002d"},{"lon":31.25876992226351,"lat":50.735793725011234,"_id":"62b8684fd583de680e2e002e"},{"lon":31.254278345842916,"lat":50.735793725011234,"_id":"62b86869d583de680e2e002f"},{"lon":31.249786769422318,"lat":50.735793725011234}]
6 changes: 4 additions & 2 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var logger = createLogger({
format: 'DD-MM-YYYY hh:mm:ss A',
}),
format.printf((nfo) => {


return `${nfo.timestamp} - ${nfo.level}: ${nfo.message}`;
})
),
Expand All @@ -35,7 +37,7 @@ var logger = createLogger({
// Extend logger object to properly log 'Error' types
var origLog = logger.log;

logger.log = function (level, msg) {
logger.log = function(level, msg) {
if (msg instanceof Error) {
var args = Array.prototype.slice.call(arguments);
args[1] = msg.stack;
Expand All @@ -55,4 +57,4 @@ logger.log = function (level, msg) {
log.fatal('testing')
*/

module.exports = logger;
module.exports = logger;
29 changes: 15 additions & 14 deletions lib/telegram-nearby.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TelegramNearby {
let tdLibraryPath = "./libtdjson.so";
if (process.platform === "win32") {
tdLibraryPath = "tdjson.dll";
} else if(process.platform === "darwin") {
} else if (process.platform === "darwin") {
tdLibraryPath = "./libtdjson.dylib";
}

Expand All @@ -41,18 +41,18 @@ class TelegramNearby {

[err, nearbyChats] = await to(
this.client
.invoke({
_: 'searchChatsNearby',
location: {
latitude: position.lat,
longitude: position.lon,
horizontal_accuracy: Math.random() * (10.12 - 1.02) + 1.02,
},
})
.catch((err) => {
log.warn(err.stack);
return null;
})
.invoke({
_: 'searchChatsNearby',
location: {
latitude: position.lat,
longitude: position.lon,
horizontal_accuracy: Math.random() * (10.12 - 1.02) + 1.02,
},
})
.catch((err) => {
log.warn(err.stack);
return null;
})
);

if (err) {
Expand Down Expand Up @@ -109,6 +109,7 @@ class TelegramNearby {
}
}


// avoid rate-limiting (?)
sleep(500);
}
Expand All @@ -117,4 +118,4 @@ class TelegramNearby {
}
}

module.exports = TelegramNearby;
module.exports = TelegramNearby;
Loading