Initial commit: Hermes Agent skills collection
- Trading skills (OKX, dividend, lottery, quantitative) - Creative skills (ASCII art, diagrams, video) - Development skills (GitHub, debugging, TDD) - Research skills (arXiv, blog monitoring) - Productivity skills (email, documents, notes) - MCP integration skills - Custom user skills
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""Telethon proxy injection snippet — copy into any Telethon-based project."""
|
||||
|
||||
import os
|
||||
import re
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def get_proxy_config():
|
||||
"""Parse HTTP_PROXY env var into Telethon-compatible SOCKS5 proxy tuple.
|
||||
|
||||
Returns:
|
||||
tuple: (socks.SOCKS5, host, port) or None if no proxy configured
|
||||
"""
|
||||
try:
|
||||
import socks
|
||||
except ImportError:
|
||||
logger.warning("PySocks not installed — proxy disabled. Install with: pip install PySocks")
|
||||
return None
|
||||
|
||||
proxy_addr = os.getenv('HTTP_PROXY') or os.getenv('http_proxy')
|
||||
if not proxy_addr:
|
||||
return None
|
||||
|
||||
m = re.match(r'https?://([\d.]+):(\d+)', proxy_addr)
|
||||
if m:
|
||||
host, port = m.group(1), int(m.group(2))
|
||||
logger.info(f"Using SOCKS5 proxy: {host}:{port}")
|
||||
return (socks.SOCKS5, host, port)
|
||||
|
||||
logger.warning(f"Could not parse proxy URL: {proxy_addr}")
|
||||
return None
|
||||
|
||||
|
||||
# Usage:
|
||||
# proxy = get_proxy_config()
|
||||
# client = TelegramClient('session', api_id, api_hash, proxy=proxy)
|
||||
Reference in New Issue
Block a user