diff --git a/bot.py b/bot.py
index e71d05b..4aff5ca 100644
--- a/bot.py
+++ b/bot.py
@@ -157,6 +157,48 @@ def fetch_url_content(url):
logger.error(f" ❌ Error: {e}")
return {"title": "Fetch failed", "status": "error", "error": str(e), "content": ""}
+# Get GitHub repo info from API
+def get_github_content(url):
+ """Fetch GitHub repo README via API"""
+ logger.debug(f" Fetching GitHub repo info from API")
+
+ match = re.search(r'github\.com/([^/]+)/([^/]+)', url)
+ if not match:
+ return None
+
+ owner, repo = match.groups()
+
+ try:
+ # Try to get README
+ response = requests.get(
+ f"https://api.github.com/repos/{owner}/{repo}/readme",
+ headers={"Accept": "application/vnd.github.v3.raw"},
+ timeout=5
+ )
+
+ if response.status_code == 200:
+ content = response.text[:2000]
+ logger.debug(f" Got README: {len(content)} chars")
+ return content
+
+ # Fallback: get repo info from API
+ response = requests.get(
+ f"https://api.github.com/repos/{owner}/{repo}",
+ timeout=5
+ )
+
+ if response.status_code == 200:
+ data = response.json()
+ desc = data.get("description", "")
+ if desc:
+ logger.debug(f" Got repo description: {desc}")
+ return desc
+
+ except Exception as e:
+ logger.warning(f" GitHub API error: {e}")
+
+ return None
+
# Extract clean text from HTML
def extract_text_from_html(html):
"""Extract readable text from HTML"""
@@ -180,6 +222,7 @@ def extract_text_from_html(html):
# Remove remaining HTML tags but keep text
text = re.sub(r'
', '\n', text, flags=re.IGNORECASE)
text = re.sub(r'
]*>', '\n', text, flags=re.IGNORECASE)
+ text = re.sub(r'