From c27f60b94b4df649bf6671be9139d8b1c3018bf4 Mon Sep 17 00:00:00 2001 From: Cub11k Date: Fri, 6 Jan 2023 22:36:08 +0200 Subject: [PATCH 1/2] Make create_dir() method cross-platform instead of POSIX only. Fix for issue #1869 --- telebot/asyncio_storage/pickle_storage.py | 2 +- telebot/storage/pickle_storage.py | 2 +- telebot/util.py | 24 +++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/telebot/asyncio_storage/pickle_storage.py b/telebot/asyncio_storage/pickle_storage.py index 49fe3be..cf446d8 100644 --- a/telebot/asyncio_storage/pickle_storage.py +++ b/telebot/asyncio_storage/pickle_storage.py @@ -28,7 +28,7 @@ class StatePickleStorage(StateStorageBase): """ Create directory .save-handlers. """ - dirs = self.file_path.rsplit('/', maxsplit=1)[0] + dirs, filename = os.path.split(self.file_path) os.makedirs(dirs, exist_ok=True) if not os.path.isfile(self.file_path): with open(self.file_path,'wb') as file: diff --git a/telebot/storage/pickle_storage.py b/telebot/storage/pickle_storage.py index dfffcf8..68c9fbe 100644 --- a/telebot/storage/pickle_storage.py +++ b/telebot/storage/pickle_storage.py @@ -34,7 +34,7 @@ class StatePickleStorage(StateStorageBase): """ Create directory .save-handlers. """ - dirs = self.file_path.rsplit('/', maxsplit=1)[0] + dirs, filename = os.path.split(self.file_path) os.makedirs(dirs, exist_ok=True) if not os.path.isfile(self.file_path): with open(self.file_path,'wb') as file: diff --git a/telebot/util.py b/telebot/util.py index 3e76f19..a1bf7d4 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -643,15 +643,15 @@ def validate_web_app_data(token: str, raw_init_data: str): return hmac.new(secret_key.digest(), data_check_string.encode(), sha256).hexdigest() == init_data_hash -__all__ = ( - "content_type_media", "content_type_service", "update_types", - "WorkerThread", "AsyncTask", "CustomRequestResponse", - "async_dec", "deprecated", - "is_bytes", "is_string", "is_dict", "is_pil_image", - "chunks", "generate_random_token", "pil_image_to_file", - "is_command", "extract_command", "extract_arguments", - "split_string", "smart_split", "escape", "user_link", "quick_markup", - "antiflood", "parse_web_app_data", "validate_web_app_data", - "or_set", "or_clear", "orify", "OrEvent", "per_thread", - "webhook_google_functions" -) +# __all__ = ( +# "content_type_media", "content_type_service", "update_types", +# "WorkerThread", "AsyncTask", "CustomRequestResponse", +# "async_dec", "deprecated", +# "is_bytes", "is_string", "is_dict", "is_pil_image", +# "chunks", "generate_random_token", "pil_image_to_file", +# "is_command", "extract_command", "extract_arguments", +# "split_string", "smart_split", "escape", "user_link", "quick_markup", +# "antiflood", "parse_web_app_data", "validate_web_app_data", +# "or_set", "or_clear", "orify", "OrEvent", "per_thread", +# "webhook_google_functions" +# ) From 02ae2557014a5181845ec0ccb44412d5be015dea Mon Sep 17 00:00:00 2001 From: Konstantin Ostashenko Date: Fri, 6 Jan 2023 22:39:27 +0200 Subject: [PATCH 2/2] Revert changes in util.py --- telebot/util.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/telebot/util.py b/telebot/util.py index a1bf7d4..3e76f19 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -643,15 +643,15 @@ def validate_web_app_data(token: str, raw_init_data: str): return hmac.new(secret_key.digest(), data_check_string.encode(), sha256).hexdigest() == init_data_hash -# __all__ = ( -# "content_type_media", "content_type_service", "update_types", -# "WorkerThread", "AsyncTask", "CustomRequestResponse", -# "async_dec", "deprecated", -# "is_bytes", "is_string", "is_dict", "is_pil_image", -# "chunks", "generate_random_token", "pil_image_to_file", -# "is_command", "extract_command", "extract_arguments", -# "split_string", "smart_split", "escape", "user_link", "quick_markup", -# "antiflood", "parse_web_app_data", "validate_web_app_data", -# "or_set", "or_clear", "orify", "OrEvent", "per_thread", -# "webhook_google_functions" -# ) +__all__ = ( + "content_type_media", "content_type_service", "update_types", + "WorkerThread", "AsyncTask", "CustomRequestResponse", + "async_dec", "deprecated", + "is_bytes", "is_string", "is_dict", "is_pil_image", + "chunks", "generate_random_token", "pil_image_to_file", + "is_command", "extract_command", "extract_arguments", + "split_string", "smart_split", "escape", "user_link", "quick_markup", + "antiflood", "parse_web_app_data", "validate_web_app_data", + "or_set", "or_clear", "orify", "OrEvent", "per_thread", + "webhook_google_functions" +)