|
@@ -37,6 +37,7 @@ import speedtest
|
|
|
from PIL import Image, ImageDraw, ImageFilter, ImageFont
|
|
from PIL import Image, ImageDraw, ImageFilter, ImageFont
|
|
|
from pyrogram.enums import MessageEntityType
|
|
from pyrogram.enums import MessageEntityType
|
|
|
from pyrogram.types import Message
|
|
from pyrogram.types import Message
|
|
|
|
|
+from pyrogram import errors
|
|
|
|
|
|
|
|
from wbb import aiohttpsession as aiosession
|
|
from wbb import aiohttpsession as aiosession
|
|
|
from wbb.utils.dbfunctions import start_restart_stage
|
|
from wbb.utils.dbfunctions import start_restart_stage
|
|
@@ -213,38 +214,43 @@ async def extract_user_and_reason(message, sender_chat=False):
|
|
|
text = message.text
|
|
text = message.text
|
|
|
user = None
|
|
user = None
|
|
|
reason = None
|
|
reason = None
|
|
|
- if message.reply_to_message:
|
|
|
|
|
- reply = message.reply_to_message
|
|
|
|
|
- # if reply to a message and no reason is given
|
|
|
|
|
- if not reply.from_user:
|
|
|
|
|
- if (
|
|
|
|
|
- reply.sender_chat
|
|
|
|
|
- and reply.sender_chat != message.chat.id
|
|
|
|
|
- and sender_chat
|
|
|
|
|
- ):
|
|
|
|
|
- id_ = reply.sender_chat.id
|
|
|
|
|
|
|
+
|
|
|
|
|
+ try:
|
|
|
|
|
+ if message.reply_to_message:
|
|
|
|
|
+ reply = message.reply_to_message
|
|
|
|
|
+ # if reply to a message and no reason is given
|
|
|
|
|
+ if not reply.from_user:
|
|
|
|
|
+ if (
|
|
|
|
|
+ reply.sender_chat
|
|
|
|
|
+ and reply.sender_chat != message.chat.id
|
|
|
|
|
+ and sender_chat
|
|
|
|
|
+ ):
|
|
|
|
|
+ id_ = reply.sender_chat.id
|
|
|
|
|
+ else:
|
|
|
|
|
+ return None, None
|
|
|
else:
|
|
else:
|
|
|
- return None, None
|
|
|
|
|
- else:
|
|
|
|
|
- id_ = reply.from_user.id
|
|
|
|
|
|
|
+ id_ = reply.from_user.id
|
|
|
|
|
|
|
|
- if len(args) < 2:
|
|
|
|
|
- reason = None
|
|
|
|
|
- else:
|
|
|
|
|
- reason = text.split(None, 1)[1]
|
|
|
|
|
- return id_, reason
|
|
|
|
|
|
|
+ if len(args) < 2:
|
|
|
|
|
+ reason = None
|
|
|
|
|
+ else:
|
|
|
|
|
+ reason = text.split(None, 1)[1]
|
|
|
|
|
+ return id_, reason
|
|
|
|
|
+
|
|
|
|
|
+ # if not reply to a message and no reason is given
|
|
|
|
|
+ if len(args) == 2:
|
|
|
|
|
+ user = text.split(None, 1)[1]
|
|
|
|
|
+ return await extract_userid(message, user), None
|
|
|
|
|
|
|
|
- # if not reply to a message and no reason is given
|
|
|
|
|
- if len(args) == 2:
|
|
|
|
|
- user = text.split(None, 1)[1]
|
|
|
|
|
- return await extract_userid(message, user), None
|
|
|
|
|
|
|
+ # if reason is given
|
|
|
|
|
+ if len(args) > 2:
|
|
|
|
|
+ user, reason = text.split(None, 2)[1:]
|
|
|
|
|
+ return await extract_userid(message, user), reason
|
|
|
|
|
|
|
|
- # if reason is given
|
|
|
|
|
- if len(args) > 2:
|
|
|
|
|
- user, reason = text.split(None, 2)[1:]
|
|
|
|
|
- return await extract_userid(message, user), reason
|
|
|
|
|
|
|
+ return user, reason
|
|
|
|
|
|
|
|
- return user, reason
|
|
|
|
|
|
|
+ except errors.UsernameInvalid:
|
|
|
|
|
+ return "", ""
|
|
|
|
|
|
|
|
|
|
|
|
|
async def extract_user(message):
|
|
async def extract_user(message):
|