1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

added property user to TeleBot class

Added property `user` to TeleBot class. The idea is to have easy access to the user object representing the bot without doing an API call every time.
This commit is contained in:
SwissCorePy 2021-09-20 14:31:00 +02:00
parent 07ebdeab25
commit 38cc96d0f3

View File

@ -207,6 +207,16 @@ class TeleBot:
self.threaded = threaded
if self.threaded:
self.worker_pool = util.ThreadPool(num_threads=num_threads)
@property
def user(self) -> types.User:
"""
The User object representing this bot.
Equivalent to bot.get_me() but the result is cached so only one API call is needed
"""
if not hasattr(self, "_user"):
self._user = types.User.de_json(self.get_me())
return self._user
def enable_save_next_step_handlers(self, delay=120, filename="./.handler-saves/step.save"):
"""