329 Zeilen
11 KiB
Python
329 Zeilen
11 KiB
Python
# social_networks/x/x_workflow.py
|
|
|
|
"""
|
|
X (Twitter) Workflow - Definiert die Arbeitsabläufe für X-Automatisierung
|
|
"""
|
|
|
|
from typing import Dict, List, Any
|
|
|
|
class XWorkflow:
|
|
"""
|
|
Definiert strukturierte Workflows für verschiedene X-Operationen.
|
|
"""
|
|
|
|
@staticmethod
|
|
def get_registration_workflow() -> Dict[str, Any]:
|
|
"""
|
|
Gibt den Workflow für die Account-Registrierung zurück.
|
|
|
|
Returns:
|
|
Dict[str, Any]: Workflow-Definition
|
|
"""
|
|
return {
|
|
"name": "X Account Registration",
|
|
"steps": [
|
|
{
|
|
"id": "navigate",
|
|
"name": "Navigate to X",
|
|
"description": "Zur X-Startseite navigieren",
|
|
"required": True,
|
|
"retry_count": 3
|
|
},
|
|
{
|
|
"id": "cookie_banner",
|
|
"name": "Handle Cookie Banner",
|
|
"description": "Cookie-Banner akzeptieren falls vorhanden",
|
|
"required": False,
|
|
"retry_count": 1
|
|
},
|
|
{
|
|
"id": "create_account",
|
|
"name": "Click Create Account",
|
|
"description": "Account erstellen Button klicken",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "fill_initial_form",
|
|
"name": "Fill Initial Form",
|
|
"description": "Name und E-Mail eingeben",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "enter_birthday",
|
|
"name": "Enter Birthday",
|
|
"description": "Geburtsdatum auswählen",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "next_birthday",
|
|
"name": "Continue After Birthday",
|
|
"description": "Weiter nach Geburtsdatum klicken",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "next_settings",
|
|
"name": "Continue Settings",
|
|
"description": "Weiter in Einstellungen klicken",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "email_verification",
|
|
"name": "Email Verification",
|
|
"description": "E-Mail-Verifizierungscode eingeben",
|
|
"required": True,
|
|
"retry_count": 3
|
|
},
|
|
{
|
|
"id": "set_password",
|
|
"name": "Set Password",
|
|
"description": "Passwort festlegen",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "skip_profile_picture",
|
|
"name": "Skip Profile Picture",
|
|
"description": "Profilbild überspringen",
|
|
"required": False,
|
|
"retry_count": 1
|
|
},
|
|
{
|
|
"id": "skip_username",
|
|
"name": "Skip Username",
|
|
"description": "Benutzername überspringen",
|
|
"required": False,
|
|
"retry_count": 1
|
|
},
|
|
{
|
|
"id": "skip_notifications",
|
|
"name": "Skip Notifications",
|
|
"description": "Benachrichtigungen überspringen",
|
|
"required": False,
|
|
"retry_count": 1
|
|
},
|
|
{
|
|
"id": "verify_success",
|
|
"name": "Verify Success",
|
|
"description": "Erfolgreiche Registrierung überprüfen",
|
|
"required": True,
|
|
"retry_count": 2
|
|
}
|
|
],
|
|
"timeout": 600, # 10 Minuten Gesamttimeout
|
|
"checkpoints": ["fill_initial_form", "email_verification", "verify_success"]
|
|
}
|
|
|
|
@staticmethod
|
|
def get_login_workflow() -> Dict[str, Any]:
|
|
"""
|
|
Gibt den Workflow für den Account-Login zurück.
|
|
|
|
Returns:
|
|
Dict[str, Any]: Workflow-Definition
|
|
"""
|
|
return {
|
|
"name": "X Account Login",
|
|
"steps": [
|
|
{
|
|
"id": "navigate",
|
|
"name": "Navigate to X",
|
|
"description": "Zur X-Startseite navigieren",
|
|
"required": True,
|
|
"retry_count": 3
|
|
},
|
|
{
|
|
"id": "cookie_banner",
|
|
"name": "Handle Cookie Banner",
|
|
"description": "Cookie-Banner akzeptieren falls vorhanden",
|
|
"required": False,
|
|
"retry_count": 1
|
|
},
|
|
{
|
|
"id": "click_login",
|
|
"name": "Click Login",
|
|
"description": "Anmelden Button klicken",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "enter_username",
|
|
"name": "Enter Username/Email",
|
|
"description": "Benutzername oder E-Mail eingeben",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "click_next",
|
|
"name": "Click Next",
|
|
"description": "Weiter klicken nach Benutzername",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "enter_password",
|
|
"name": "Enter Password",
|
|
"description": "Passwort eingeben",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "submit_login",
|
|
"name": "Submit Login",
|
|
"description": "Anmelden klicken",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "handle_challenges",
|
|
"name": "Handle Challenges",
|
|
"description": "Eventuelle Sicherheitsabfragen behandeln",
|
|
"required": False,
|
|
"retry_count": 3
|
|
},
|
|
{
|
|
"id": "verify_success",
|
|
"name": "Verify Success",
|
|
"description": "Erfolgreichen Login überprüfen",
|
|
"required": True,
|
|
"retry_count": 2
|
|
}
|
|
],
|
|
"timeout": 300, # 5 Minuten Gesamttimeout
|
|
"checkpoints": ["enter_username", "submit_login", "verify_success"]
|
|
}
|
|
|
|
@staticmethod
|
|
def get_verification_workflow() -> Dict[str, Any]:
|
|
"""
|
|
Gibt den Workflow für die Account-Verifizierung zurück.
|
|
|
|
Returns:
|
|
Dict[str, Any]: Workflow-Definition
|
|
"""
|
|
return {
|
|
"name": "X Account Verification",
|
|
"steps": [
|
|
{
|
|
"id": "check_verification_needed",
|
|
"name": "Check Verification",
|
|
"description": "Prüfen ob Verifizierung erforderlich",
|
|
"required": True,
|
|
"retry_count": 1
|
|
},
|
|
{
|
|
"id": "select_method",
|
|
"name": "Select Method",
|
|
"description": "Verifizierungsmethode auswählen",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "request_code",
|
|
"name": "Request Code",
|
|
"description": "Verifizierungscode anfordern",
|
|
"required": True,
|
|
"retry_count": 3
|
|
},
|
|
{
|
|
"id": "enter_code",
|
|
"name": "Enter Code",
|
|
"description": "Verifizierungscode eingeben",
|
|
"required": True,
|
|
"retry_count": 3
|
|
},
|
|
{
|
|
"id": "submit_verification",
|
|
"name": "Submit Verification",
|
|
"description": "Verifizierung abschließen",
|
|
"required": True,
|
|
"retry_count": 2
|
|
},
|
|
{
|
|
"id": "verify_success",
|
|
"name": "Verify Success",
|
|
"description": "Erfolgreiche Verifizierung überprüfen",
|
|
"required": True,
|
|
"retry_count": 2
|
|
}
|
|
],
|
|
"timeout": 300, # 5 Minuten Gesamttimeout
|
|
"checkpoints": ["enter_code", "verify_success"]
|
|
}
|
|
|
|
@staticmethod
|
|
def get_error_recovery_strategies() -> Dict[str, List[str]]:
|
|
"""
|
|
Gibt Fehlerbehandlungsstrategien zurück.
|
|
|
|
Returns:
|
|
Dict[str, List[str]]: Fehler und ihre Behandlungsstrategien
|
|
"""
|
|
return {
|
|
"rate_limit": [
|
|
"wait_exponential_backoff",
|
|
"rotate_proxy",
|
|
"change_user_agent",
|
|
"abort_with_retry_later"
|
|
],
|
|
"captcha": [
|
|
"solve_captcha_manual",
|
|
"solve_captcha_service",
|
|
"rotate_proxy_retry",
|
|
"abort_with_manual_intervention"
|
|
],
|
|
"suspended_account": [
|
|
"log_suspension",
|
|
"mark_account_suspended",
|
|
"abort_immediately"
|
|
],
|
|
"network_error": [
|
|
"retry_with_backoff",
|
|
"check_proxy_health",
|
|
"switch_proxy",
|
|
"retry_direct_connection"
|
|
],
|
|
"element_not_found": [
|
|
"wait_longer",
|
|
"refresh_page",
|
|
"check_alternate_selectors",
|
|
"take_screenshot_debug"
|
|
]
|
|
}
|
|
|
|
@staticmethod
|
|
def get_validation_rules() -> Dict[str, Any]:
|
|
"""
|
|
Gibt Validierungsregeln für verschiedene Eingaben zurück.
|
|
|
|
Returns:
|
|
Dict[str, Any]: Validierungsregeln
|
|
"""
|
|
return {
|
|
"username": {
|
|
"min_length": 1,
|
|
"max_length": 15,
|
|
"allowed_chars": r"^[a-zA-Z0-9_]+$",
|
|
"forbidden_patterns": ["twitter", "admin", "x.com"]
|
|
},
|
|
"password": {
|
|
"min_length": 8,
|
|
"max_length": 128,
|
|
"require_uppercase": False,
|
|
"require_lowercase": True,
|
|
"require_number": True,
|
|
"require_special": False
|
|
},
|
|
"email": {
|
|
"pattern": r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$",
|
|
"forbidden_domains": ["example.com", "test.com"]
|
|
},
|
|
"age": {
|
|
"minimum": 13,
|
|
"maximum": 120
|
|
}
|
|
} |