MAX & TT: теперь в качестве страны локации используется настоящая страна пользователя, а также зафиксировал версии библиотек в зависимостях

This commit is contained in:
Alexey Polyakov
2026-04-28 18:22:16 +03:00
parent c716520ca4
commit 89f1fefa31
11 changed files with 61 additions and 28 deletions

View File

@@ -1,5 +1,8 @@
import json
import time
import os
import geoip2.database
class Tools:
@@ -546,3 +549,15 @@ class Tools:
presence[int(contact_id)] = {"seen": int(lastseen)}
return presence
def get_geo(self, ip, db_path):
"""
Получение страны пользователя по его айпи адресу
Используется во время запуска сессии
"""
try:
with geoip2.database.Reader(db_path) as reader:
response = reader.country(ip)
return response.country.name or "Localhost Federation"
except Exception:
return "Localhost Federation"