Add .purgeme command

This commit is contained in:
Michael De Roover 2021-03-21 13:09:50 +01:00
parent c59060b921
commit 2e89400747
Signed by: vim
GPG Key ID: 075496E232CE04CB

14
ubot.py
View File

@ -79,6 +79,18 @@ async def edit(event):
rpl = 'Sauce: [ghnou/ubot](https://git.ghnou.su/ghnou/ubot)'
await event.edit(rpl)
if '.purgeme' in msg:
count = int(msg.split()[1])
i = 1
async for msgs in client.iter_messages(event.chat_id, from_user='me'):
if (i > count + 1):
break
i = i + 1
await msgs.delete()
rpl = "Purge complete! Purged " + str(count) + " messages."
await client.send_message('me', rpl)
if '.help' in msg:
rpl = '**Available userbot commands:**\n'
rpl += '.alive - Check whether the bot is running.\n'
@ -86,7 +98,7 @@ async def edit(event):
rpl += '.stats - Get user account stats.\n'
rpl += '.fire - IMA FIRING MAH LAZER\n'
rpl += '.sauce - Get the bot\'s source code.\n'
rpl += '.help - Show this help message.'
rpl += '.help - Show this help message.\n'
await event.edit(rpl)
client.start()