mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-05 14:54:51 +00:00
Hide phone numbers and show human-friendly date formats when printing
This commit is contained in:
parent
41d5a13b5f
commit
807dcb67be
1 changed files with 10 additions and 3 deletions
|
|
@ -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))
|
+ [
|
||||||
for attr in obj.__slots__
|
(attr, "*" * len(getattr(obj, attr)))
|
||||||
if getattr(obj, attr) is not None]
|
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__
|
||||||
|
if getattr(obj, attr) is not None
|
||||||
|
]
|
||||||
)
|
)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return repr(obj)
|
return repr(obj)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue