Path property implemented
Useful when dealing with files
This commit is contained in:
parent
e47dd1d458
commit
967627c4a2
@ -28,6 +28,7 @@ class Bot(TelegramBot):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
bots = []
|
bots = []
|
||||||
|
_path = '.'
|
||||||
runner = None
|
runner = None
|
||||||
local_host = 'localhost'
|
local_host = 'localhost'
|
||||||
port = 3000
|
port = 3000
|
||||||
@ -57,6 +58,7 @@ class Bot(TelegramBot):
|
|||||||
"""
|
"""
|
||||||
self.__class__.bots.append(self)
|
self.__class__.bots.append(self)
|
||||||
super().__init__(token)
|
super().__init__(token)
|
||||||
|
self._path = None
|
||||||
self._offset = 0
|
self._offset = 0
|
||||||
self._hostname = hostname
|
self._hostname = hostname
|
||||||
self._certificate = certificate
|
self._certificate = certificate
|
||||||
@ -136,6 +138,23 @@ class Bot(TelegramBot):
|
|||||||
self._default_keyboard = dict()
|
self._default_keyboard = dict()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path(self):
|
||||||
|
"""Path where files should be looked for.
|
||||||
|
|
||||||
|
If no instance path is set, return class path.
|
||||||
|
"""
|
||||||
|
return self._path or self.__class__._path
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_class_path(csl, path):
|
||||||
|
"""Set class path attribute."""
|
||||||
|
csl._path = path
|
||||||
|
|
||||||
|
def set_path(self, path):
|
||||||
|
"""Set instance path attribute."""
|
||||||
|
self._path = path
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hostname(self):
|
def hostname(self):
|
||||||
"""Hostname for the webhook URL.
|
"""Hostname for the webhook URL.
|
||||||
@ -673,7 +692,6 @@ class Bot(TelegramBot):
|
|||||||
as reply_markup (only those messages can be edited, which were
|
as reply_markup (only those messages can be edited, which were
|
||||||
sent with no reply markup or with an inline keyboard).
|
sent with no reply markup or with an inline keyboard).
|
||||||
"""
|
"""
|
||||||
# TODO prevent Telegram flood control
|
|
||||||
if 'message' in update:
|
if 'message' in update:
|
||||||
update = update['message']
|
update = update['message']
|
||||||
if chat_id is None and 'chat' in update:
|
if chat_id is None and 'chat' in update:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user