-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathbot.py
238 lines (208 loc) · 8.23 KB
/
bot.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
from os import environ
import os
import time
from unshortenit import UnshortenIt
from urllib.request import urlopen
from urllib.parse import urlparse
import aiohttp
from pyrogram import Client, filters
from pyshorteners import Shortener
from bs4 import BeautifulSoup
#from doodstream import DoodStream
import requests
import re
API_ID = environ.get('API_ID', '6')
API_HASH = environ.get('API_HASH', 'eb06d4abfb49dc3eeb1aeb98ae0f581e')
BOT_TOKEN = environ.get('BOT_TOKEN')
CHANNEL = environ.get('CUSTOM_FOOTER')
MDISK_TOKEN = environ.get('MDISK_TOKEN')
bot = Client('Doodstream bot',
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workers=50,
sleep_threshold=0)
START_TEXT = """
A Simple MDisk Uploader Bot.\n
➠ Send Me Any Direct Link, YouTube Link Or Video Link.\n
➠ I Will Upload To PDisk And Give Direct Link\n
➠ Made With ❤ BY @MoviesFlixers_DL"""
HELP_TEXT = """
<i>- Sᴇɴᴅ ᴍᴇ ᴀɴʏ ꜰɪʟᴇ (ᴏʀ) ᴍᴇᴅɪᴀ ꜰʀᴏᴍ ᴛᴇʟᴇɢʀᴀᴍ.</i>
<i>- I ᴡɪʟʟ ᴘʀᴏᴠɪᴅᴇ ᴇxᴛᴇʀɴᴀʟ ᴅɪʀᴇᴄᴛ Mdisk ᴅᴏᴡɴʟᴏᴀᴅ ʟɪɴᴋ !.</i>
<i>- Tʜɪs Pᴇʀᴍᴇᴀɴᴛ Lɪɴᴋ Wɪᴛʜ Fᴀsᴛᴇsᴛ Sᴘᴇᴇᴅ</i>\n
<u>🔸 𝗪𝗔𝗥𝗡𝗜𝗡𝗚 🚸</u>\n
<b>🔞 Pʀᴏɴ ᴄᴏɴᴛᴇɴᴛꜱ ʟᴇᴀᴅꜱ ᴛᴏ ᴘᴇʀᴍᴀɴᴇɴᴛ ʙᴀɴ ʏᴏᴜ.</b>\n
<i>Cᴏɴᴛᴀᴄᴛ ᴅᴇᴠᴇʟᴏᴘᴇʀ (ᴏʀ) ʀᴇᴘᴏʀᴛ ʙᴜɢꜱ</i> <b>: <a href='https://t.me/TeleRoid14'>[ツAʙʜɪsʜᴇᴋ Kᴜᴍᴀʀ]</a></b>"""
ABOUT_TEXT = """
<b>⚜ Mʏ ɴᴀᴍᴇ : MdiskVideoBot</b>\n
<b>🔸Vᴇʀꜱɪᴏɴ : <a href='https://t.me/+t1ko_FOJxhFiOThl'>3.0.1</a></b>\n
<b>🔹Sᴏᴜʀᴄᴇ : <a href='https://github.com/PredatorHackerzZ'>Cʟɪᴄᴋ Hᴇʀᴇ</a></b>\n
<b>🔸GitHub : <a href='https://GitHub.com/PredatorHackerzZ'>ツAʙʜɪsʜᴇᴋ Kᴜᴍᴀʀ</a></b>\n
<b>🔹Dᴇᴠᴇʟᴏᴘᴇʀ : <a href='https://telegram.me/Mrabhi2k3'>ツAʙʜɪsʜᴇᴋ Kᴜᴍᴀʀ </a></b>\n
<b>🔸Lᴀꜱᴛ ᴜᴘᴅᴀᴛᴇᴅ : <a href='https://telegram.me/Mrabhi2k3'>[ 04 - March - 2023 ] 12:17 ᴀᴍ</a></b>"""
START_BUTTONS = InlineKeyboardMarkup(
[[
InlineKeyboardButton('Hᴇʟᴘ', callback_data='help'),
InlineKeyboardButton('Aʙᴏᴜᴛ', callback_data='about'),
InlineKeyboardButton('Cʟᴏsᴇ', callback_data='close')
]]
)
HELP_BUTTONS = InlineKeyboardMarkup(
[[
InlineKeyboardButton('Hᴏᴍᴇ', callback_data='home'),
InlineKeyboardButton('Aʙᴏᴜᴛ', callback_data='about'),
InlineKeyboardButton('Cʟᴏsᴇ', callback_data='close')
]]
)
ABOUT_BUTTONS = InlineKeyboardMarkup(
[[
InlineKeyboardButton('Hᴏᴍᴇ', callback_data='home'),
InlineKeyboardButton('Hᴇʟᴘ', callback_data='help'),
InlineKeyboardButton('Cʟᴏsᴇ', callback_data='close')
]]
)
@bot.on_callback_query()
async def cb_data(bot, update):
if update.data == "home":
await update.message.edit_text(
text=START_TEXT.format(update.from_user.mention),
disable_web_page_preview=True,
reply_markup=START_BUTTONS
)
elif update.data == "help":
await update.message.edit_text(
text=HELP_TEXT,
disable_web_page_preview=True,
reply_markup=HELP_BUTTONS
)
elif update.data == "about":
await update.message.edit_text(
text=ABOUT_TEXT,
disable_web_page_preview=True,
reply_markup=ABOUT_BUTTONS
)
else:
await update.message.delete()
@bot.on_message(filters.command('start') & filters.private)
async def start(bot, message):
await message.reply(
f"**Hola 👋{message.chat.first_name}!**\n\n"
"**A Simple PDisk Uploader Bot.\n\n➠ Send Me Any Direct Link, YouTube Link Or Video Link I Will Upload To PDisk And Give Direct Link\n\nMade With ❤ BY @MoviesFlixers_DL**",
disable_web_page_preview=True,
reply_markup=START_BUTTONS
)
@bot.on_message(filters.text & filters.private)
async def Doodstream_uploader(bot, message):
new_string = str(message.text)
conv = await message.reply("Processing your given URL ⚡")
dele = conv["message_id"]
try:
Doodstream_link = await multi_Doodstream_up(new_string)
await bot.delete_messages(chat_id=message.chat.id, message_ids=dele)
await message.reply(f'**{Doodstream_link}**' , quote=True)
except Exception as e:
await message.reply(f'Error: {e}', quote=True)
@bot.on_message(filters.photo & filters.private)
async def Doodstream_uploader(bot, message):
new_string = str(message.caption)
conv = await message.reply("Processing your given URL ⚡")
dele = conv["message_id"]
try:
Doodstream_link = await multi_Doodstream_up(new_string)
if(len(Doodstream_link) > 1020):
await bot.delete_messages(chat_id=message.chat.id, message_ids=dele)
await message.reply(f'{Doodstream_link}' , quote=True)
else:
await bot.delete_messages(chat_id=message.chat.id, message_ids=dele)
await bot.send_photo(message.chat.id, message.photo.file_id, caption=f'**{Doodstream_link}**')
except Exception as e:
await message.reply(f'Error: {e}', quote=True)
'''async def get_ptitle(url):
if ('bit' in url ):
url = urlopen(url).geturl()
html_text = requests.get(url).text
soup = BeautifulSoup(html_text, 'html.parser')
for title in soup.find_all('title'):
pass
title = list(title.get_text())
title = title[8:]
str = 't.me/' + CHANNEL + ' '
for i in title:
str = str + i
lst = list(html_text.split(","))
c = 0
for i in lst:
if ("""/e/""" in i):
found = lst[c]
break
c += 1
# Doodstream.com link
Doodstream_video_id = list(found.split(":"))
video_id = Doodstream_video_id[2]
video_id = list(video_id.split(","))
v_id = video_id[0]
#v_len = len(v_id)
#v_id = v_id[1:v_len - 2]
v_url = 'https://vidzoop.blogspot.com/p/share-video.html?vid=' + v_id + '&m=1'
v_url = url
res = [str, v_url]
return res'''
async def Doodstream_up(link):
if ('bit' in link ):
#link = urlopen(link).geturl()
unshortener = UnshortenIt()
link = unshortener.unshorten(link)
title_new = urlparse(link)
title_new = os.path.basename(title_new.path)
title_Doodstream = '@' + CHANNEL + title_new
realaurl = 'https://diskuploader.mypowerdisk.com/v1/tp/cp'
param = {'token':f'{MDISK_TOKEN}','link':link}
res = requests.post(realaurl, json = param)
data = res.json()
data = dict(data)
print(data)
#bot.delete_messages(con)
v_url = data['sharelink']
return (v_url)
async def multi_Doodstream_up(ml_string):
list_string = ml_string.splitlines()
ml_string = ' \n'.join(list_string)
new_ml_string = list(map(str, ml_string.split(" ")))
new_ml_string = await remove_username(new_ml_string)
new_join_str = "".join(new_ml_string)
urls = re.findall(r'(https?://[^\s]+)', new_join_str)
nml_len = len(new_ml_string)
u_len = len(urls)
url_index = []
count = 0
for i in range(nml_len):
for j in range(u_len):
if (urls[j] in new_ml_string[i]):
url_index.append(count)
count += 1
new_urls = await new_Doodstream_url(urls)
url_index = list(dict.fromkeys(url_index))
i = 0
for j in url_index:
new_ml_string[j] = new_ml_string[j].replace(urls[i], new_urls[i])
i += 1
new_string = " ".join(new_ml_string)
return await addFooter(new_string)
async def new_Doodstream_url(urls):
new_urls = []
for i in urls:
time.sleep(0.2)
new_urls.append(await Doodstream_up(i))
return new_urls
async def remove_username(new_List):
for i in new_List:
if('@' in i or 't.me' in i or 'https://bit.ly/abcd' in i or 'https://bit.ly/123abcd' in i or 'telegra.ph' in i):
new_List.remove(i)
return new_List
async def addFooter(str):
footer = """
━━━━━━━━━━━━━━━
✪ »JOIN CHANNEL ➡️ t.me/""" + CHANNEL
return str + footer
bot.run()