mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +00:00
Let FutureSalt(s) attributes be plain integer instead of datetime values
This commit is contained in:
parent
2df9f53e54
commit
48a5da8958
@ -16,7 +16,6 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from .object import Object
|
from .object import Object
|
||||||
@ -30,15 +29,15 @@ class FutureSalt(Object):
|
|||||||
|
|
||||||
QUALNAME = "FutureSalt"
|
QUALNAME = "FutureSalt"
|
||||||
|
|
||||||
def __init__(self, valid_since: int or datetime, valid_until: int or datetime, salt: int):
|
def __init__(self, valid_since: int, valid_until: int, salt: int):
|
||||||
self.valid_since = valid_since
|
self.valid_since = valid_since
|
||||||
self.valid_until = valid_until
|
self.valid_until = valid_until
|
||||||
self.salt = salt
|
self.salt = salt
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read(b: BytesIO, *args) -> "FutureSalt":
|
def read(b: BytesIO, *args) -> "FutureSalt":
|
||||||
valid_since = datetime.fromtimestamp(Int.read(b))
|
valid_since = Int.read(b)
|
||||||
valid_until = datetime.fromtimestamp(Int.read(b))
|
valid_until = Int.read(b)
|
||||||
salt = Long.read(b)
|
salt = Long.read(b)
|
||||||
|
|
||||||
return FutureSalt(valid_since, valid_until, salt)
|
return FutureSalt(valid_since, valid_until, salt)
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from . import FutureSalt
|
from . import FutureSalt
|
||||||
@ -31,7 +30,7 @@ class FutureSalts(Object):
|
|||||||
|
|
||||||
QUALNAME = "FutureSalts"
|
QUALNAME = "FutureSalts"
|
||||||
|
|
||||||
def __init__(self, req_msg_id: int, now: int or datetime, salts: list):
|
def __init__(self, req_msg_id: int, now: int, salts: list):
|
||||||
self.req_msg_id = req_msg_id
|
self.req_msg_id = req_msg_id
|
||||||
self.now = now
|
self.now = now
|
||||||
self.salts = salts
|
self.salts = salts
|
||||||
@ -39,7 +38,7 @@ class FutureSalts(Object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def read(b: BytesIO, *args) -> "FutureSalts":
|
def read(b: BytesIO, *args) -> "FutureSalts":
|
||||||
req_msg_id = Long.read(b)
|
req_msg_id = Long.read(b)
|
||||||
now = datetime.fromtimestamp(Int.read(b))
|
now = Int.read(b)
|
||||||
|
|
||||||
count = Int.read(b)
|
count = Int.read(b)
|
||||||
salts = [FutureSalt.read(b) for _ in range(count)]
|
salts = [FutureSalt.read(b) for _ in range(count)]
|
||||||
|
@ -350,7 +350,8 @@ class Session:
|
|||||||
|
|
||||||
# Seconds to wait until middle-overlap, which is
|
# Seconds to wait until middle-overlap, which is
|
||||||
# 15 minutes before/after the current/next salt end/start time
|
# 15 minutes before/after the current/next salt end/start time
|
||||||
dt = (self.current_salt.valid_until - now).total_seconds() - 900
|
valid_until = datetime.fromtimestamp(self.current_salt.valid_until)
|
||||||
|
dt = (valid_until - now).total_seconds() - 900
|
||||||
|
|
||||||
log.debug("Current salt: {} | Next salt in {:.0f}m {:.0f}s ({})".format(
|
log.debug("Current salt: {} | Next salt in {:.0f}m {:.0f}s ({})".format(
|
||||||
self.current_salt.salt,
|
self.current_salt.salt,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user