mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-16 12:07:13 +00:00
Add WebHookInfo, GameHighScore
This commit is contained in:
parent
24f70bf9d5
commit
5874291b15
2 changed files with 51 additions and 0 deletions
19
aiogram/types/game_high_score.py
Normal file
19
aiogram/types/game_high_score.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from . import Deserializable
|
||||
from .user import User
|
||||
|
||||
|
||||
class GameHighScore(Deserializable):
|
||||
def __init__(self, position, user, score):
|
||||
self.position: int = position
|
||||
self.user: User = user
|
||||
self.score: int = score
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, raw_data):
|
||||
raw_data = cls.check_json(raw_data)
|
||||
|
||||
position = raw_data.get('position')
|
||||
user = User.deserialize(raw_data.get('user'))
|
||||
score = raw_data.get('score')
|
||||
|
||||
return GameHighScore(position, user, score)
|
||||
32
aiogram/types/webhook_info.py
Normal file
32
aiogram/types/webhook_info.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import datetime
|
||||
|
||||
from . import Deserializable
|
||||
|
||||
|
||||
class WebhookInfo(Deserializable):
|
||||
def __init__(self, url, has_custom_certificate, pending_update_count, last_error_date, last_error_message, max_connections, allowed_updates):
|
||||
self.url: str = url
|
||||
self.has_custom_certificate: bool = has_custom_certificate
|
||||
self.pending_update_count: int = pending_update_count
|
||||
self.last_error_date: int = last_error_date
|
||||
self.last_error_message: str = last_error_message
|
||||
self.max_connections: int = max_connections
|
||||
self.allowed_updates: [str] = allowed_updates
|
||||
|
||||
@classmethod
|
||||
def _parse_date(cls, unix_time):
|
||||
return datetime.datetime.fromtimestamp(unix_time)
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, raw_data):
|
||||
raw_data = cls.check_json(raw_data)
|
||||
|
||||
url = raw_data.get('url')
|
||||
has_custom_certificate = raw_data.get('has_custom_certificate')
|
||||
pending_update_count = raw_data.get('pending_update_count')
|
||||
last_error_date = cls._parse_date(raw_data.get('last_error_date'))
|
||||
last_error_message = raw_data.get('last_error_message')
|
||||
max_connections = raw_data.get('max_connections')
|
||||
allowed_updates = raw_data.get('allowed_updates')
|
||||
|
||||
return WebhookInfo(url, has_custom_certificate, pending_update_count, last_error_date, last_error_message, max_connections, allowed_updates)
|
||||
Loading…
Add table
Add a link
Reference in a new issue