strize raw String properties for Telegram Objects

This commit is contained in:
leandrotoledo 2015-09-07 15:53:09 -03:00
parent cdcf2481ba
commit 69d705a99f
8 changed files with 21 additions and 17 deletions

View file

@ -49,12 +49,12 @@ class Audio(TelegramObject):
duration,
**kwargs):
# Required
self.file_id = file_id
self.file_id = str(file_id)
self.duration = int(duration)
# Optionals
self.performer = kwargs.get('performer', '')
self.title = kwargs.get('title', '')
self.mime_type = kwargs.get('mime_type', '')
self.performer = str(kwargs.get('performer', ''))
self.title = str(kwargs.get('title', ''))
self.mime_type = str(kwargs.get('mime_type', ''))
self.file_size = int(kwargs.get('file_size', 0))
@staticmethod

View file

@ -45,7 +45,7 @@ class Contact(TelegramObject):
first_name,
**kwargs):
# Required
self.phone_number = phone_number
self.phone_number = str(phone_number)
self.first_name = first_name
# Optionals
self.last_name = kwargs.get('last_name', '')

View file

@ -46,11 +46,11 @@ class Document(TelegramObject):
file_id,
**kwargs):
# Required
self.file_id = file_id
self.file_id = str(file_id)
# Optionals
self.thumb = kwargs.get('thumb')
self.file_name = kwargs.get('file_name', '')
self.mime_type = kwargs.get('mime_type', '')
self.file_name = str(kwargs.get('file_name', ''))
self.mime_type = str(kwargs.get('mime_type', ''))
self.file_size = int(kwargs.get('file_size', 0))
@staticmethod

View file

@ -22,10 +22,14 @@
class TelegramError(Exception):
"""This object represents a Telegram Error."""
@property
def message(self):
def __init__(self, message):
"""
Returns:
str:
"""
return self.args[0]
super(TelegramError, self).__init__()
self.message = message.split(':')[-1].strip().capitalize()
def __str__(self):
return '%s' % (self.message)

View file

@ -48,7 +48,7 @@ class Sticker(TelegramObject):
height,
**kwargs):
# Required
self.file_id = file_id
self.file_id = str(file_id)
self.width = int(width)
self.height = int(height)
# Optionals

View file

@ -39,7 +39,7 @@ class Update(TelegramObject):
update_id,
**kwargs):
# Required
self.update_id = update_id
self.update_id = int(update_id)
# Optionals
self.message = kwargs.get('message')

View file

@ -53,13 +53,13 @@ class Video(TelegramObject):
duration,
**kwargs):
# Required
self.file_id = file_id
self.file_id = str(file_id)
self.width = int(width)
self.height = int(height)
self.duration = int(duration)
# Optionals
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))
@staticmethod

View file

@ -44,10 +44,10 @@ class Voice(TelegramObject):
file_id,
**kwargs):
# Required
self.file_id = file_id
self.file_id = str(file_id)
# Optionals
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))
@staticmethod