Skip to content

Commit

Permalink
pylint: auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TgCat committed Sep 17, 2024
1 parent 8b5f3a9 commit 3f37067
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
25 changes: 10 additions & 15 deletions userbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
import signal
import sys
import time
import requests

import heroku3
import requests
from fake_useragent import UserAgent

from .Config import Config
from .core.logger import logging
from .core.managers import edit_delete, edit_or_reply
from .core.session import catub
from .helpers.functions.converter import Convert
from .helpers.functions.musictool import *
from .helpers.utils.utils import runasync
from .sql_helper.globals import addgvar, delgvar, gvarstatus
from .core.managers import edit_delete, edit_or_reply

__version__ = "3.3.0"
__license__ = "GNU Affero General Public License v3.0"
Expand Down Expand Up @@ -53,25 +53,20 @@ def close_connection(*_):
def user_agent():
return agent.random


def upload_to_catbox(file_path, userhash=None):
url = 'https://catbox.moe/user/api.php'
data = {
'reqtype': 'fileupload',
'userhash': userhash
}

with open(file_path, 'rb') as f:
files = {
'fileToUpload': f
}
url = "https://catbox.moe/user/api.php"
data = {"reqtype": "fileupload", "userhash": userhash}

with open(file_path, "rb") as f:
files = {"fileToUpload": f}
response = requests.post(url, data=data, files=files)

if response.status_code == 200:
return response.text
else:
return f"Error: {response.status_code} - {response.text}"




UPSTREAM_REPO_URL = Config.UPSTREAM_REPO

Expand Down
11 changes: 10 additions & 1 deletion userbot/plugins/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@
from telethon.tl.functions.users import GetFullUserRequest
from urlextract import URLExtract

from userbot import BOTLOG_CHATID, catub, edit_delete, edit_or_reply, addgvar, delgvar, gvarstatus, upload_to_catbox
from userbot import (
BOTLOG_CHATID,
addgvar,
catub,
delgvar,
edit_delete,
edit_or_reply,
gvarstatus,
upload_to_catbox,
)
from userbot.core.logger import logging

plugin_category = "tools"
Expand Down
9 changes: 6 additions & 3 deletions userbot/plugins/webupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async def labstack(event):
async def _(event):
"To upload media to some online media sharing platforms"
editor = await edit_or_reply(event, "Processing ...")

# Capture the input string (file path) and selected transfer option
input_str = event.pattern_match.group(1)
selected_transfer = event.pattern_match.group(2)
Expand All @@ -147,7 +147,8 @@ async def _(event):
CMD_WEB = {
"fileio": 'curl -F "file=@{full_file_path}" https://file.io',
"anonfiles": 'curl -F "file=@{full_file_path}" https://api.anonfiles.com/upload',
"transfer": 'curl --upload-file "{full_file_path}" https://transfer.sh/' + os.path.basename(file_name),
"transfer": 'curl --upload-file "{full_file_path}" https://transfer.sh/'
+ os.path.basename(file_name),
"filebin": 'curl -X POST --data-binary "@{full_file_path}" -H "filename: {bare_local_name}" "https://filebin.net"',
"anonymousfiles": 'curl -F "file=@{full_file_path}" https://api.anonymousfiles.io/',
"vshare": 'curl -F "file=@{full_file_path}" https://api.vshare.is/upload',
Expand Down Expand Up @@ -181,7 +182,9 @@ async def _(event):
# Handle non-JSON responses from some sites
LOGS.info(str(e))
urls = re.findall(link_regex, t_response)
result = "**Uploaded File link/links :**\n" + "\n".join(urls) if urls else t_response
result = (
"**Uploaded File link/links :**\n" + "\n".join(urls) if urls else t_response
)
await editor.edit(result)
else:
await editor.edit(f"Error: {error}")
Expand Down

0 comments on commit 3f37067

Please sign in to comment.