-
Notifications
You must be signed in to change notification settings - Fork 105
/
terabox.py
121 lines (103 loc) · 4.79 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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ᴇɴᴅ ɪᴛ ᴛᴏ ʏᴏᴜ ✨."
join_button = InlineKeyboardButton("ᴊᴏɪɴ ❤️🚀", url="https://t.me/jetmirror")
developer_button = InlineKeyboardButton("ᴅᴇᴠᴇʟᴏᴘᴇʀ ⚡️", url="https://t.me/hrishikesh2861")
reply_markup = InlineKeyboardMarkup([[join_button, developer_button]])
video_file_id = "/app/Jet-Mirror.mp4"
if os.path.exists(video_file_id):
await client.send_video(
chat_id=message.chat.id,
video=video_file_id,
caption=reply_message,
reply_markup=reply_markup
)
else:
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):
if message.from_user is None:
logging.error("Message does not contain user information.")
return
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/jetmirror")
reply_markup = InlineKeyboardMarkup([[join_button]])
await message.reply_text("ʏᴏᴜ ᴍᴜsᴛ ᴊᴏɪɴ ᴍʏ ᴄʜᴀɴɴᴇʟ ᴛᴏ ᴜsᴇ ᴍᴇ.", reply_markup=reply_markup)
return
valid_domains = [
'terabox.com', 'nephobox.com', '4funbox.com', 'mirrobox.com',
'momerybox.com', 'teraboxapp.com', '1024tera.com',
'terabox.app', 'gibibox.com', 'goaibox.com', 'terasharelink.com', 'teraboxlink.com', 'terafileshare.com'
]
terabox_link = message.text.strip()
if not any(domain in terabox_link for domain in valid_domains):
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("Api has given a Broken Download Link. Dont Contact the Owner for this Issue.")
if __name__ == "__main__":
keep_alive()
app.run()