refactor: remove unused import of get_cookies_from_browser across multiple example scripts

This commit is contained in:
bohd4nx
2026-05-21 00:21:41 +03:00
parent 516e69f820
commit 92384b96f0
14 changed files with 12 additions and 26 deletions
-2
View File
@@ -10,8 +10,6 @@ Use next_offset for pagination.
import asyncio
import json
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import FragmentClient, GiftsResult
SEED = "word1 word2 ... word24"
-2
View File
@@ -9,8 +9,6 @@ Use next_offset_id for pagination.
import asyncio
import json
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import FragmentClient, NumbersResult
SEED = "word1 word2 ... word24"
-2
View File
@@ -9,8 +9,6 @@ Use next_offset_id for pagination.
import asyncio
import json
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import FragmentClient, UsernamesResult
SEED = "word1 word2 ... word24"
-2
View File
@@ -11,8 +11,6 @@ Defaults to the Fragment base URL.
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import FragmentClient
SEED = "word1 word2 ... word24"
-2
View File
@@ -7,8 +7,6 @@ wallet_version defaults to "V5R1" — change to "V4R2" for older wallets.
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import FragmentClient
SEED = "word1 word2 ... word24"
-2
View File
@@ -8,8 +8,6 @@ Use terminate_sessions() to forcefully end all active Telegram sessions.
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import AnonymousNumberError, FragmentClient
SEED = "word1 word2 ... word24"
@@ -7,8 +7,6 @@ Your wallet must satisfy the current minimum TON threshold and transaction cost.
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import (
AdsRechargeResult,
ConfigurationError,
@@ -9,8 +9,6 @@ Channel can be "@channel", "channel", or "https://t.me/channel".
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import ConfigurationError, FragmentClient, UserNotFoundError
SEED = "word1 word2 ... word24"
-2
View File
@@ -9,8 +9,6 @@ Channel can be "@channel", "channel", or "https://t.me/channel".
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import ConfigurationError, FragmentClient, UserNotFoundError
SEED = "word1 word2 ... word24"
-2
View File
@@ -9,8 +9,6 @@ Username can be "@username", "username", or "https://t.me/username".
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import ConfigurationError, FragmentClient, UserNotFoundError
SEED = "word1 word2 ... word24"
-2
View File
@@ -9,8 +9,6 @@ Username can be "@username", "username", or "https://t.me/username".
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import ConfigurationError, FragmentClient, UserNotFoundError
SEED = "word1 word2 ... word24"
-2
View File
@@ -9,8 +9,6 @@ Your wallet must satisfy the current minimum TON threshold and transaction cost.
import asyncio
from pyfragment.utils import get_cookies_from_browser # noqa: F401
from pyfragment import (
ConfigurationError,
FragmentClient,
+11 -1
View File
@@ -7,15 +7,25 @@ from pyfragment.core.constants import FRAGMENT_BASE_URL, FRAGMENT_DOMAIN, REQUIR
from pyfragment.exceptions import CookieError
from pyfragment.models.cookies import CookieResult
try:
import rookiepy as rookiepy # type: ignore[import-not-found,no-redef]
except Exception:
rookiepy = None
def get_cookies_from_browser(browser: str = "chrome") -> CookieResult:
global rookiepy
key = browser.lower()
if key not in SUPPORTED_BROWSERS:
supported = ", ".join(sorted(SUPPORTED_BROWSERS))
raise CookieError(CookieError.UNSUPPORTED_BROWSER.format(browser=browser, supported=supported))
try:
import rookiepy # type: ignore[import-not-found]
if rookiepy is None:
import rookiepy as imported_rookiepy # type: ignore[import-not-found]
rookiepy = imported_rookiepy
jar: list[dict[str, Any]] = getattr(rookiepy, key)([FRAGMENT_DOMAIN])
except Exception as exc:
+1 -1
View File
@@ -74,7 +74,7 @@ class UserNotFoundError(FragmentAPIError):
class AnonymousNumberError(FragmentAPIError):
"""Raised for Fragment anonymous number API failures."""
NOT_OWNED = "Number '{number}' is not linked to your Fragment account, or there are no active sessions to terminate."
NOT_OWNED = "Number '{number}' is not associated with your Fragment account or has no active sessions to terminate."
TERMINATE_FAILED = "Failed to terminate sessions for '{number}': {error}"