forked from xditya/TeleBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8cedf81
commit e008dd7
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Schedule Plugin for @UniBorg | ||
Syntax: .schd <time_in_seconds> ;=; <message to send>""" | ||
from telethon import events | ||
import asyncio | ||
from userbot.utils import admin_cmd | ||
|
||
|
||
@register(admin_cmd("schd ?(.*)")) | ||
async def _(event): | ||
if event.fwd_from: | ||
return | ||
input_str = event.pattern_match.group(1) | ||
ttl = 0 | ||
message = "SYNTAX: `.schd <time_in_seconds> = <message to send>`" | ||
if input_str: | ||
await event.delete() | ||
if "=" in input_str: | ||
ttl, message = input_str.split("=") | ||
elif event.reply_to_msg_id: | ||
await event.delete() | ||
ttl = int(input_str) | ||
message = await event.get_reply_message() | ||
await asyncio.sleep(int(ttl)) | ||
await event.respond(message) | ||
else: | ||
await event.edit(message) |