python-telegram-bot/telegram/sticker.py

30 lines
869 B
Python
Raw Normal View History

2015-07-08 04:52:12 +02:00
#!/usr/bin/env python
class Sticker(object):
def __init__(self, **kwargs):
param_defaults = {
'file_id': None,
'width': None,
'height': None,
'thumb': None,
'file_size': None
}
for (param, default) in param_defaults.iteritems():
setattr(self, param, kwargs.get(param, default))
@staticmethod
def newFromJsonDict(data):
if 'thumb' in data:
from telegram import PhotoSize
thumb = PhotoSize.newFromJsonDict(data['thumb'])
else:
thumb = None
return Sticker(file_id=data.get('file_id', None),
width=data.get('width', None),
height=data.get('height', None),
thumb=thumb,
file_size=data.get('file_size', None))