Queer European MD passionate about IT
ソースを参照

set_class_path class method

Davte 6 年 前
コミット
b40fd52411
2 ファイル変更9 行追加2 行削除
  1. 1 1
      davtelepot/__init__.py
  2. 8 1
      davtelepot/custombot.py

+ 1 - 1
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"
 

+ 8 - 1
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.