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, 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

View file

@ -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', '')

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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')

View file

@ -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

View file

@ -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