mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 15:17:00 +01:00
strize raw String properties for Telegram Objects
This commit is contained in:
parent
cdcf2481ba
commit
69d705a99f
8 changed files with 21 additions and 17 deletions
|
@ -49,12 +49,12 @@ class Audio(TelegramObject):
|
||||||
duration,
|
duration,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
self.file_id = file_id
|
self.file_id = str(file_id)
|
||||||
self.duration = int(duration)
|
self.duration = int(duration)
|
||||||
# Optionals
|
# Optionals
|
||||||
self.performer = kwargs.get('performer', '')
|
self.performer = str(kwargs.get('performer', ''))
|
||||||
self.title = kwargs.get('title', '')
|
self.title = str(kwargs.get('title', ''))
|
||||||
self.mime_type = kwargs.get('mime_type', '')
|
self.mime_type = str(kwargs.get('mime_type', ''))
|
||||||
self.file_size = int(kwargs.get('file_size', 0))
|
self.file_size = int(kwargs.get('file_size', 0))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Contact(TelegramObject):
|
||||||
first_name,
|
first_name,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
self.phone_number = phone_number
|
self.phone_number = str(phone_number)
|
||||||
self.first_name = first_name
|
self.first_name = first_name
|
||||||
# Optionals
|
# Optionals
|
||||||
self.last_name = kwargs.get('last_name', '')
|
self.last_name = kwargs.get('last_name', '')
|
||||||
|
|
|
@ -46,11 +46,11 @@ class Document(TelegramObject):
|
||||||
file_id,
|
file_id,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
self.file_id = file_id
|
self.file_id = str(file_id)
|
||||||
# Optionals
|
# Optionals
|
||||||
self.thumb = kwargs.get('thumb')
|
self.thumb = kwargs.get('thumb')
|
||||||
self.file_name = kwargs.get('file_name', '')
|
self.file_name = str(kwargs.get('file_name', ''))
|
||||||
self.mime_type = kwargs.get('mime_type', '')
|
self.mime_type = str(kwargs.get('mime_type', ''))
|
||||||
self.file_size = int(kwargs.get('file_size', 0))
|
self.file_size = int(kwargs.get('file_size', 0))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -22,10 +22,14 @@
|
||||||
class TelegramError(Exception):
|
class TelegramError(Exception):
|
||||||
"""This object represents a Telegram Error."""
|
"""This object represents a Telegram Error."""
|
||||||
|
|
||||||
@property
|
def __init__(self, message):
|
||||||
def message(self):
|
|
||||||
"""
|
"""
|
||||||
Returns:
|
Returns:
|
||||||
str:
|
str:
|
||||||
"""
|
"""
|
||||||
return self.args[0]
|
super(TelegramError, self).__init__()
|
||||||
|
|
||||||
|
self.message = message.split(':')[-1].strip().capitalize()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return '%s' % (self.message)
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Sticker(TelegramObject):
|
||||||
height,
|
height,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
self.file_id = file_id
|
self.file_id = str(file_id)
|
||||||
self.width = int(width)
|
self.width = int(width)
|
||||||
self.height = int(height)
|
self.height = int(height)
|
||||||
# Optionals
|
# Optionals
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Update(TelegramObject):
|
||||||
update_id,
|
update_id,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
self.update_id = update_id
|
self.update_id = int(update_id)
|
||||||
# Optionals
|
# Optionals
|
||||||
self.message = kwargs.get('message')
|
self.message = kwargs.get('message')
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,13 @@ class Video(TelegramObject):
|
||||||
duration,
|
duration,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
self.file_id = file_id
|
self.file_id = str(file_id)
|
||||||
self.width = int(width)
|
self.width = int(width)
|
||||||
self.height = int(height)
|
self.height = int(height)
|
||||||
self.duration = int(duration)
|
self.duration = int(duration)
|
||||||
# Optionals
|
# Optionals
|
||||||
self.thumb = kwargs.get('thumb')
|
self.thumb = kwargs.get('thumb')
|
||||||
self.mime_type = kwargs.get('mime_type', '')
|
self.mime_type = str(kwargs.get('mime_type', ''))
|
||||||
self.file_size = int(kwargs.get('file_size', 0))
|
self.file_size = int(kwargs.get('file_size', 0))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -44,10 +44,10 @@ class Voice(TelegramObject):
|
||||||
file_id,
|
file_id,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
# Required
|
# Required
|
||||||
self.file_id = file_id
|
self.file_id = str(file_id)
|
||||||
# Optionals
|
# Optionals
|
||||||
self.duration = int(kwargs.get('duration', 0))
|
self.duration = int(kwargs.get('duration', 0))
|
||||||
self.mime_type = kwargs.get('mime_type', '')
|
self.mime_type = str(kwargs.get('mime_type', ''))
|
||||||
self.file_size = int(kwargs.get('file_size', 0))
|
self.file_size = int(kwargs.get('file_size', 0))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in a new issue