Complete API reference for Telegram Multi-Account Message Sender.
This document provides a comprehensive reference for all public APIs, classes, and functions in the Telegram Multi-Account Message Sender application.
Manages multiple Telegram client connections.
from app.core import TelegramClientManager
manager = TelegramClientManager()Methods:
get_client(account_id: str) -> TelegramClientWrapper: Get client for accountadd_client(account: Account) -> TelegramClientWrapper: Add new clientremove_client(account_id: str) -> None: Remove clientdisconnect_all() -> None: Disconnect all clients
Wrapper for Telethon Telegram client.
from app.core import TelegramClientWrapper
client = TelegramClientWrapper(account_id, api_id, api_hash)Methods:
connect() -> bool: Connect to Telegramdisconnect() -> None: Disconnect from Telegramsend_message(recipient: str, message: str, media: Optional[str] = None) -> dict: Send messageis_connected() -> bool: Check connection status
Core message sending engine.
from app.core import MessageEngine
engine = MessageEngine()Methods:
send_message(account_id: str, recipient: str, message: str, media: Optional[str] = None) -> dict: Send single messageprocess_spintax(text: str) -> str: Process spintax syntaxvalidate_message(message: str) -> bool: Validate message content
Runs message campaigns.
from app.core import CampaignRunner
runner = CampaignRunner(campaign_id)Methods:
start() -> None: Start campaignpause() -> None: Pause campaignstop() -> None: Stop campaignget_status() -> dict: Get campaign status
Manages rate limiting and throttling.
from app.core import Throttler
throttler = Throttler(max_messages_per_minute=30)Methods:
acquire(account_id: str) -> bool: Acquire permission to sendwait_time(account_id: str) -> float: Get wait time until next sendreset(account_id: str) -> None: Reset rate limit for account
Rate limiting implementation.
from app.core import RateLimiter
limiter = RateLimiter(rate=30, per=60)Processes spintax syntax for message variations.
from app.core import SpintaxProcessor
processor = SpintaxProcessor()
result = processor.process("Hello {John|Jane|Alex}!")Methods:
process(text: str) -> str: Process spintax and return variationvalidate(text: str) -> bool: Validate spintax syntaxget_variations(text: str, count: int = 10) -> List[str]: Get multiple variations
Checks message compliance.
from app.core import ComplianceChecker
checker = ComplianceChecker()
is_compliant = checker.check(message)Methods:
check(message: str) -> bool: Check if message is compliantget_violations(message: str) -> List[str]: Get list of violationsfix(message: str) -> str: Auto-fix compliance issues
Safety and security checks.
from app.core import SafetyGuard
guard = SafetyGuard()Methods:
check_rate_limit(account_id: str) -> bool: Check rate limit compliancecheck_content(message: str) -> bool: Check content safetycheck_recipient(recipient: str) -> bool: Validate recipient
Collects campaign analytics.
from app.core import AnalyticsCollector
collector = AnalyticsCollector()Methods:
collect(campaign_id: str, event: str, data: dict) -> None: Collect analytics eventget_stats(campaign_id: str) -> dict: Get campaign statisticsexport(campaign_id: str, format: str = "json") -> str: Export analytics
Campaign analytics data structure.
from app.core import CampaignAnalytics
analytics = CampaignAnalytics(campaign_id)Telegram account model.
from app.models import Account
account = Account(
phone_number="+1234567890",
api_id="your_api_id",
api_hash="your_api_hash"
)Fields:
id: UUID: Account IDphone_number: str: Phone numberapi_id: str: Telegram API IDapi_hash: str: Telegram API hashstatus: AccountStatus: Account statusproxy_type: Optional[ProxyType]: Proxy typeproxy_host: Optional[str]: Proxy hostproxy_port: Optional[int]: Proxy portcreated_at: datetime: Creation timestampupdated_at: datetime: Update timestamp
Account status enumeration.
from app.models import AccountStatus
AccountStatus.ACTIVE
AccountStatus.INACTIVE
AccountStatus.BANNED
AccountStatus.PENDINGMessage campaign model.
from app.models import Campaign
campaign = Campaign(
name="My Campaign",
campaign_type=CampaignType.BULK,
message_text="Hello {name}!",
status=CampaignStatus.PENDING
)Fields:
id: UUID: Campaign IDname: str: Campaign namecampaign_type: CampaignType: Campaign typemessage_type: MessageType: Message typemessage_text: str: Message contentstatus: CampaignStatus: Campaign statusstart_time: Optional[datetime]: Scheduled start timerate_limit: int: Messages per minutecreated_at: datetime: Creation timestampupdated_at: datetime: Update timestamp
Campaign status enumeration.
from app.models import CampaignStatus
CampaignStatus.PENDING
CampaignStatus.RUNNING
CampaignStatus.PAUSED
CampaignStatus.COMPLETED
CampaignStatus.FAILED
CampaignStatus.CANCELLEDCampaign type enumeration.
from app.models import CampaignType
CampaignType.BULK
CampaignType.SCHEDULED
CampaignType.RECURRINGMessage type enumeration.
from app.models import MessageType
MessageType.TEXT
MessageType.MEDIA
MessageType.COMBINEDMessage recipient model.
from app.models import Recipient
recipient = Recipient(
username="username",
phone_number="+1234567890",
recipient_type=RecipientType.USERNAME
)Fields:
id: UUID: Recipient IDusername: Optional[str]: Telegram usernamephone_number: Optional[str]: Phone numberrecipient_type: RecipientType: Recipient typestatus: RecipientStatus: Recipient statussource: RecipientSource: Recipient sourcecreated_at: datetime: Creation timestampupdated_at: datetime: Update timestamp
Recipient list model.
from app.models import RecipientList
recipient_list = RecipientList(name="My List")Fields:
id: UUID: List IDname: str: List namedescription: Optional[str]: List descriptioncreated_at: datetime: Creation timestampupdated_at: datetime: Update timestamp
Message template model.
from app.models import MessageTemplate
template = MessageTemplate(
name="Welcome Template",
content="Hello {name}, welcome!",
template_type=TemplateType.SPINTAX
)Fields:
id: UUID: Template IDname: str: Template namecontent: str: Template contenttemplate_type: TemplateType: Template typecategory: Optional[TemplateCategory]: Template categorycreated_at: datetime: Creation timestampupdated_at: datetime: Update timestamp
Message send log model.
from app.models import SendLog
log = SendLog(
campaign_id=campaign_id,
account_id=account_id,
recipient=recipient,
status=SendStatus.SUCCESS
)Fields:
id: UUID: Log IDcampaign_id: UUID: Campaign IDaccount_id: UUID: Account IDrecipient: str: Recipient identifierstatus: SendStatus: Send statusmessage: Optional[str]: Error messagesent_at: Optional[datetime]: Send timestampcreated_at: datetime: Creation timestamp
Get application settings.
from app.services import get_settings
settings = get_settings()
api_id = settings.telegram_api_idApplication settings class.
from app.services import Settings
settings = Settings()Fields:
telegram_api_id: str: Telegram API IDtelegram_api_hash: str: Telegram API hashtheme: Theme: UI themelanguage: Language: UI languagelog_level: LogLevel: Logging levelstart_with_windows: bool: Start with Windowsrate_limit_per_minute: int: Default rate limit
Reload settings from configuration.
from app.services import reload_settings
settings = reload_settings()Initialize database connection.
from app.services import initialize_database
initialize_database()Get database session.
from app.services import get_session
with get_session() as session:
accounts = session.query(Account).all()Get async database session.
from app.services import get_async_session
async with get_async_session() as session:
result = await session.execute(select(Account))Check database health.
from app.services import health_check
is_healthy = health_check()Backup database.
from app.services import backup_database
success = backup_database("backup.db")Restore database from backup.
from app.services import restore_database
success = restore_database("backup.db")Get campaign manager instance.
from app.services import get_campaign_manager
manager = get_campaign_manager()Manages message campaigns.
from app.services import CampaignManager
manager = CampaignManager()Methods:
create_campaign(data: dict) -> Campaign: Create new campaignstart_campaign(campaign_id: str) -> bool: Start campaignpause_campaign(campaign_id: str) -> bool: Pause campaignstop_campaign(campaign_id: str) -> bool: Stop campaignget_campaign(campaign_id: str) -> Optional[Campaign]: Get campaignlist_campaigns() -> List[Campaign]: List all campaignsdelete_campaign(campaign_id: str) -> bool: Delete campaign
Get application logger.
from app.services import get_logger
logger = get_logger()
logger.info("Application started")Application logger class.
from app.services import AppLogger
logger = AppLogger()Methods:
info(message: str) -> None: Log info messagewarning(message: str) -> None: Log warning messageerror(message: str) -> None: Log error messagedebug(message: str) -> None: Log debug messagecritical(message: str) -> None: Log critical message
Setup logging configuration.
from app.services import setup_logging, LogLevel
setup_logging(LogLevel.DEBUG)Get warmup manager instance.
from app.services import get_warmup_manager
manager = get_warmup_manager()Manages account warmup process.
from app.services import WarmupManager
manager = WarmupManager()Methods:
start_warmup(account_id: str, duration: int = 7) -> bool: Start warmupstop_warmup(account_id: str) -> bool: Stop warmupget_warmup_status(account_id: str) -> dict: Get warmup statusis_warming_up(account_id: str) -> bool: Check if account is warming up
Main application window.
from app.gui.main import MainWindow
window = MainWindow()
window.show()Methods:
setup_ui() -> None: Setup user interfacesetup_menu() -> None: Setup menu barsetup_status_bar() -> None: Setup status barupdate_status() -> None: Update status baron_language_changed() -> None: Handle language change
Manages application themes.
from app.gui.theme import ThemeManager
theme_manager = ThemeManager()
theme_manager.apply_theme(Theme.DARK)Methods:
apply_theme(theme: Theme) -> None: Apply themeget_current_theme() -> Theme: Get current themeget_theme_stylesheet(theme: Theme) -> str: Get theme stylesheet
Add application to Windows startup.
from app.utils.windows_startup import add_to_startup
success = add_to_startup("Telegram Sender", "C:\\path\\to\\app.exe")Remove application from Windows startup.
from app.utils.windows_startup import remove_from_startup
success = remove_from_startup("Telegram Sender")Check if application is in Windows startup.
from app.utils.windows_startup import is_in_startup
in_startup = is_in_startup("Telegram Sender")Read file content.
from app.utils.files import read_file
content = read_file("data.txt")Write file content.
from app.utils.files import write_file
success = write_file("data.txt", "content")Encrypt data.
from app.utils.crypto import encrypt
encrypted = encrypt("sensitive data", "secret_key")Decrypt data.
from app.utils.crypto import decrypt
decrypted = decrypt(encrypted_data, "secret_key")All API methods may raise the following exceptions:
ValueError: Invalid input parametersConnectionError: Network connection issuesAuthenticationError: Authentication failuresRateLimitError: Rate limit exceededComplianceError: Compliance check failures
See Examples and Examples for practical usage examples.
- Architecture Documentation for system design
- CLI Reference for command-line interface
- Usage Guide for user documentation