Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -6,7 +6,6 @@ import asyncio
|
|
| 6 |
|
| 7 |
# ==========================================
|
| 8 |
# πͺ THE HUGGING FACE TRICK
|
| 9 |
-
# Hugging Face requires a web server on port 7860 to keep the Space "Green" and Running.
|
| 10 |
# ==========================================
|
| 11 |
class DummyHandler(BaseHTTPRequestHandler):
|
| 12 |
def do_GET(self):
|
|
@@ -21,12 +20,13 @@ def keep_alive():
|
|
| 21 |
threading.Thread(target=keep_alive, daemon=True).start()
|
| 22 |
|
| 23 |
# ==========================================
|
| 24 |
-
# π€ BOT LIBRARIES
|
| 25 |
# ==========================================
|
| 26 |
from pyrogram import Client, filters
|
| 27 |
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
|
| 28 |
from pytgcalls import PyTgCalls
|
| 29 |
-
from pytgcalls.types import
|
|
|
|
| 30 |
import yt_dlp
|
| 31 |
import requests
|
| 32 |
import sqlite3
|
|
@@ -70,7 +70,11 @@ async def play_audio(client, message):
|
|
| 70 |
status = await message.reply_text("π Connecting to Voice Chat...")
|
| 71 |
try:
|
| 72 |
url, title = await asyncio.to_thread(get_stream_url, query, False)
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
await status.edit_text(f"π΅ **Playing Live in VC:** {title}")
|
| 75 |
except Exception as e:
|
| 76 |
await status.edit_text(f"π©Έ **VC Error:** {str(e)}")
|
|
@@ -82,7 +86,11 @@ async def play_video(client, message):
|
|
| 82 |
status = await message.reply_text("π Connecting to Video Chat...")
|
| 83 |
try:
|
| 84 |
url, title = await asyncio.to_thread(get_stream_url, query, True)
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
await status.edit_text(f"π¬ **Streaming Video Live in VC:** {title}")
|
| 87 |
except Exception as e:
|
| 88 |
await status.edit_text(f"π©Έ **VC Error:** {str(e)}")
|
|
@@ -90,7 +98,7 @@ async def play_video(client, message):
|
|
| 90 |
@app.on_message(filters.command("stop") & filters.group)
|
| 91 |
async def stop_stream(client, message):
|
| 92 |
try:
|
| 93 |
-
await call_py.
|
| 94 |
await message.reply_text("π Left the Voice Chat.")
|
| 95 |
except:
|
| 96 |
await message.reply_text("I am not in a Voice Chat right now.")
|
|
|
|
| 6 |
|
| 7 |
# ==========================================
|
| 8 |
# πͺ THE HUGGING FACE TRICK
|
|
|
|
| 9 |
# ==========================================
|
| 10 |
class DummyHandler(BaseHTTPRequestHandler):
|
| 11 |
def do_GET(self):
|
|
|
|
| 20 |
threading.Thread(target=keep_alive, daemon=True).start()
|
| 21 |
|
| 22 |
# ==========================================
|
| 23 |
+
# π€ BOT LIBRARIES (STABLE)
|
| 24 |
# ==========================================
|
| 25 |
from pyrogram import Client, filters
|
| 26 |
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
|
| 27 |
from pytgcalls import PyTgCalls
|
| 28 |
+
from pytgcalls.types.input_stream import AudioPiped, AudioVideoPiped
|
| 29 |
+
from pytgcalls.types.input_stream.quality import HighQualityAudio, HighQualityVideo
|
| 30 |
import yt_dlp
|
| 31 |
import requests
|
| 32 |
import sqlite3
|
|
|
|
| 70 |
status = await message.reply_text("π Connecting to Voice Chat...")
|
| 71 |
try:
|
| 72 |
url, title = await asyncio.to_thread(get_stream_url, query, False)
|
| 73 |
+
# Stable v2.1.0 Join Command
|
| 74 |
+
await call_py.join_group_call(
|
| 75 |
+
message.chat.id,
|
| 76 |
+
AudioPiped(url, HighQualityAudio())
|
| 77 |
+
)
|
| 78 |
await status.edit_text(f"π΅ **Playing Live in VC:** {title}")
|
| 79 |
except Exception as e:
|
| 80 |
await status.edit_text(f"π©Έ **VC Error:** {str(e)}")
|
|
|
|
| 86 |
status = await message.reply_text("π Connecting to Video Chat...")
|
| 87 |
try:
|
| 88 |
url, title = await asyncio.to_thread(get_stream_url, query, True)
|
| 89 |
+
# Stable v2.1.0 Video Command
|
| 90 |
+
await call_py.join_group_call(
|
| 91 |
+
message.chat.id,
|
| 92 |
+
AudioVideoPiped(url, HighQualityAudio(), HighQualityVideo())
|
| 93 |
+
)
|
| 94 |
await status.edit_text(f"π¬ **Streaming Video Live in VC:** {title}")
|
| 95 |
except Exception as e:
|
| 96 |
await status.edit_text(f"π©Έ **VC Error:** {str(e)}")
|
|
|
|
| 98 |
@app.on_message(filters.command("stop") & filters.group)
|
| 99 |
async def stop_stream(client, message):
|
| 100 |
try:
|
| 101 |
+
await call_py.leave_group_call(message.chat.id)
|
| 102 |
await message.reply_text("π Left the Voice Chat.")
|
| 103 |
except:
|
| 104 |
await message.reply_text("I am not in a Voice Chat right now.")
|