-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
39 lines (30 loc) · 1.37 KB
/
Copy pathbot.py
File metadata and controls
39 lines (30 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import subprocess
from telegram import Update
from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, ContextTypes, filters
from dotenv import load_dotenv
load_dotenv()
TOKEN = 'TELEGRAM_BOT_TOKEN'
# Start command
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("👋 Send me an email address to search.")
# When user sends an email
async def handle_email(update: Update, context: ContextTypes.DEFAULT_TYPE):
email = update.message.text.strip()
await update.message.reply_text(f"🔍 Searching for: {email}...")
try:
# Run Holehe using subprocess
result = subprocess.run(['holehe', email], capture_output=True, text=True)
output = result.stdout or result.stderr
if output:
await update.message.reply_text(f"📄 Results:\n\n{output[:4000]}") # limit to avoid Telegram limit
else:
await update.message.reply_text("⚠️ No results found or an error occurred.")
except Exception as e:
await update.message.reply_text(f"❌ Error: {str(e)}")
# Main function
if __name__ == '__main__':
app = ApplicationBuilder().token(TOKEN).build()
app.add_handler(CommandHandler("start", start))
app.add_handler(MessageHandler(filters.TEXT & (~filters.COMMAND), handle_email))
print("🤖 Bot is running...")
app.run_polling()