python-telegram-bot/telegram/base.py
2015-07-19 23:25:44 -03:00

28 lines
512 B
Python

#!/usr/bin/env python
import json
from abc import ABCMeta, abstractmethod
class TelegramObject(object):
"""Base class for most telegram object"""
__metaclass__ = ABCMeta
def __str__(self):
return str(self.to_dict())
def __getitem__(self, item):
return self.__dict__[item]
@staticmethod
def de_json(data):
raise NotImplementedError
def to_json(self):
return json.dumps(self.to_dict())
@abstractmethod
def to_dict(self):
return