mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
refactor: remove reimported module (#301)
* refactor: remove reimported module
A module or an import name is reimported multiple times. This can be confusing and should be fixed.
Please refer to the occurrence message to see the reimported name and the line number where it was imported for the first time.
* style: format code with isort, Ruff Formatter and Yapf
This commit fixes the style issues introduced in f7922fd according to the output
from isort, Ruff Formatter and Yapf.
Details: https://github.com/yasirarism/MissKatyPyro/pull/301
---------
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
parent
e33a58a3f2
commit
88558990d0
2 changed files with 62 additions and 32 deletions
|
|
@ -5,23 +5,22 @@ import io
|
|||
import json
|
||||
import os
|
||||
import pickle
|
||||
import platform
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
from inspect import getfullargspec
|
||||
from logging import getLogger
|
||||
from shutil import disk_usage
|
||||
from time import time
|
||||
from typing import Any, Optional, Tuple
|
||||
|
||||
import aiohttp
|
||||
import contextlib
|
||||
import cloudscraper
|
||||
import requests
|
||||
import platform
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
from bs4 import BeautifulSoup
|
||||
from logging import getLogger
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from psutil import Process, boot_time, cpu_count, cpu_percent
|
||||
from psutil import disk_usage as disk_usage_percent
|
||||
|
|
@ -29,15 +28,22 @@ from psutil import net_io_counters, virtual_memory
|
|||
from pyrogram import Client
|
||||
from pyrogram import __version__ as pyrover
|
||||
from pyrogram import enums, filters
|
||||
from pyrogram.errors import ChatSendPhotosForbidden, FloodWait, MessageTooLong, PeerIdInvalid, ChatSendPlainForbidden, ReactionInvalid
|
||||
from pyrogram.errors import (
|
||||
ChatSendPhotosForbidden,
|
||||
ChatSendPlainForbidden,
|
||||
FloodWait,
|
||||
MessageTooLong,
|
||||
PeerIdInvalid,
|
||||
ReactionInvalid,
|
||||
)
|
||||
from pyrogram.raw.types import UpdateBotStopped
|
||||
from pyrogram.types import (
|
||||
InlineKeyboardButton,
|
||||
InlineKeyboardMarkup,
|
||||
InputMediaPhoto,
|
||||
LabeledPrice,
|
||||
PreCheckoutQuery,
|
||||
Message,
|
||||
PreCheckoutQuery,
|
||||
)
|
||||
|
||||
from database.gban_db import add_gban_user, is_gbanned_user, remove_gban_user
|
||||
|
|
@ -92,7 +98,7 @@ async def star_donation(self: Client, ctx: Message):
|
|||
currency="XTR",
|
||||
prices=[LabeledPrice(label="Donation", amount=amount)],
|
||||
message_thread_id=ctx.message_thread_id,
|
||||
payload="stars"
|
||||
payload="stars",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -104,17 +110,23 @@ async def pre_checkout_query_handler(_: Client, query: PreCheckoutQuery):
|
|||
@app.on_message(filters.private, group=3)
|
||||
async def successful_payment_handler(_: Client, message: Message):
|
||||
if message.successful_payment:
|
||||
await message.reply(f"Thanks for support for <b>{message.successful_payment.total_amount} {message.successful_payment.currency}</b>! Your transaction ID is : <code>{message.successful_payment.telegram_payment_charge_id}</code>")
|
||||
await message.reply(
|
||||
f"Thanks for support for <b>{message.successful_payment.total_amount} {message.successful_payment.currency}</b>! Your transaction ID is : <code>{message.successful_payment.telegram_payment_charge_id}</code>"
|
||||
)
|
||||
|
||||
|
||||
@app.on_message(filters.command(["refund_star"], COMMAND_HANDLER))
|
||||
async def refund_star_payment(client: Client, message: Message):
|
||||
if len(message.command) == 1:
|
||||
return await message.reply_msg("Please input telegram_payment_charge_id after command.")
|
||||
return await message.reply_msg(
|
||||
"Please input telegram_payment_charge_id after command."
|
||||
)
|
||||
trx_id = message.command[1]
|
||||
try:
|
||||
await client.refund_star_payment(message.from_user.id, trx_id)
|
||||
await message.reply_msg(f"Great {message.from_user.mention}, your stars has been refunded to your balance.")
|
||||
await message.reply_msg(
|
||||
f"Great {message.from_user.mention}, your stars has been refunded to your balance."
|
||||
)
|
||||
except Exception as e:
|
||||
await message.reply_msg(e)
|
||||
|
||||
|
|
@ -131,8 +143,12 @@ async def log_file(_, ctx: Message, strings):
|
|||
data = {
|
||||
"value": content,
|
||||
}
|
||||
pastelog = await fetch.post("https://paste.yasirapi.eu.org/save", data=data, follow_redirects=True)
|
||||
await msg.edit_msg(f"<a href='{pastelog.url}'>Here the Logs</a>\nlog size: {get_readable_file_size(os.path.getsize('MissKatyLogs.txt'))}")
|
||||
pastelog = await fetch.post(
|
||||
"https://paste.yasirapi.eu.org/save", data=data, follow_redirects=True
|
||||
)
|
||||
await msg.edit_msg(
|
||||
f"<a href='{pastelog.url}'>Here the Logs</a>\nlog size: {get_readable_file_size(os.path.getsize('MissKatyLogs.txt'))}"
|
||||
)
|
||||
except Exception:
|
||||
await ctx.reply_document(
|
||||
"MissKatyLogs.txt",
|
||||
|
|
@ -171,10 +187,15 @@ async def donate(self: Client, ctx: Message):
|
|||
"https://img.yasirweb.eu.org/file/ee74ce527fb8264b54691.jpg",
|
||||
caption="Hi, If you find this bot useful, you can make a donation to the account below. Because this bot server uses VPS and is not free. Thank You..\n\n<b>Indonesian Payment:</b>\n<b>QRIS:</b> https://img.yasirweb.eu.org/file/ee74ce527fb8264b54691.jpg (Yasir Store)\n<b>Bank Jago:</b> 109641845083 (Yasir Aris M)\n\nFor international people can use PayPal to support me or via GitHub Sponsor:\nhttps://paypal.me/yasirarism\nhttps://github.com/sponsors/yasirarism\n\n<b>Source:</b> @BeriKopi",
|
||||
reply_to_message_id=ctx.id,
|
||||
message_effect_id=5159385139981059251 if ctx.chat.type.value == "private" else None
|
||||
message_effect_id=5159385139981059251
|
||||
if ctx.chat.type.value == "private"
|
||||
else None,
|
||||
)
|
||||
except (ChatSendPlainForbidden, ChatSendPhotosForbidden):
|
||||
await self.send_message(LOG_CHANNEL, f"❗️ <b>WARNING</b>\nI'm leaving from {ctx.chat.id} since i didn't have sufficient admin permissions.")
|
||||
await self.send_message(
|
||||
LOG_CHANNEL,
|
||||
f"❗️ <b>WARNING</b>\nI'm leaving from {ctx.chat.id} since i didn't have sufficient admin permissions.",
|
||||
)
|
||||
await ctx.chat.leave()
|
||||
|
||||
|
||||
|
|
@ -372,7 +393,9 @@ async def unban_globally(_, ctx: Message):
|
|||
filters.command(["shell", "sh", "term"], COMMAND_HANDLER) & filters.user(SUDO)
|
||||
)
|
||||
@app.on_edited_message(
|
||||
filters.command(["shell", "sh", "term"], COMMAND_HANDLER) & filters.user(SUDO) & ~filters.react
|
||||
filters.command(["shell", "sh", "term"], COMMAND_HANDLER)
|
||||
& filters.user(SUDO)
|
||||
& ~filters.react
|
||||
)
|
||||
@user.on_message(filters.command(["shell", "sh", "term"], ".") & filters.me)
|
||||
@use_chat_lang()
|
||||
|
|
@ -435,8 +458,12 @@ async def shell_cmd(self: Client, ctx: Message, strings):
|
|||
& filters.user(SUDO)
|
||||
)
|
||||
@app.on_edited_message(
|
||||
(filters.command(["ev", "run", "meval"], COMMAND_HANDLER) | filters.regex(r"app.run\(\)$"))
|
||||
& filters.user(SUDO) & ~filters.react
|
||||
(
|
||||
filters.command(["ev", "run", "meval"], COMMAND_HANDLER)
|
||||
| filters.regex(r"app.run\(\)$")
|
||||
)
|
||||
& filters.user(SUDO)
|
||||
& ~filters.react
|
||||
)
|
||||
@user.on_message(filters.command(["ev", "run", "meval"], ".") & filters.me)
|
||||
@use_chat_lang()
|
||||
|
|
@ -449,7 +476,9 @@ async def cmd_eval(self: Client, ctx: Message, strings) -> Optional[str]:
|
|||
else await ctx.reply_msg(strings("run_eval"), quote=True)
|
||||
)
|
||||
code = (
|
||||
ctx.text.split(maxsplit=1)[1] if ctx.command else ctx.text.split("\napp.run()")[0]
|
||||
ctx.text.split(maxsplit=1)[1]
|
||||
if ctx.command
|
||||
else ctx.text.split("\napp.run()")[0]
|
||||
)
|
||||
out_buf = io.StringIO()
|
||||
out = ""
|
||||
|
|
@ -586,6 +615,7 @@ async def update_restart(_, ctx: Message, strings):
|
|||
async def tespoll(self, msg):
|
||||
await ctx.reply(msg)
|
||||
|
||||
|
||||
@app.on_raw_update(group=-99)
|
||||
async def updtebot(client, update, users, _):
|
||||
if isinstance(update, UpdateBotStopped):
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ from pyrogram.types import (
|
|||
from misskaty import BOT_USERNAME, app
|
||||
from misskaty.core.decorator.errors import capture_err
|
||||
from misskaty.helper.http import fetch
|
||||
from misskaty.helper.tools import rentry, gen_trans_image
|
||||
from misskaty.helper.tools import gen_trans_image, rentry
|
||||
from misskaty.vars import COMMAND_HANDLER
|
||||
from utils import extract_user, get_file_id
|
||||
|
||||
|
|
@ -66,7 +66,6 @@ __HELP__ = """
|
|||
|
||||
def remove_html_tags(text):
|
||||
"""Remove html tags from a string"""
|
||||
import re
|
||||
|
||||
clean = re.compile("<.*?>")
|
||||
return re.sub(clean, "", text)
|
||||
|
|
@ -78,7 +77,7 @@ def calcExpression(text):
|
|||
except (SyntaxError, ZeroDivisionError):
|
||||
return ""
|
||||
except TypeError:
|
||||
return float(eval(text.replace('(', '*(')))
|
||||
return float(eval(text.replace("(", "*(")))
|
||||
except Exception as e:
|
||||
LOGGER.error(e, exc_info=True)
|
||||
return ""
|
||||
|
|
@ -129,9 +128,10 @@ async def calculate_handler(self, ctx):
|
|||
text=f"Made by @{self.me.username}",
|
||||
reply_markup=calc_btn(ctx.from_user.id),
|
||||
disable_web_page_preview=True,
|
||||
quote=True
|
||||
quote=True,
|
||||
)
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("^calc"))
|
||||
async def calc_cb(self, query):
|
||||
_, uid, data = query.data.split("|")
|
||||
|
|
@ -139,7 +139,7 @@ async def calc_cb(self, query):
|
|||
return await query.answer("Who are you??", show_alert=True, cache_time=5)
|
||||
try:
|
||||
text = query.message.text.split("\n")[0].strip().split("=")[0].strip()
|
||||
text = '' if f"Made by @{self.me.username}" in text else text
|
||||
text = "" if f"Made by @{self.me.username}" in text else text
|
||||
inpt = text + query.data
|
||||
result = ""
|
||||
if data == "=":
|
||||
|
|
@ -167,7 +167,7 @@ async def calc_cb(self, query):
|
|||
await query.message.edit_msg(
|
||||
text=text,
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=calc_btn(query.from_user.id)
|
||||
reply_markup=calc_btn(query.from_user.id),
|
||||
)
|
||||
except Exception as error:
|
||||
LOGGER.error(error)
|
||||
|
|
|
|||
Loading…
Reference in a new issue