Skip to content

Commit

Permalink
Create chain.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xditya authored May 21, 2020
1 parent 0322bde commit 1ded22a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions userbot/plugins/chain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from telethon import events
from telethon.tl.functions.messages import SaveDraftRequest
from userbot.utils import admin_cmd

@borg.on(admin_cmd(pattern="chain"))
async def _(event):
await event.edit("Counting...")
count = -1
message = event.message
while message:
reply = await message.get_reply_message()
if reply is None:
await borg(SaveDraftRequest(
await event.get_input_chat(),
"",
reply_to_msg_id=message.id
))
message = reply
count += 1
await event.edit(f"Chain length: {count}")

0 comments on commit 1ded22a

Please sign in to comment.