mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1125 from David256/feature-new-property-fullname
New property full_name
This commit is contained in:
commit
efa35ba71c
@ -179,6 +179,13 @@ class User(JsonDeserializable, Dictionaryable, JsonSerializable):
|
|||||||
self.can_read_all_group_messages = can_read_all_group_messages
|
self.can_read_all_group_messages = can_read_all_group_messages
|
||||||
self.supports_inline_queries = supports_inline_queries
|
self.supports_inline_queries = supports_inline_queries
|
||||||
|
|
||||||
|
@property
|
||||||
|
def full_name(self):
|
||||||
|
full_name = self.first_name
|
||||||
|
if self.last_name:
|
||||||
|
full_name += f' {self.last_name}'
|
||||||
|
return full_name
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return json.dumps(self.to_dict())
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
|
@ -6,9 +6,10 @@ from telebot import types
|
|||||||
|
|
||||||
|
|
||||||
def test_json_user():
|
def test_json_user():
|
||||||
jsonstring = r'{"id":101176298,"first_name":"RDSSBOT","username":"rdss_bot","is_bot":true}'
|
jsonstring = r'{"id":101176298,"first_name":"RDSSBOT","last_name":")))","username":"rdss_bot","is_bot":true}'
|
||||||
u = types.User.de_json(jsonstring)
|
u = types.User.de_json(jsonstring)
|
||||||
assert u.id == 101176298
|
assert u.id == 101176298
|
||||||
|
assert u.full_name == 'RDSSBOT )))'
|
||||||
|
|
||||||
|
|
||||||
def test_json_message():
|
def test_json_message():
|
||||||
|
Loading…
Reference in New Issue
Block a user