Skip to content

Commit

Permalink
Add limited_seconds to TlObject.
Browse files Browse the repository at this point in the history
  • Loading branch information
AYMENJD committed Jan 13, 2025
1 parent 7d1cb89 commit 6b80732
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion generate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def generate_self_args(args, classes):
arg_type = generate_union_types(arg_type, arg_data["type"], classes)

args_list.append(
f"self.{arg_name}: {arg_type} = {arg_value}\n{indent * 2}r\"\"\"{escape_quotes(arg_data['description'])}\"\"\""
f'self.{arg_name}: {arg_type} = {arg_value}\n{indent * 2}r"""{escape_quotes(arg_data["description"])}"""'
)
if not args_list:
return "pass"
Expand Down Expand Up @@ -403,6 +403,13 @@ def __bool__(self):
def is_error(self): # for backward compatibility
return isinstance(self, Error)
@property
def limited_seconds(self):
if self.is_error and self.code == 429:
return pytdbot.utils.get_retry_after_time(self.message)
else:
return 0
def getType(self):
raise NotImplementedError
Expand Down
9 changes: 8 additions & 1 deletion pytdbot/types/td_types/types.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Union, Literal, List
from base64 import b64decode
from .bound_methods import (
MessageBoundMethods,
FileBoundMethods,
MessageBoundMethods,
CallbackQueryBoundMethods,
)
import pytdbot
Expand All @@ -27,6 +27,13 @@ def __bool__(self):
def is_error(self): # for backward compatibility
return isinstance(self, Error)

@property
def limited_seconds(self):
if self.is_error and self.code == 429:
return pytdbot.utils.get_retry_after_time(self.message)
else:
return 0

def getType(self):
raise NotImplementedError

Expand Down

0 comments on commit 6b80732

Please sign in to comment.