fix sangmata module
This commit is contained in:
@@ -14,47 +14,39 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import asyncio
|
|
||||||
|
|
||||||
from pyrogram import Client, enums, filters
|
from pyrogram import Client, filters
|
||||||
|
from pyrogram.errors import YouBlockedUser
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.errors import RPCError
|
|
||||||
|
|
||||||
|
from utils.conv import Conversation
|
||||||
from utils.misc import modules_help, prefix
|
from utils.misc import modules_help, prefix
|
||||||
from utils.scripts import edit_or_reply
|
from utils.scripts import format_exc
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.command("sgb", prefix) & filters.me)
|
@Client.on_message(filters.command("sgb", prefix) & filters.me)
|
||||||
async def sg(client: Client, message: Message):
|
async def sg(client: Client, message: Message):
|
||||||
lol = await edit_or_reply(message, "<code>Processing please wait</code>")
|
|
||||||
if message.reply_to_message and message.reply_to_message.from_user:
|
if message.reply_to_message and message.reply_to_message.from_user:
|
||||||
user_id = message.reply_to_message.from_user.id
|
user_id = message.reply_to_message.from_user.id
|
||||||
else:
|
else:
|
||||||
await message.edit(f"<b>Usage: </b><code>{prefix}sgb [id]</code>")
|
await message.edit(f"<b>Usage: </b><code>{prefix}sgb [id]</code>")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
await client.send_message(
|
await message.edit("<code>Processing please wait</code>")
|
||||||
"@SangMata_beta_bot", "/start", parse_mode=enums.ParseMode.MARKDOWN
|
bot_username = "@SangMata_beta_bot"
|
||||||
)
|
async with Conversation(client, bot_username, timeout=15) as conv:
|
||||||
except RPCError:
|
await conv.send_message(str(user_id))
|
||||||
await lol.edit(
|
response = await conv.get_response(timeout=10)
|
||||||
"**Please unblock @SangMata_beta_bot and try again**",
|
if "you have used up your quota" in response.text:
|
||||||
parse_mode=enums.ParseMode.MARKDOWN,
|
await message.edit(response.text.splitlines()[0])
|
||||||
)
|
|
||||||
return
|
return
|
||||||
id = "@SangMata_beta_bot"
|
return await message.edit(response.text)
|
||||||
chat = message.chat.id
|
except YouBlockedUser:
|
||||||
await client.send_message(id, user_id, parse_mode=enums.ParseMode.MARKDOWN)
|
await message.edit("<i>Please unblock @SangMata_beta_bot first.</i>")
|
||||||
await asyncio.sleep(2)
|
except TimeoutError:
|
||||||
async for opt in client.get_chat_history("@SangMata_beta_bot", limit=1):
|
await message.edit("<i>No response from bot within the timeout period.</i>")
|
||||||
hmm = opt.text
|
except Exception as e:
|
||||||
if hmm.startswith("Forward"):
|
await message.edit(f"<i>Error: {format_exc(e)}</i>")
|
||||||
await lol.edit(
|
|
||||||
"**Unknown error occurred**", parse_mode=enums.ParseMode.MARKDOWN
|
|
||||||
)
|
|
||||||
return
|
|
||||||
await lol.delete()
|
|
||||||
await opt.copy(chat)
|
|
||||||
|
|
||||||
|
|
||||||
modules_help["sangmata"] = {"sgb": "reply to any user"}
|
modules_help["sangmata"] = {"sgb": "reply to any user"}
|
||||||
|
|||||||
Reference in New Issue
Block a user