Initial commit
This commit is contained in:
29
plugins/commands/toggle.py
Normal file
29
plugins/commands/toggle.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
|
||||
from classes.pyroclient import PyroClient
|
||||
|
||||
|
||||
@PyroClient.on_message(
|
||||
~filters.scheduled & filters.private & filters.command(["toggle"], prefixes=["/"]) # type: ignore
|
||||
)
|
||||
async def command_toggle(app: PyroClient, message: Message):
|
||||
user = await app.find_user(message.from_user)
|
||||
|
||||
await user.update_state(not user.enabled)
|
||||
|
||||
if user.enabled:
|
||||
await message.reply_text("Notifications have been disabled.")
|
||||
return
|
||||
|
||||
if user.location is None:
|
||||
await message.reply_text(
|
||||
f"Notifications have been enabled {user.offset} d. before garbage collection at {datetime(1970, 1, 1, user.time_hour, user.time_minute).strftime('%H:%M')}. Use /setup to select your location."
|
||||
)
|
||||
return
|
||||
|
||||
await message.reply_text(
|
||||
f"Notifications have been enabled {user.offset} d. before garbage collection at {datetime(1970, 1, 1, user.time_hour, user.time_minute).strftime('%H:%M')} at the **{user.location.name}**."
|
||||
)
|
Reference in New Issue
Block a user