Queer European MD passionate about IT
Browse Source

Specify encoding in `send_part_of_text_file` function

Davte 1 year ago
parent
commit
ec747bef1d
2 changed files with 4 additions and 3 deletions
  1. 1 1
      davtelepot/__init__.py
  2. 3 2
      davtelepot/utilities.py

+ 1 - 1
davtelepot/__init__.py

@@ -11,7 +11,7 @@ __author__ = "Davide Testa"
 __email__ = "davide@davte.it"
 __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
 __license__ = "GNU General Public License v3.0"
-__version__ = "2.9.7"
+__version__ = "2.9.8"
 __maintainer__ = "Davide Testa"
 __contact__ = "t.me/davte"
 

+ 3 - 2
davtelepot/utilities.py

@@ -1666,7 +1666,8 @@ async def send_part_of_text_file(bot, chat_id, file_path, caption=None,
                                  file_name='File.txt', user_record=None,
                                  update=None,
                                  reversed_=True,
-                                 limit=None):
+                                 limit=None,
+                                 encoding='utf-8'):
     """Send `lines` lines of text file via `bot` in `chat_id`.
 
     If `reversed`, read the file from last line.
@@ -1677,7 +1678,7 @@ async def send_part_of_text_file(bot, chat_id, file_path, caption=None,
     if update is None:
         update = dict()
     try:
-        with open(file_path, 'r') as log_file:
+        with open(file_path, 'r', encoding=encoding) as log_file:
             lines = log_file.readlines()
             if reversed_:
                 lines = lines[::-1]