Spaces:
Paused
Paused
Devesh Pal commited on
Commit ·
8997ff3
1
Parent(s): 5aa1a4f
feat: use telethonpatch to patch changes
Browse files- pyUltroid/__init__.py +1 -1
- pyUltroid/startup/BaseClient.py +6 -13
pyUltroid/__init__.py
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
|
| 8 |
import os
|
| 9 |
import sys
|
| 10 |
-
|
| 11 |
from .version import __version__
|
| 12 |
|
| 13 |
run_as_module = __package__ in sys.argv or sys.argv[0] == "-m"
|
|
|
|
| 7 |
|
| 8 |
import os
|
| 9 |
import sys
|
| 10 |
+
import telethonpatch
|
| 11 |
from .version import __version__
|
| 12 |
|
| 13 |
run_as_module = __package__ in sys.argv or sys.argv[0] == "-m"
|
pyUltroid/startup/BaseClient.py
CHANGED
|
@@ -5,12 +5,13 @@
|
|
| 5 |
# PLease read the GNU Affero General Public License in
|
| 6 |
# <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>.
|
| 7 |
|
|
|
|
| 8 |
import inspect
|
| 9 |
import sys
|
| 10 |
import time
|
| 11 |
from logging import Logger
|
| 12 |
|
| 13 |
-
from
|
| 14 |
from telethon import utils as telethon_utils
|
| 15 |
from telethon.errors import (
|
| 16 |
AccessTokenExpiredError,
|
|
@@ -51,9 +52,7 @@ class UltroidClient(TelegramClient):
|
|
| 51 |
self.dc_id = self.session.dc_id
|
| 52 |
|
| 53 |
def __repr__(self):
|
| 54 |
-
return "<Ultroid.Client :\n self: {}\n bot: {}\n>"
|
| 55 |
-
self.full_name, self._bot
|
| 56 |
-
)
|
| 57 |
|
| 58 |
@property
|
| 59 |
def __dict__(self):
|
|
@@ -126,10 +125,8 @@ class UltroidClient(TelegramClient):
|
|
| 126 |
and files["by_bot"] == by_bot
|
| 127 |
):
|
| 128 |
if to_delete:
|
| 129 |
-
|
| 130 |
os.remove(file)
|
| 131 |
-
except FileNotFoundError:
|
| 132 |
-
pass
|
| 133 |
return files["raw_file"], time.time() - start_time
|
| 134 |
from pyUltroid.fns.FastTelethon import upload_file
|
| 135 |
from pyUltroid.fns.helper import progress
|
|
@@ -161,10 +158,8 @@ class UltroidClient(TelegramClient):
|
|
| 161 |
else:
|
| 162 |
self._cache.update({"upload_cache": [cache]})
|
| 163 |
if to_delete:
|
| 164 |
-
|
| 165 |
os.remove(file)
|
| 166 |
-
except FileNotFoundError:
|
| 167 |
-
pass
|
| 168 |
return raw_file, time.time() - start_time
|
| 169 |
|
| 170 |
async def fast_downloader(self, file, **kwargs):
|
|
@@ -249,8 +244,6 @@ class UltroidClient(TelegramClient):
|
|
| 249 |
return dict(inspect.getmembers(self))
|
| 250 |
|
| 251 |
async def parse_id(self, text):
|
| 252 |
-
|
| 253 |
text = int(text)
|
| 254 |
-
except ValueError:
|
| 255 |
-
pass
|
| 256 |
return await self.get_peer_id(text)
|
|
|
|
| 5 |
# PLease read the GNU Affero General Public License in
|
| 6 |
# <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>.
|
| 7 |
|
| 8 |
+
import contextlib
|
| 9 |
import inspect
|
| 10 |
import sys
|
| 11 |
import time
|
| 12 |
from logging import Logger
|
| 13 |
|
| 14 |
+
from telethonpatch import TelegramClient
|
| 15 |
from telethon import utils as telethon_utils
|
| 16 |
from telethon.errors import (
|
| 17 |
AccessTokenExpiredError,
|
|
|
|
| 52 |
self.dc_id = self.session.dc_id
|
| 53 |
|
| 54 |
def __repr__(self):
|
| 55 |
+
return f"<Ultroid.Client :\n self: {self.full_name}\n bot: {self._bot}\n>"
|
|
|
|
|
|
|
| 56 |
|
| 57 |
@property
|
| 58 |
def __dict__(self):
|
|
|
|
| 125 |
and files["by_bot"] == by_bot
|
| 126 |
):
|
| 127 |
if to_delete:
|
| 128 |
+
with contextlib.suppress(FileNotFoundError):
|
| 129 |
os.remove(file)
|
|
|
|
|
|
|
| 130 |
return files["raw_file"], time.time() - start_time
|
| 131 |
from pyUltroid.fns.FastTelethon import upload_file
|
| 132 |
from pyUltroid.fns.helper import progress
|
|
|
|
| 158 |
else:
|
| 159 |
self._cache.update({"upload_cache": [cache]})
|
| 160 |
if to_delete:
|
| 161 |
+
with contextlib.suppress(FileNotFoundError):
|
| 162 |
os.remove(file)
|
|
|
|
|
|
|
| 163 |
return raw_file, time.time() - start_time
|
| 164 |
|
| 165 |
async def fast_downloader(self, file, **kwargs):
|
|
|
|
| 244 |
return dict(inspect.getmembers(self))
|
| 245 |
|
| 246 |
async def parse_id(self, text):
|
| 247 |
+
with contextlib.suppress(ValueError):
|
| 248 |
text = int(text)
|
|
|
|
|
|
|
| 249 |
return await self.get_peer_id(text)
|