set_class_path class method

This commit is contained in:
Davte 2018-10-24 18:06:02 +02:00
parent 8a050acfd3
commit b40fd52411
2 changed files with 9 additions and 2 deletions

View File

@ -1,7 +1,7 @@
__author__ = "Davide Testa" __author__ = "Davide Testa"
__credits__ = "Marco Origlia" __credits__ = "Marco Origlia"
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "1.2.1" __version__ = "1.2.2"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -95,7 +95,7 @@ class Bot(telepot.aio.Bot, Gettable):
MAX_GROUP_MESSAGES_PER_MINUTE = 20 MAX_GROUP_MESSAGES_PER_MINUTE = 20
# Max length of text field for a Telegram message (UTF-8 text) # Max length of text field for a Telegram message (UTF-8 text)
TELEGRAM_MESSAGES_MAX_LEN = 4096 TELEGRAM_MESSAGES_MAX_LEN = 4096
_path = os.path.dirname(__file__) _path = '.'
_unauthorized_message = None _unauthorized_message = None
_unknown_command_message = None _unknown_command_message = None
_maintenance_message = None _maintenance_message = None
@ -223,6 +223,13 @@ class Bot(telepot.aio.Bot, Gettable):
return self.__class__._maintenance_message return self.__class__._maintenance_message
return "Bot is currently under maintenance! Retry later please." 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 @classmethod
def set_class_unauthorized_message(csl, unauthorized_message): def set_class_unauthorized_message(csl, unauthorized_message):
"""Set class unauthorized message, to be returned if user is unauthorized to make a request. """Set class unauthorized message, to be returned if user is unauthorized to make a request.