Relay / meet_bot.py
FredyHoundayi's picture
Initial commit: Whisper WebSocket API for Hugging Face
da12a71
import asyncio
from playwright.async_api import async_playwright
MEET_URL = "https://meet.google.com/jhg-zqvt-jdj"
BOT_NAME = "Relay.AI"
PROFILE_PATH = "/home/fredy/.config/google-chrome/Default"
async def click_join_button(page):
print("Searching for join button...")
# laisser Meet charger complètement l'UI
await page.wait_for_timeout(6000)
buttons = page.locator("button")
count = await buttons.count()
print("Buttons detected:", count)
for i in range(count):
btn = buttons.nth(i)
try:
text = (await btn.inner_text()).lower()
print("BTN:", text)
if any(word in text for word in [
"join", "ask", "rejoindre", "participer"
]):
print("Clicking join button:", text)
await btn.click()
return True
except:
pass
print("Join button not found")
return False
async def run():
async with async_playwright() as p:
context = await p.chromium.launch_persistent_context(
user_data_dir=PROFILE_PATH,
headless=False,
args=[
"--start-maximized",
"--use-fake-ui-for-media-stream",
"--autoplay-policy=no-user-gesture-required",
"--disable-blink-features=AutomationControlled"
],
)
page = context.pages[0] if context.pages else await context.new_page()
print("Opening Google Meet...")
await page.goto(MEET_URL)
await page.wait_for_timeout(5000)
# si entrée en tant qu'invité
try:
await page.wait_for_selector('input[type="text"]', timeout=8000)
print("Typing bot name...")
await page.fill('input[type="text"]', BOT_NAME)
except:
print("Google account already logged in")
await page.wait_for_timeout(2000)
# couper caméra
try:
cam_btn = page.locator('[aria-label*="camera"]')
await cam_btn.first.click(timeout=5000)
print("Camera disabled")
except:
pass
# couper micro
try:
mic_btn = page.locator('[aria-label*="microphone"]')
await mic_btn.first.click(timeout=5000)
print("Microphone muted")
except:
pass
# rejoindre réunion
joined = await click_join_button(page)
if joined:
print("Bot requested access / joined meeting")
else:
print("Manual approval may be required")
# rester connecté
await page.wait_for_timeout(10_000_000)
asyncio.run(run())