mirror of
https://github.com/Nick80835/microbot
synced 2025-09-05 00:45:55 +00:00
reject chats and channels in get_user
This commit is contained in:
@@ -8,6 +8,7 @@ from platform import python_version
|
|||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
from telethon import version
|
from telethon import version
|
||||||
|
from telethon.tl.types import Channel, Chat
|
||||||
|
|
||||||
from ubot import ldr, micro_bot
|
from ubot import ldr, micro_bot
|
||||||
|
|
||||||
@@ -176,7 +177,12 @@ async def get_user(event):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return await event.client.get_entity(event.args)
|
user = await event.client.get_entity(event.args)
|
||||||
|
|
||||||
|
if isinstance(user, (Chat, Channel)):
|
||||||
|
raise TypeError
|
||||||
|
|
||||||
|
return user
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
await event.reply("The ID or username you provided was invalid!")
|
await event.reply("The ID or username you provided was invalid!")
|
||||||
return
|
return
|
||||||
@@ -186,7 +192,12 @@ async def get_user(event):
|
|||||||
|
|
||||||
if reply_id:
|
if reply_id:
|
||||||
try:
|
try:
|
||||||
return await event.client.get_entity(reply_id)
|
user = await event.client.get_entity(reply_id)
|
||||||
|
|
||||||
|
if isinstance(user, (Chat, Channel)):
|
||||||
|
raise TypeError
|
||||||
|
|
||||||
|
return user
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
await event.reply("There was an error getting the user's ID!")
|
await event.reply("There was an error getting the user's ID!")
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user