From b40fd5241111dc0af66cf490fed98af3bb5be9c7 Mon Sep 17 00:00:00 2001 From: Davte Date: Wed, 24 Oct 2018 18:06:02 +0200 Subject: [PATCH] set_class_path class method --- davtelepot/__init__.py | 2 +- davtelepot/custombot.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/davtelepot/__init__.py b/davtelepot/__init__.py index baaef43..f843c44 100644 --- a/davtelepot/__init__.py +++ b/davtelepot/__init__.py @@ -1,7 +1,7 @@ __author__ = "Davide Testa" __credits__ = "Marco Origlia" __license__ = "GNU General Public License v3.0" -__version__ = "1.2.1" +__version__ = "1.2.2" __maintainer__ = "Davide Testa" __contact__ = "t.me/davte" diff --git a/davtelepot/custombot.py b/davtelepot/custombot.py index 5b17edb..422b016 100644 --- a/davtelepot/custombot.py +++ b/davtelepot/custombot.py @@ -95,7 +95,7 @@ class Bot(telepot.aio.Bot, Gettable): MAX_GROUP_MESSAGES_PER_MINUTE = 20 # Max length of text field for a Telegram message (UTF-8 text) TELEGRAM_MESSAGES_MAX_LEN = 4096 - _path = os.path.dirname(__file__) + _path = '.' _unauthorized_message = None _unknown_command_message = None _maintenance_message = None @@ -223,6 +223,13 @@ class Bot(telepot.aio.Bot, Gettable): return self.__class__._maintenance_message return "Bot is currently under maintenance! Retry later please." + @classmethod + def set_class_path(csl, path): + """Set class path, where files will be looked for. + For example, if send_photo receives `photo='mypic.png'`, it will parse it as `'{path}/mypic.png'.format(path=self.path)` + """ + csl._path = path + @classmethod def set_class_unauthorized_message(csl, unauthorized_message): """Set class unauthorized message, to be returned if user is unauthorized to make a request.