Spaces:
Sleeping
Sleeping
first
Browse files- config.py +11 -0
- main.py +34 -0
- plugins/__pycache__/commands.cpython-312.pyc +0 -0
- plugins/__pycache__/paste.cpython-312.pyc +0 -0
- plugins/__pycache__/upload.cpython-312.pyc +0 -0
- plugins/commands.py +8 -0
- plugins/paste.py +38 -0
- plugins/upload.py +52 -0
- requirements.txt +7 -0
- utils/__pycache__/keep_alive.cpython-311.pyc +0 -0
- utils/__pycache__/keep_alive.cpython-312.pyc +0 -0
- utils/keep_alive.py +42 -0
config.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
load_dotenv()
|
4 |
+
BOT_TOKEN = os.getenv("BOT_TOKEN")
|
5 |
+
PASTEBIN_DEV_KEY = os.getenv("PASTEBIN_DEV_KEY")
|
6 |
+
PASTEBIN_USER_NAME = os.getenv("PASTEBIN_USER_NAME")
|
7 |
+
PASTEBIN_USER_PASSWORD = os.getenv("PASTEBIN_USER_PASSWORD")
|
8 |
+
MAX_FILE_SIZE = 2e8
|
9 |
+
API_ID = os.getenv("API_ID")
|
10 |
+
API_HASH = os.getenv("API_HASH")
|
11 |
+
REPL_URL = os.getenv("REPL_URL")
|
main.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
|
3 |
+
# uvloop is optional, but it's recommended to install it for better performance of pyrogram
|
4 |
+
try:
|
5 |
+
import uvloop
|
6 |
+
except:
|
7 |
+
print("uvloop is not installed")
|
8 |
+
|
9 |
+
from pyrogram import Client
|
10 |
+
from config import API_ID, API_HASH, BOT_TOKEN
|
11 |
+
from utils import keep_alive
|
12 |
+
|
13 |
+
if __name__ == '__main__':
|
14 |
+
|
15 |
+
# If you are deploying on Replit, you can use this code to keep your bot alive
|
16 |
+
if 'y' in input('Are you deploying on Replit? (y/n): ').lower():
|
17 |
+
from config import REPL_URL
|
18 |
+
keep_alive.awake(REPL_URL, False)
|
19 |
+
|
20 |
+
# Setting up uvloop
|
21 |
+
try:
|
22 |
+
uvloop.install()
|
23 |
+
except:
|
24 |
+
print("Could not apply uvloop on project")
|
25 |
+
|
26 |
+
# Defining path to plugins
|
27 |
+
plugins = dict(root="plugins")
|
28 |
+
|
29 |
+
# Defining the pyrogram client's instance
|
30 |
+
Client("UploadBot",
|
31 |
+
api_id=API_ID,
|
32 |
+
api_hash=API_HASH,
|
33 |
+
bot_token=BOT_TOKEN,
|
34 |
+
plugins=plugins).run()
|
plugins/__pycache__/commands.cpython-312.pyc
ADDED
Binary file (826 Bytes). View file
|
|
plugins/__pycache__/paste.cpython-312.pyc
ADDED
Binary file (2.24 kB). View file
|
|
plugins/__pycache__/upload.cpython-312.pyc
ADDED
Binary file (2.99 kB). View file
|
|
plugins/commands.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pyrogram import Client, filters
|
2 |
+
|
3 |
+
@Client.on_message(filters.command('start') & filters.private & ~filters.bot)
|
4 |
+
async def start(client, message):
|
5 |
+
await message.reply_text(
|
6 |
+
f'Hi {message.from_user.first_name}!\n\n'
|
7 |
+
f'Write a text or send me a file and I will generate a link for it.\n\n'
|
8 |
+
)
|
plugins/paste.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
from pyrogram import Client, filters
|
4 |
+
from config import PASTEBIN_DEV_KEY, PASTEBIN_USER_NAME, PASTEBIN_USER_PASSWORD
|
5 |
+
|
6 |
+
def generate_user_key():
|
7 |
+
login_data = {
|
8 |
+
'api_dev_key': PASTEBIN_DEV_KEY,
|
9 |
+
'api_user_name': PASTEBIN_USER_NAME,
|
10 |
+
'api_user_password': PASTEBIN_USER_PASSWORD
|
11 |
+
}
|
12 |
+
login = requests.post(
|
13 |
+
"https://pastebin.com/api/api_login.php", data=login_data)
|
14 |
+
if login.status_code != 200:
|
15 |
+
raise ValueError("Failed to generate user key")
|
16 |
+
return login.text
|
17 |
+
|
18 |
+
def paste(message, title="GenAtoZBot"):
|
19 |
+
user_key = generate_user_key()
|
20 |
+
data = {
|
21 |
+
'api_option': 'paste',
|
22 |
+
'api_dev_key': PASTEBIN_DEV_KEY,
|
23 |
+
'api_paste_code': message,
|
24 |
+
'api_paste_name': title,
|
25 |
+
'api_user_key': user_key
|
26 |
+
}
|
27 |
+
r = requests.post("https://pastebin.com/api/api_post.php", data=data)
|
28 |
+
if r.status_code != 200:
|
29 |
+
raise ValueError("Failed to paste text")
|
30 |
+
return r.text
|
31 |
+
|
32 |
+
@Client.on_message(filters.text & filters.private)
|
33 |
+
async def paste_text(client, message):
|
34 |
+
try:
|
35 |
+
paste_url = paste(message.text)
|
36 |
+
await message.reply_text(f"Paste created: {paste_url}", quote=True)
|
37 |
+
except ValueError as e:
|
38 |
+
await message.reply_text(f"Failed to paste text: {str(e)}", quote=True)
|
plugins/upload.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import requests
|
3 |
+
from pyrogram import Client, filters
|
4 |
+
from config import MAX_FILE_SIZE
|
5 |
+
|
6 |
+
|
7 |
+
def upload_to_transfersh(file_path):
|
8 |
+
url = 'https://0x0.st'
|
9 |
+
file = {'file': ('@' + file_path, open(file_path, 'rb'))}
|
10 |
+
response = requests.post(url, files=file)
|
11 |
+
download_link = response.content.decode('utf-8')
|
12 |
+
return download_link
|
13 |
+
|
14 |
+
|
15 |
+
@Client.on_message(filters.private
|
16 |
+
& (filters.document | filters.photo | filters.audio | filters.video))
|
17 |
+
async def upload(client, message):
|
18 |
+
|
19 |
+
|
20 |
+
if (message.document and message.document.file_size > MAX_FILE_SIZE):
|
21 |
+
await message.reply_text(
|
22 |
+
f'File is too big.\n\nFile size: {message.document.file_size}'
|
23 |
+
)
|
24 |
+
return
|
25 |
+
if (message.photo and message.photo.file_size > MAX_FILE_SIZE):
|
26 |
+
await message.reply_text(
|
27 |
+
f'Photo is too big.\n\nFile size: {message.photo.file_size}'
|
28 |
+
)
|
29 |
+
return
|
30 |
+
if (message.audio and message.audio.file_size > MAX_FILE_SIZE):
|
31 |
+
await message.reply_text(
|
32 |
+
f'Audio is too big.\n\nFile size: {message.audio.file_size}'
|
33 |
+
)
|
34 |
+
return
|
35 |
+
if (message.video and message.video.file_size > MAX_FILE_SIZE):
|
36 |
+
await message.reply_text(
|
37 |
+
f'Video is too big.\n\nFile size: {message.video.file_size}'
|
38 |
+
)
|
39 |
+
return
|
40 |
+
|
41 |
+
|
42 |
+
path = await message.download()
|
43 |
+
if not path:
|
44 |
+
return
|
45 |
+
|
46 |
+
link = upload_to_transfersh(path).removesuffix('\n')
|
47 |
+
|
48 |
+
os.remove(path)
|
49 |
+
|
50 |
+
await message.reply_text(f"File's Download Page:\n\n{link}"
|
51 |
+
|
52 |
+
f'\n\nDownload Link might expire after 30 days...', quote=True)
|
requirements.txt
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
pyrogram
|
2 |
+
tgcrypto
|
3 |
+
uvloop
|
4 |
+
flask
|
5 |
+
requests
|
6 |
+
python-dotenv
|
7 |
+
gunicorn
|
utils/__pycache__/keep_alive.cpython-311.pyc
ADDED
Binary file (1.98 kB). View file
|
|
utils/__pycache__/keep_alive.cpython-312.pyc
ADDED
Binary file (1.71 kB). View file
|
|
utils/keep_alive.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask
|
2 |
+
from threading import Thread
|
3 |
+
import random
|
4 |
+
import time
|
5 |
+
import requests
|
6 |
+
import logging
|
7 |
+
|
8 |
+
app = Flask("")
|
9 |
+
|
10 |
+
|
11 |
+
@app.route("/")
|
12 |
+
def home():
|
13 |
+
return "You have found the home of a Python program!"
|
14 |
+
|
15 |
+
|
16 |
+
def run():
|
17 |
+
app.run()
|
18 |
+
|
19 |
+
|
20 |
+
def ping(target, debug):
|
21 |
+
while True:
|
22 |
+
r = requests.get(target)
|
23 |
+
if debug == True:
|
24 |
+
print("Status Code: " + str(r.status_code))
|
25 |
+
time.sleep(random.randint(
|
26 |
+
180, 300)) # alternate ping time between 3 and 5 minutes
|
27 |
+
|
28 |
+
|
29 |
+
def awake(target, debug=False):
|
30 |
+
log = logging.getLogger("werkzeug")
|
31 |
+
log.disabled = True
|
32 |
+
app.logger.disabled = True
|
33 |
+
t = Thread(target=run)
|
34 |
+
r = Thread(
|
35 |
+
target=ping,
|
36 |
+
args=(
|
37 |
+
target,
|
38 |
+
debug,
|
39 |
+
),
|
40 |
+
)
|
41 |
+
t.start()
|
42 |
+
r.start()
|