# █ █ ▀ █▄▀ ▄▀█ █▀█ ▀
# █▀█ █ █ █ █▀█ █▀▄ █
# © Copyright 2022
# https://t.me/hikariatama
#
# 🔒 Licensed under the GNU AGPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# meta pic: https://static.dan.tatar/youdbettersleep_icon.png
# meta banner: https://mods.hikariatama.ru/badges/youdbettersleep.jpg
# meta developer: @hikarimods
# scope: hikka_only
# scope: hikka_min 1.3.0
import re
import time
from telethon.tl.types import Message
from .. import loader, utils
def s2time(temp_time: str) -> int:
seconds, minutes, hours = 0, 0, 0
try:
seconds = int(str(re.search("([0-9]+)s", temp_time).group(1)))
except Exception:
pass
try:
minutes = int(str(re.search("([0-9]+)m", temp_time).group(1))) * 60
except Exception:
pass
try:
hours = int(str(re.search("([0-9]+)h", temp_time).group(1))) * 60 * 60
except Exception:
pass
return round(seconds + minutes + hours)
@loader.tds
class YouDBetterSleepMod(loader.Module):
"""Restricts user from sending messages while sleeping"""
strings = {
"name": "YouDBetterSleep",
"no_time": "🚫 You can't sleep forever, specify ",
"awake": "🥱 Good morning",
"asleep": "😴 Good night. Now I can't write messages for {}",
"disabled": (
"😴 I can't write messages, because my userbot wants me to sleep"
),
}
strings_ru = {
"no_time": "👾 Ты не можешь спать вечно, укажи аргумент <время>",
"awake": "🥱 Доброе утро",
"asleep": (
"😴 Спокойной ночи. Я не могу писать сообщения на протяжении {}"
),
"disabled": (
"😴 Я не могу писать сообщения, так как мой юзербот хочет, чтобы я"
" поспал"
),
"_cls_doc": "Запрещает писать во время сна",
}
@loader.command(ru_doc="<время> - Поспать")
async def sleepcmd(self, message: Message):
"""