Skip to content

Commit

Permalink
add helper method to check permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Feb 8, 2022
1 parent 52fc902 commit b9040a2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions bot/helpers/help_for_14121.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from pyrogram.errors import (
UserNotParticipant
)
from bot.bot import Bot


async def check_perm(client: Bot, chat_id: int, user_id: int) -> bool:
try:
_a_ = await client.get_chat_member(
chat_id,
user_id
)
except UserNotParticipant:
return False
else:
if _a_.can_delete_messages:
return True
else:
return False

0 comments on commit b9040a2

Please sign in to comment.