Resolve merge conflicts.
This commit is contained in:
commit
36ba21643b
|
@ -165,4 +165,4 @@ def listener1(*messages):
|
||||||
- [x] sendLocation
|
- [x] sendLocation
|
||||||
- [x] sendChatAction
|
- [x] sendChatAction
|
||||||
- [x] getUserProfilePhotos
|
- [x] getUserProfilePhotos
|
||||||
- [ ] getUpdat(contact and chat message not yet)
|
- [ ] getUpdat(chat message not yet)
|
||||||
|
|
3
setup.py
3
setup.py
|
@ -2,7 +2,7 @@
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
setup(name='pyTelegramBotAPI',
|
setup(name='pyTelegramBotAPI',
|
||||||
version='0.1.8',
|
version='0.1.9',
|
||||||
description='Python Telegram bot api. ',
|
description='Python Telegram bot api. ',
|
||||||
author='eternnoir',
|
author='eternnoir',
|
||||||
author_email='eternnoir@gmail.com',
|
author_email='eternnoir@gmail.com',
|
||||||
|
@ -16,6 +16,7 @@ setup(name='pyTelegramBotAPI',
|
||||||
'Programming Language :: Python :: 2',
|
'Programming Language :: Python :: 2',
|
||||||
'Programming Language :: Python :: 2.6',
|
'Programming Language :: Python :: 2.6',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
'Environment :: Console',
|
'Environment :: Console',
|
||||||
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
|
'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
|
||||||
]
|
]
|
||||||
|
|
|
@ -28,6 +28,7 @@ class JsonSerializable:
|
||||||
Subclasses of this class are guaranteed to be able to be converted to JSON format.
|
Subclasses of this class are guaranteed to be able to be converted to JSON format.
|
||||||
All subclasses of this class must override to_json.
|
All subclasses of this class must override to_json.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
"""
|
"""
|
||||||
Returns a JSON string representation of this class.
|
Returns a JSON string representation of this class.
|
||||||
|
@ -134,6 +135,9 @@ class Message(JsonDeserializable):
|
||||||
if 'location' in obj:
|
if 'location' in obj:
|
||||||
opts['location'] = Location.de_json(obj['location'])
|
opts['location'] = Location.de_json(obj['location'])
|
||||||
content_type = 'location'
|
content_type = 'location'
|
||||||
|
if 'contact' in obj:
|
||||||
|
opts['contact'] = Contact.de_json(json.dumps(obj['contact']))
|
||||||
|
content_type = 'contact'
|
||||||
return Message(message_id, from_user, date, chat, content_type, opts)
|
return Message(message_id, from_user, date, chat, content_type, opts)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -280,6 +284,18 @@ class Video(JsonDeserializable):
|
||||||
|
|
||||||
|
|
||||||
class Contact:
|
class Contact:
|
||||||
|
@classmethod
|
||||||
|
def de_json(cls, json_string):
|
||||||
|
obj = json.loads(json_string)
|
||||||
|
phone_number = obj['phone_number']
|
||||||
|
first_name = obj['first_name']
|
||||||
|
last_name = None
|
||||||
|
if 'last_name' in obj:
|
||||||
|
last_name = obj['last_name']
|
||||||
|
if 'user_id' in obj:
|
||||||
|
user_id = obj['user_id']
|
||||||
|
return Contact(phone_number, first_name, last_name, user_id)
|
||||||
|
|
||||||
def __init__(self, phone_number, first_name, last_name=None, user_id=None):
|
def __init__(self, phone_number, first_name, last_name=None, user_id=None):
|
||||||
self.phone_number = phone_number
|
self.phone_number = phone_number
|
||||||
self.first_name = first_name
|
self.first_name = first_name
|
||||||
|
|
|
@ -88,3 +88,10 @@ def test_json_UserProfilePhotos():
|
||||||
upp = types.UserProfilePhotos.de_json(json_string)
|
upp = types.UserProfilePhotos.de_json(json_string)
|
||||||
assert upp.photos[0][0].width == 160
|
assert upp.photos[0][0].width == 160
|
||||||
assert upp.photos[0][-1].height == 800
|
assert upp.photos[0][-1].height == 800
|
||||||
|
|
||||||
|
|
||||||
|
def test_json_contact():
|
||||||
|
json_string = r'{"phone_number":"00011111111","first_name":"dd","last_name":"ddl","user_id":8633}'
|
||||||
|
contact = types.Contact.de_json(json_string)
|
||||||
|
assert contact.first_name == 'dd'
|
||||||
|
assert contact.last_name == 'ddl'
|
||||||
|
|
Loading…
Reference in New Issue