Skip to content

Commit

Permalink
make it better
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 8, 2021
1 parent 1b8a87e commit 2c43990
Show file tree
Hide file tree
Showing 12 changed files with 1,038 additions and 76 deletions.
Binary file added bot/Telegram MixDrop Bot.session
Binary file not shown.
13 changes: 13 additions & 0 deletions bot/plugins/helpers/call_back.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pyrogram import Client
from bot import LOGGER
import pyrogram
from bot.plugins.helpers.dowloader import fileDownload
@Client.on_callback_query()
async def server_selection(client, server):
# print(server)
server_name = server.data
if server_name == 'MixDrop':
# LOGGER.info(server)
await fileDownload(client, server)
if server_name == 'File.io':
await fileDownload(client, server)
48 changes: 48 additions & 0 deletions bot/plugins/helpers/dowloader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from pyrogram import Client
import time
from bot.plugins.upload_servers.fileio_upload import fileIO
from bot.plugins.upload_servers.mixdrop_upload import mixFileup
from bot.plugins.display import progress

async def fileDownload(client, bot):
file_path = ''
now = time.time()
upload_server = bot.data
userMsg = await client.edit_message_text(
chat_id=bot.from_user.id,
message_id=bot.message.message_id,
text="processing your request...please wait",
)
user_progress = userMsg
try:
file_path = await client.download_media(
message = userMsg.reply_to_message,
progress=progress,
progress_args=(
"Downloading...",
user_progress,
now
)
)
except Exception as error:
print(error)
print(file_path)
if upload_server == "MixDrop":
await mixFileup(file_path,client, bot, now)
if upload_server == "File.io":
await fileIO(file_path, client, bot, now)

# file_path = await client.download_media(
# message=bot.reply_to_message,
# progress=progress,
# progress_args=(
# "Downloading...",
# userMsg,
# now
# )
# )
# await client.edit_message_text(
# chat_id=bot.from_user.id,
# message_id=bot.message.message_id,
# text="hello"
# )
115 changes: 115 additions & 0 deletions bot/plugins/helpers/file_recive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# (c) Abhijith N T ;-)
# Thank you https://github.com/pyrogram/pyrogram :-)

from pyrogram import Client,filters
from bot import LOGGER
from hurry.filesize import size
from bot.plugins.keybord import server_select

@Client.on_message(filters.video)
async def userVideo(client, bot):
LOGGER.info(f"{bot.chat.id} - {bot.video.file_name}")
await client.send_message(
chat_id=bot.chat.id,
text = (
f"File Name: <code>{bot.video.file_name}</code>"
f"\nFile Size: <code>{size(bot.video.file_size)}</code>"
),
reply_markup=server_select(),
reply_to_message_id=bot.message_id
)
@Client.on_message(filters.document)
async def userDocument(client, bot):
LOGGER.info(f"{bot.chat.id} - {bot.document.file_name}")
await client.send_message(
chat_id=bot.chat.id,
text = (
f"File Name: <code>{bot.document.file_name}</code>"
f"\nFile Size: <code>{size(bot.document.file_size)}</code>"
),
reply_markup=server_select(),
reply_to_message_id=bot.message_id
)
@Client.on_message(filters.audio)
async def userAudio(client, bot):
LOGGER.info(f"{bot.chat.id} - {bot.audio.file_name}")
await client.send_message(
chat_id=bot.chat.id,
text = (
f"File Name: <code>{bot.audio.file_name}</code>"
f"\nFile Size: <code>{size(bot.audio.file_size)}</code>"
),
reply_markup=server_select(),
reply_to_message_id=bot.message_id
)












# @Client.on_message(filters.media)
# async def userMedia(client, bot):
# now = time.time()
# link = ''
# f_size = ''
# f_name = ''
# file = ''

# userMsg = await client.send_message(
# chat_id=bot.chat.id,
# text = "processing your request...please wait"
# )

# try:
# file = await bot.download(
# progress = progress,
# progress_args = (
# 'Downloading....',
# userMsg,
# now
# )
# )
# f_size = os.path.getsize(file)
# f_name = file.split('/')[-1]
# link = await mixFileup(file, userMsg, now)
# for i in link:
# pass
# LOGGER.info(f"""
# Download:{bot.from_user.id}:
# File Name:{f_name}
# Link:{link}
# """)
# except Exception as error:
# print(error)
# await bot.reply(
# text = f"""
# File Name: {f_name}
# \nSIZE: {size(f_size)}
# """,
# reply_markup=InlineKeyboardMarkup(
# [
# [
# InlineKeyboardButton(
# "DOWNLOAD !",
# url=f"{link}"
# ),
# ],
# ]
# )
# )
# try:
# os.remove(file)
# LOGGER.info(f"{bot.from_user.id} {file} Remove")
# except Exception as error:
# LOGGER.info(f"{file} not Remove")
# print(error)
73 changes: 0 additions & 73 deletions bot/plugins/helpers/get_file.py

This file was deleted.

36 changes: 36 additions & 0 deletions bot/plugins/keybord/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from yarl import URL
import bot
from pyrogram.types import (
InlineKeyboardMarkup,
InlineKeyboardButton
)



def server_select():
upload_selection = []
upload_selection=[
[
InlineKeyboardButton(
"MixDrop",
callback_data = "MixDrop"
),
InlineKeyboardButton(
"File.io",
callback_data = "File.io"
)
],
]
return InlineKeyboardMarkup(upload_selection)

def downloadButton(link):
dl_button = []
dl_button = [
[
InlineKeyboardButton(
"DOWNLOAD URL",
url=f"{link}"
)
]
]
return InlineKeyboardMarkup(dl_button)
32 changes: 32 additions & 0 deletions bot/plugins/upload_servers/fileio_upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import requests
import json
from bot.plugins.keybord import downloadButton
from bot.plugins.display.time import time_data

async def fileIO(file_name, client, bot, s_time):
print(1)
try:
await client.edit_message_text(
chat_id=bot.from_user.id,
message_id=bot.message.message_id,
text="Uploadig to File.IO",
)
files = {
'file': (file_name, open( file_name, 'rb')),
}
response = await requests.post('https://file.io/', files=files)
response = await json.loads(response.text)
dl_b = response['link']
await downloadButton(dl_b)
await client.edit_message_text(
chat_id=bot.from_user.id,
message_id=bot.message.message_id,
text=f"Uploaded...100% in {time_data(s_time)}",
)
await client.client.send_message(
chat_id=bot.from_user.id,
text=f"Enjoy Enjoy..",
reply_markup=downloadButton()
)
except Exception as error:
print(error)
File renamed without changes.
Loading

0 comments on commit 2c43990

Please sign in to comment.