Skip to content

Commit

Permalink
#2 error
Browse files Browse the repository at this point in the history
  • Loading branch information
abhint authored Jan 11, 2021
1 parent b58b3cd commit 50e8b7c
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 76 deletions.
5 changes: 5 additions & 0 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# https://github.com/Abhijith-cloud
# (c) Abhijith N T ;-)
# Thank you https://github.com/pyrogram/pyrogram :-)
#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram

import os
import logging
Expand Down
5 changes: 3 additions & 2 deletions bot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/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 :-)
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram


from bot import (
BOT_TOKEN,
Expand Down
6 changes: 6 additions & 0 deletions bot/plugins/cmd/cmd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram

from pyrogram import Client,filters
from bot import msg

Expand Down
5 changes: 3 additions & 2 deletions bot/plugins/display/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/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 :-)
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram


from bot.plugins.display.time import time_data

Expand Down
5 changes: 5 additions & 0 deletions bot/plugins/display/time.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# Copyright ABHIJITH N T

import time

def time_data(start_time):
Expand Down
11 changes: 8 additions & 3 deletions bot/plugins/helpers/call_back.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram

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):
await fileDownload(client, server)
await fileDownload(client, server)
36 changes: 16 additions & 20 deletions bot/plugins/helpers/dowloader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from pyrogram import Client
import time
#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram

from bot.plugins.upload_servers.fileio_upload import fileIO
from bot.plugins.upload_servers.mixdrop_upload import mixFileup
from bot.plugins.display import progress
import os, time
from pyrogram.errors import FloodWait

async def fileDownload(client, bot):
file_path = ''
Expand All @@ -22,27 +28,17 @@ async def fileDownload(client, bot):
"Downloading...",
user_progress,
now
)
)
)
except Exception as error:
print(error)
print(file_path)
except FloodWait as e:
print(time.sleep(e.x))

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"
# )
try:
os.remove(file_path)
except OSError as error:
print("Error: %s - %s." % (error.filename, error.strerror))
115 changes: 115 additions & 0 deletions bot/plugins/helpers/incoming_messages.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
# Copyright 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)
27 changes: 16 additions & 11 deletions bot/plugins/keybord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
)


#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram

def server_select():
upload_selection = []
Expand All @@ -23,14 +28,14 @@ def server_select():
]
return InlineKeyboardMarkup(upload_selection)

def downloadButton(link):
dl_button = []
dl_button = [
[
InlineKeyboardButton(
"DOWNLOAD URL",
url=f"{link}"
)
]
]
return InlineKeyboardMarkup(dl_button)
# def downloadButton(link):
# dl_button = []
# dl_button = [
# [
# InlineKeyboardButton(
# "DOWNLOAD URL",
# url=f"{link}"
# )
# ]
# ]
# return InlineKeyboardMarkup(dl_button)
72 changes: 51 additions & 21 deletions bot/plugins/upload_servers/fileio_upload.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,62 @@
import requests
import json
from bot.plugins.keybord import downloadButton
#!/usr/bin/env python3
# This is bot coded by Abhijith-cloud and used for educational purposes only
# https://github.com/Abhijith-cloud
# Copyright ABHIJITH N T
# Thank you https://github.com/pyrogram/pyrogram


import aiohttp
import os, time
from hurry.filesize import size
from bot.plugins.display.time import time_data
from pyrogram.errors import FloodWait
from pyrogram.types import (
InlineKeyboardMarkup,
InlineKeyboardButton
)



async def fileIO(file_name, client, bot, s_time):
print(1)
async def fileIO(file, client, bot, s_time):
file_size = size(os.path.getsize(file))
file_name = file.split('/')[-1]
try:
await client.edit_message_text(
chat_id=bot.from_user.id,
message_id=bot.message.message_id,
text="Uploadig to File.IO",
text="Uploadig to File.IO"
)
files = {
'file': (file_name, open( file_name, 'rb')),
}
response = 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(
async with aiohttp.ClientSession() as session:
files = {
'file': open(file, 'rb')
}
response = await session.post('https://file.io/', data=files)
link = await response.json()
dl_b = link['link']
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(
text=f"Uploaded...100% in {time_data(s_time)}"
)
await client.send_message(
chat_id=bot.from_user.id,
text=f"Enjoy Enjoy..",
reply_markup=downloadButton()
text=(
f"File Name: <code>{file_name}</code>"
f"\nFile Size: <code>{file_size}</code>"
),
reply_markup=InlineKeyboardMarkup(
[[
InlineKeyboardButton(
"🔗 DOWNLOAD URL",
url=f"{dl_b}"
)
],
[
InlineKeyboardButton(
"🗂 SOURCE",
url = "https://github.com/Abhijith-cloud/"
)
]])
)
except Exception as error:
print(error)
except FloodWait as error:
print(time.sleep(error.x))
Loading

0 comments on commit 50e8b7c

Please sign in to comment.