Skip to content

Commit 48a5da8

Browse files
committed
Let FutureSalt(s) attributes be plain integer instead of datetime values
1 parent 2df9f53 commit 48a5da8

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

pyrogram/api/core/future_salt.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from datetime import datetime
2019
from io import BytesIO
2120

2221
from .object import Object
@@ -30,15 +29,15 @@ class FutureSalt(Object):
3029

3130
QUALNAME = "FutureSalt"
3231

33-
def __init__(self, valid_since: int or datetime, valid_until: int or datetime, salt: int):
32+
def __init__(self, valid_since: int, valid_until: int, salt: int):
3433
self.valid_since = valid_since
3534
self.valid_until = valid_until
3635
self.salt = salt
3736

3837
@staticmethod
3938
def read(b: BytesIO, *args) -> "FutureSalt":
40-
valid_since = datetime.fromtimestamp(Int.read(b))
41-
valid_until = datetime.fromtimestamp(Int.read(b))
39+
valid_since = Int.read(b)
40+
valid_until = Int.read(b)
4241
salt = Long.read(b)
4342

4443
return FutureSalt(valid_since, valid_until, salt)

pyrogram/api/core/future_salts.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from datetime import datetime
2019
from io import BytesIO
2120

2221
from . import FutureSalt
@@ -31,15 +30,15 @@ class FutureSalts(Object):
3130

3231
QUALNAME = "FutureSalts"
3332

34-
def __init__(self, req_msg_id: int, now: int or datetime, salts: list):
33+
def __init__(self, req_msg_id: int, now: int, salts: list):
3534
self.req_msg_id = req_msg_id
3635
self.now = now
3736
self.salts = salts
3837

3938
@staticmethod
4039
def read(b: BytesIO, *args) -> "FutureSalts":
4140
req_msg_id = Long.read(b)
42-
now = datetime.fromtimestamp(Int.read(b))
41+
now = Int.read(b)
4342

4443
count = Int.read(b)
4544
salts = [FutureSalt.read(b) for _ in range(count)]

pyrogram/session/session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ def next_salt(self):
350350

351351
# Seconds to wait until middle-overlap, which is
352352
# 15 minutes before/after the current/next salt end/start time
353-
dt = (self.current_salt.valid_until - now).total_seconds() - 900
353+
valid_until = datetime.fromtimestamp(self.current_salt.valid_until)
354+
dt = (valid_until - now).total_seconds() - 900
354355

355356
log.debug("Current salt: {} | Next salt in {:.0f}m {:.0f}s ({})".format(
356357
self.current_salt.salt,

0 commit comments

Comments
 (0)