mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Hide phone numbers and show human-friendly date formats when printing
This commit is contained in:
parent
41d5a13b5f
commit
807dcb67be
@ -17,6 +17,7 @@
|
|||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from datetime import datetime
|
||||||
from json import dumps
|
from json import dumps
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
@ -46,9 +47,15 @@ class PyrogramType:
|
|||||||
try:
|
try:
|
||||||
return OrderedDict(
|
return OrderedDict(
|
||||||
[("_", "pyrogram." + obj.__class__.__name__)]
|
[("_", "pyrogram." + obj.__class__.__name__)]
|
||||||
+ [(attr, getattr(obj, attr))
|
+ [
|
||||||
|
(attr, "*" * len(getattr(obj, attr)))
|
||||||
|
if attr == "phone_number"
|
||||||
|
else (attr, str(datetime.fromtimestamp(getattr(obj, attr))))
|
||||||
|
if attr.endswith("date")
|
||||||
|
else (attr, getattr(obj, attr))
|
||||||
for attr in obj.__slots__
|
for attr in obj.__slots__
|
||||||
if getattr(obj, attr) is not None]
|
if getattr(obj, attr) is not None
|
||||||
|
]
|
||||||
)
|
)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return repr(obj)
|
return repr(obj)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user