Skip to content

Commit a229093

Browse files
committed
Fix PyPI package: Add proper CLI entry points and improve installation
- Add app/cli.py with proper CLI interface - Update pyproject.toml with multiple entry points (console_scripts and gui_scripts) - Update setup.py with correct entry points and version 1.2.1 - Add run_telegram_sender.bat for Windows users - Package now works with: python -m app.cli - Multiple command options: telegram-sender, telegram-multi-account-sender - Improved installation experience for end users
1 parent cb80f21 commit a229093

4 files changed

Lines changed: 101 additions & 35 deletions

File tree

app/cli.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
1+
#!/usr/bin/env python3
12
"""
2-
Command-line interface for the Telegram Multi-Account Message Sender.
3+
Command-line interface for Telegram Multi-Account Message Sender.
34
"""
45

5-
import asyncio
66
import sys
7+
import asyncio
78
from pathlib import Path
8-
from typing import Optional
99

10-
from .services import initialize_database, get_settings, get_logger
11-
from .core import TelegramClientManager, MessageEngine
10+
# Add app directory to Python path
11+
app_dir = Path(__file__).parent
12+
sys.path.insert(0, str(app_dir))
13+
14+
from app.services import initialize_database, get_settings, get_logger
15+
from app.gui.main import MainWindow
1216

17+
# Import all models to ensure they are registered with SQLModel
18+
from app.models import Account, Campaign, Recipient, SendLog
19+
from PyQt5.QtWidgets import QApplication
1320

14-
async def main():
15-
"""Main CLI entry point."""
16-
# Initialize services
21+
22+
def main():
23+
"""Main entry point for the CLI."""
24+
# Initialize database
1725
initialize_database()
26+
27+
# Get settings and logger
1828
settings = get_settings()
1929
logger = get_logger()
2030

21-
logger.info("Telegram Multi-Account Message Sender CLI")
31+
logger.info("Starting Telegram Multi-Account Message Sender...")
2232

23-
# Check if Telegram API is configured
24-
if not settings.is_telegram_configured():
25-
logger.error("Telegram API not configured. Please set TELEGRAM_API_ID and TELEGRAM_API_HASH")
26-
sys.exit(1)
33+
# Create QApplication
34+
app = QApplication(sys.argv)
35+
app.setApplicationName("Telegram Multi-Account Message Sender")
36+
app.setApplicationVersion("1.2.1")
2737

28-
# Initialize components
29-
client_manager = TelegramClientManager()
30-
message_engine = MessageEngine(client_manager)
38+
# Create and show main window
39+
main_window = MainWindow()
40+
main_window.show()
3141

32-
try:
33-
# CLI logic would go here
34-
logger.info("CLI mode not yet implemented. Use GUI mode for now.")
35-
36-
except KeyboardInterrupt:
37-
logger.info("Shutting down...")
38-
except Exception as e:
39-
logger.error(f"Error: {e}")
40-
sys.exit(1)
41-
finally:
42-
await client_manager.disconnect_all()
42+
# Run application
43+
sys.exit(app.exec_())
4344

4445

4546
if __name__ == "__main__":
46-
asyncio.run(main())
47+
main()

pyproject.toml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[build-system]
2-
requires = ["setuptools>=61.0.0", "wheel>=0.37.0"]
3-
build-backend = "setuptools.build_meta"
4-
51
[project]
62
name = "telegram-multi-account-sender"
73
version = "1.2.1"
@@ -90,7 +86,16 @@ Download = "https://github.com/VoxHash/Telegram-Multi-Account-Message-Sender/rel
9086
"Source Code" = "https://github.com/VoxHash/Telegram-Multi-Account-Message-Sender"
9187

9288
[project.scripts]
93-
telegram-sender = "main:main"
89+
telegram-sender = "app.cli:main"
90+
telegram-multi-account-sender = "app.cli:main"
91+
92+
[project.gui-scripts]
93+
telegram-sender-gui = "app.cli:main"
94+
telegram-multi-account-sender-gui = "app.cli:main"
95+
96+
[tool.setuptools]
97+
include-package-data = true
98+
zip-safe = false
9499

95100
[tool.setuptools.packages.find]
96101
where = ["."]
@@ -185,6 +190,19 @@ omit = [
185190
"*/__pycache__/*",
186191
"*/venv/*",
187192
"*/env/*",
193+
"*/build/*",
194+
"*/dist/*",
195+
"*/.pytest_cache/*",
196+
"*/.coverage*",
197+
"*/htmlcov/*",
198+
"*/.mypy_cache/*",
199+
"*/.tox/*",
200+
"*/.cache/*",
201+
"*/.vscode/*",
202+
"*/.idea/*",
203+
"*/.swp",
204+
"*/.swo",
205+
"*/~",
188206
]
189207

190208
[tool.coverage.report]

run_telegram_sender.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
@echo off
2+
REM Telegram Multi-Account Message Sender Launcher
3+
REM This batch file ensures the application runs regardless of PATH configuration
4+
5+
echo Starting Telegram Multi-Account Message Sender...
6+
7+
REM Try to find the executable in common locations
8+
if exist "C:\Users\%USERNAME%\AppData\Roaming\Python\Python313\Scripts\telegram-multi-account-sender.exe" (
9+
"C:\Users\%USERNAME%\AppData\Roaming\Python\Python313\Scripts\telegram-multi-account-sender.exe"
10+
goto :end
11+
)
12+
13+
if exist "C:\Users\%USERNAME%\AppData\Roaming\Python\Python312\Scripts\telegram-multi-account-sender.exe" (
14+
"C:\Users\%USERNAME%\AppData\Roaming\Python\Python312\Scripts\telegram-multi-account-sender.exe"
15+
goto :end
16+
)
17+
18+
if exist "C:\Users\%USERNAME%\AppData\Roaming\Python\Python311\Scripts\telegram-multi-account-sender.exe" (
19+
"C:\Users\%USERNAME%\AppData\Roaming\Python\Python311\Scripts\telegram-multi-account-sender.exe"
20+
goto :end
21+
)
22+
23+
REM Try to run via Python module
24+
python -m app.cli
25+
if %ERRORLEVEL% EQU 0 goto :end
26+
27+
REM If all else fails, show error
28+
echo.
29+
echo ERROR: Could not find Telegram Multi-Account Message Sender
30+
echo.
31+
echo Please try one of these solutions:
32+
echo 1. Download the Windows executable from:
33+
echo https://github.com/VoxHash/Telegram-Multi-Account-Message-Sender/releases
34+
echo.
35+
echo 2. Add Python Scripts to your PATH:
36+
echo C:\Users\%USERNAME%\AppData\Roaming\Python\Python313\Scripts
37+
echo.
38+
echo 3. Run directly with: python -m app.cli
39+
echo.
40+
pause
41+
42+
:end

setup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
requirements = [line.strip() for line in f if line.strip() and not line.startswith("#")]
1717

1818
# Read version
19-
version = "1.1.0"
19+
version = "1.2.1"
2020

2121
setup(
2222
name="telegram-multi-account-sender",
@@ -77,7 +77,12 @@
7777
},
7878
entry_points={
7979
"console_scripts": [
80-
"telegram-sender=main:main",
80+
"telegram-sender=app.cli:main",
81+
"telegram-multi-account-sender=app.cli:main",
82+
],
83+
"gui_scripts": [
84+
"telegram-sender-gui=app.cli:main",
85+
"telegram-multi-account-sender-gui=app.cli:main",
8186
],
8287
},
8388
include_package_data=True,

0 commit comments

Comments
 (0)