Skip to content
This repository was archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
Signed-off-by: code-rgb <62891774+code-rgb@users.noreply.github.com>
Browse files Browse the repository at this point in the history
  • Loading branch information
code-rgb committed Nov 3, 2020
1 parent 0564b53 commit a2fca02
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions userge/plugins/utils/pmpermit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
CHANNEL = userge.getCLogger(__name__)
SAVED_SETTINGS = get_collection("CONFIGS")
ALLOWED_COLLECTION = get_collection("PM_PERMIT")
PMPERMIT_MSG = {}


pmCounter: Dict[int, int] = {}
allowAllFilter = filters.create(lambda _, __, ___: Config.ALLOW_ALL_PMS)
Expand Down Expand Up @@ -70,12 +72,17 @@ async def allow(message: Message):
else:
await (await userge.get_users(userid)).unblock()
await message.edit("`Approved to direct message`", del_in=3)

if userid in PMPERMIT_MSG:
await userge.delete_messages(userid, message_ids=PMPERMIT_MSG[userid])
del PMPERMIT_MSG[userid]

else:
await message.edit(
"I need to reply to a user or provide the username/id or be in a private chat",
del_in=3,
)


@userge.on_cmd(
"nopm",
Expand Down Expand Up @@ -279,10 +286,10 @@ async def uninvitedPmHandler(message: Message):
)
else:
pmCounter.update({message.from_user.id: 1})
await message.reply(
PMPERMIT_MSG[message.from_user.id] = (await message.reply(
noPmMessage.format_map(SafeDict(**user_dict))
+ "\n`- Protected by USERGE-X`"
)
)).message_id
await asyncio.sleep(1)
await CHANNEL.log(f"#NEW_MESSAGE\n{user_dict['mention']} has messaged you")

Expand Down

0 comments on commit a2fca02

Please sign in to comment.