forked from oVo-HxBots/Terabox-Downloader-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
terabox.py
101 lines (86 loc) · 4.54 KB
/
terabox.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
import logging
import asyncio
from datetime import datetime
from pyrogram.enums import ChatMemberStatus
from dotenv import load_dotenv
from os import environ
import os
import time
from status import format_progress_bar
from video import download_video, upload_video
from web import keep_alive
load_dotenv('config.env', override=True)
logging.basicConfig(level=logging.INFO)
api_id = os.environ.get('TELEGRAM_API', '')
if len(api_id) == 0:
logging.error("TELEGRAM_API variable is missing! Exiting now")
exit(1)
api_hash = os.environ.get('TELEGRAM_HASH', '')
if len(api_hash) == 0:
logging.error("TELEGRAM_HASH variable is missing! Exiting now")
exit(1)
bot_token = os.environ.get('BOT_TOKEN', '')
if len(bot_token) == 0:
logging.error("BOT_TOKEN variable is missing! Exiting now")
exit(1)
dump_id = os.environ.get('DUMP_CHAT_ID', '')
if len(dump_id) == 0:
logging.error("DUMP_CHAT_ID variable is missing! Exiting now")
exit(1)
else:
dump_id = int(dump_id)
fsub_id = os.environ.get('FSUB_ID', '')
if len(fsub_id) == 0:
logging.error("FSUB_ID variable is missing! Exiting now")
exit(1)
else:
fsub_id = int(fsub_id)
app = Client("my_bot", api_id=api_id, api_hash=api_hash, bot_token=bot_token)
@app.on_message(filters.command("start"))
async def start_command(client, message):
sticker_message = await message.reply_sticker("CAACAgIAAxkBAAEYonplzwrczhVu3I6HqPBzro3L2JU6YAACvAUAAj-VzAoTSKpoG9FPRjQE")
await asyncio.sleep(2)
await sticker_message.delete()
user_mention = message.from_user.mention
reply_message = f"ᴡᴇʟᴄᴏᴍᴇ, {user_mention}.\n\n🌟 ɪ ᴀᴍ ᴀ ᴛᴇʀᴀʙᴏx ᴅᴏᴡɴʟᴏᴀᴅᴇʀ ʙᴏᴛ. sᴇɴᴅ ᴍᴇ ᴀɴʏ ᴛᴇʀᴀʙᴏx ʟɪɴᴋ ɪ ᴡɪʟʟ ᴅᴏᴡɴʟᴏᴀᴅ ᴡɪᴛʜɪɴ ғᴇᴡ sᴇᴄᴏɴᴅs ᴀɴᴅ sᴇɴᴅ ɪᴛ ᴛᴏ ʏᴏᴜ ✨.\n\nɪғ ʏᴏᴜʀ ғɪʟᴇ sɪᴢᴇ ɪs ᴍᴏʀᴇ ᴛʜᴀɴ 120ᴍʙ ɪᴛ ᴍɪɢʜᴛ ғᴀɪʟ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ."
join_button = InlineKeyboardButton("ᴊᴏɪɴ ❤️🚀", url="https://t.me/TakenInHindi")
developer_button = InlineKeyboardButton("ᴅᴇᴠᴇʟᴏᴘᴇʀ ⚡️", url="https://t.me/Kirodewal")
reply_markup = InlineKeyboardMarkup([[join_button, developer_button]])
await message.reply_text(reply_message, reply_markup=reply_markup)
async def is_user_member(client, user_id):
try:
member = await client.get_chat_member(fsub_id, user_id)
logging.info(f"User {user_id} membership status: {member.status}")
if member.status in [ChatMemberStatus.MEMBER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
return True
else:
return False
except Exception as e:
logging.error(f"Error checking membership status for user {user_id}: {e}")
return False
@app.on_message(filters.text)
async def handle_message(client, message: Message):
user_id = message.from_user.id
user_mention = message.from_user.mention
is_member = await is_user_member(client, user_id)
if not is_member:
join_button = InlineKeyboardButton("ᴊᴏɪɴ ❤️🚀", url="https://t.me/TakenInHindi")
reply_markup = InlineKeyboardMarkup([[join_button]])
await message.reply_text("ʏᴏᴜ ᴍᴜsᴛ ᴊᴏɪɴ ᴍʏ ᴄʜᴀɴɴᴇʟ ᴛᴏ ᴜsᴇ ᴍᴇ.", reply_markup=reply_markup)
return
terabox_link = message.text.strip()
if "terabox" not in terabox_link:
await message.reply_text("ᴘʟᴇᴀsᴇ sᴇɴᴅ ᴀ ᴠᴀʟɪᴅ ᴛᴇʀᴀʙᴏx ʟɪɴᴋ.")
return
reply_msg = await message.reply_text("sᴇɴᴅɪɴɢ ʏᴏᴜ ᴛʜᴇ ᴍᴇᴅɪᴀ...🤤")
try:
file_path, thumbnail_path, video_title = await download_video(terabox_link, reply_msg, user_mention, user_id)
await upload_video(client, file_path, thumbnail_path, video_title, reply_msg, dump_id, user_mention, user_id, message)
except Exception as e:
logging.error(f"Error handling message: {e}")
await reply_msg.edit_text("ғᴀɪʟᴇᴅ ᴛᴏ ᴘʀᴏᴄᴇss ʏᴏᴜʀ ʀᴇǫᴜᴇsᴛ.\nɪғ ʏᴏᴜʀ ғɪʟᴇ sɪᴢᴇ ɪs ᴍᴏʀᴇ ᴛʜᴀɴ 120ᴍʙ ɪᴛ ᴍɪɢʜᴛ ғᴀɪʟ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ.\nᴛʜɪs ɪs ᴛʜᴇ ᴛᴇʀᴀʙᴏx ɪssᴜᴇ, sᴏᴍᴇ ʟɪɴᴋs ᴀʀᴇ ʙʀᴏᴋᴇɴ, sᴏ ᴅᴏɴᴛ ᴄᴏɴᴛᴀᴄᴛ ʙᴏᴛ's ᴏᴡɴᴇʀ")
if __name__ == "__main__":
keep_alive()
app.run()