-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
39 lines (27 loc) · 1.17 KB
/
bot.py
File metadata and controls
39 lines (27 loc) · 1.17 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
from telegram import Update
from telegram.ext import ApplicationBuilder, ContextTypes,MessageHandler, filters,CommandHandler
from userbot import client, upload_movie
import asyncio
TOKEN = "token"
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("سلام \n برای دانلود لینک ویدیو خود را بفرستید")
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("در حال اپلود \n ممکن است تا چند دقیقه طول بکشد")
url = update.message.text
msg = await upload_movie(url=url)
chat_id = update.effective_chat.id
await context.bot.forward_message(chat_id=chat_id,from_chat_id=msg.chat_id,message_id=msg.id)
await update.message.reply_text("ارسال شد")
async def main():
app = (
ApplicationBuilder()
.token(TOKEN)
.connect_timeout(60)
.read_timeout(300)
.write_timeout(300)
.build()
)
app.add_handler(CommandHandler('start',start))
app.add_handler(MessageHandler(filters.TEXT, handle_message))
await client.start()
await app.run_polling()