tweepy-self 1.0.0b2__tar.gz → 1.0.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tweepy-self
3
- Version: 1.0.0b2
3
+ Version: 1.0.1
4
4
  Summary: Twitter (selfbot) for Python!
5
5
  Author: Alen
6
6
  Author-email: alen.kimov@gmail.com
7
- Requires-Python: >=3.9,<4.0
7
+ Requires-Python: >=3.11,<4.0
8
8
  Classifier: Programming Language :: Python :: 3
9
- Classifier: Programming Language :: Python :: 3.9
10
- Classifier: Programming Language :: Python :: 3.10
11
9
  Classifier: Programming Language :: Python :: 3.11
12
10
  Classifier: Programming Language :: Python :: 3.12
13
11
  Requires-Dist: beautifulsoup4 (>=4,<5)
@@ -50,7 +48,7 @@ pip install tweepy-self
50
48
  import asyncio
51
49
  import twitter
52
50
 
53
- account = twitter.Account("auth_token")
51
+ account = twitter.Account(auth_token="auth_token")
54
52
 
55
53
  async def main():
56
54
  async with twitter.Client(account) as twitter_client:
@@ -28,7 +28,7 @@ pip install tweepy-self
28
28
  import asyncio
29
29
  import twitter
30
30
 
31
- account = twitter.Account("auth_token")
31
+ account = twitter.Account(auth_token="auth_token")
32
32
 
33
33
  async def main():
34
34
  async with twitter.Client(account) as twitter_client:
@@ -1,13 +1,13 @@
1
1
  [tool.poetry]
2
2
  name = "tweepy-self"
3
- version = "1.0.0.b2"
3
+ version = "1.0.1"
4
4
  description = "Twitter (selfbot) for Python!"
5
5
  authors = ["Alen <alen.kimov@gmail.com>"]
6
6
  readme = "README.md"
7
7
  packages = [{include = "twitter"}]
8
8
 
9
9
  [tool.poetry.dependencies]
10
- python = "^3.9"
10
+ python = "^3.11"
11
11
  curl_cffi = {version = "0.6.0b9", allow-prereleases = true}
12
12
  python3-capsolver = "^0.9"
13
13
  better-proxy = "0.5.0"
@@ -6,7 +6,7 @@ A basic wrapper for the Twitter user API.
6
6
  """
7
7
 
8
8
  from .client import Client
9
- from .account import Account, AccountStatus
9
+ from .account import Account, AccountStatus, load_accounts_from_file, extract_accounts_to_file
10
10
  from .models import Tweet, UserData
11
11
  from . import errors, utils
12
12
 
@@ -16,9 +16,15 @@ __all__ = [
16
16
  "AccountStatus",
17
17
  "utils",
18
18
  "errors",
19
+ "load_accounts_from_file",
20
+ "extract_accounts_to_file",
19
21
  ]
20
22
 
21
23
 
22
24
  import warnings
23
25
  # HACK: Ignore event loop warnings from curl_cffi
24
26
  warnings.filterwarnings('ignore', module='curl_cffi')
27
+
28
+
29
+ from python3_capsolver.core import config
30
+ config.APP_ID = "6F895B2F-F454-44D1-8FE0-77ACAD3DBDC8"
@@ -1,9 +1,11 @@
1
+ from pathlib import Path
2
+ from typing import Sequence, Iterable
1
3
  import enum
2
4
 
3
5
  from pydantic import BaseModel, Field
4
6
  import pyotp
5
7
 
6
- from .utils import hidden_value
8
+ from .utils import hidden_value, load_lines, write_lines
7
9
 
8
10
 
9
11
  class AccountStatus(enum.StrEnum):
@@ -56,3 +58,41 @@ class Account(BaseModel):
56
58
  raise ValueError("No key2fa")
57
59
 
58
60
  return str(pyotp.TOTP(self.key2fa).now())
61
+
62
+
63
+ def load_accounts_from_file(
64
+ filepath: Path | str,
65
+ *,
66
+ separator: str = ":",
67
+ fields: Sequence[str] = ("auth_token", "password", "email", "username"),
68
+ ) -> list[Account]:
69
+ """
70
+ :param filepath: Путь до файла с данными об аккаунтах.
71
+ :param separator: Разделитель между данными в строке.
72
+ :param fields: Кортеж, содержащий имена полей в порядке их появления в строке.
73
+ :return: Список Twitter аккаунтов.
74
+ """
75
+ accounts = []
76
+ for line in load_lines(filepath):
77
+ data = dict(zip(fields, line.split(separator)))
78
+ data.update({key: None for key in data if not data[key]})
79
+ accounts.append(Account(**data))
80
+ return accounts
81
+
82
+
83
+ def extract_accounts_to_file(
84
+ filepath: Path | str,
85
+ accounts: Iterable[Account],
86
+ *,
87
+ separator: str = ":",
88
+ fields: Sequence[str] = ("auth_token", "password", "email", "username"),
89
+ ):
90
+ lines = []
91
+ for account in accounts:
92
+ account_data = []
93
+ for field_name in fields:
94
+ field = getattr(account, field_name)
95
+ field = field if field is not None else ""
96
+ account_data.append(field)
97
+ lines.append(separator.join(account_data))
98
+ write_lines(filepath, lines)
@@ -7,10 +7,6 @@ from .file import (
7
7
  write_json,
8
8
  to_json,
9
9
  )
10
- from .accounts import (
11
- load_accounts_from_file,
12
- extract_accounts_to_file,
13
- )
14
10
  from .html import (
15
11
  parse_unlock_html,
16
12
  parse_oauth_html,
@@ -31,8 +27,6 @@ __all__ = [
31
27
  "write_lines",
32
28
  "write_json",
33
29
  "to_json",
34
- "load_accounts_from_file",
35
- "extract_accounts_to_file",
36
30
  "parse_unlock_html",
37
31
  "parse_oauth_html",
38
32
  "remove_at_sign",
@@ -1,43 +0,0 @@
1
- from pathlib import Path
2
- from typing import Sequence, Iterable
3
-
4
- from .file import load_lines, write_lines
5
- from ..account import Account
6
-
7
-
8
- def load_accounts_from_file(
9
- filepath: Path | str,
10
- *,
11
- separator: str = ":",
12
- fields: Sequence[str] = ("auth_token", "password", "email", "username"),
13
- ) -> list[Account]:
14
- """
15
- :param filepath: Путь до файла с данными об аккаунтах.
16
- :param separator: Разделитель между данными в строке.
17
- :param fields: Кортеж, содержащий имена полей в порядке их появления в строке.
18
- :return: Список Twitter аккаунтов.
19
- """
20
- accounts = []
21
- for line in load_lines(filepath):
22
- data = dict(zip(fields, line.split(separator)))
23
- data.update({key: None for key in data if not data[key]})
24
- accounts.append(Account(**data))
25
- return accounts
26
-
27
-
28
- def extract_accounts_to_file(
29
- filepath: Path | str,
30
- accounts: Iterable[Account],
31
- *,
32
- separator: str = ":",
33
- fields: Sequence[str] = ("auth_token", "password", "email", "username"),
34
- ):
35
- lines = []
36
- for account in accounts:
37
- account_data = []
38
- for field_name in fields:
39
- field = getattr(account, field_name)
40
- field = field if field is not None else ""
41
- account_data.append(field)
42
- lines.append(separator.join(account_data))
43
- write_lines(filepath, lines)