Skip to content

Commit

Permalink
Merge pull request eternnoir#1311 from SwissCorePy/master
Browse files Browse the repository at this point in the history
added property `user` to TeleBot class
  • Loading branch information
Badiboy authored Sep 20, 2021
2 parents 82518d8 + 38cc96d commit c6ff9b0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ def __init__(
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"):
"""
Expand Down

0 comments on commit c6ff9b0

Please sign in to comment.