2023-09-08 02:49:37 +02:00
|
|
|
import re
|
|
|
|
import asyncio
|
|
|
|
from module_interface import ModuleInterface
|
2023-10-03 04:01:27 +02:00
|
|
|
|
|
|
|
|
2023-09-08 02:49:37 +02:00
|
|
|
class Timer(ModuleInterface):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
self.name = "Timer"
|
|
|
|
self.regex_pattern = r"((.|\n)*)(타이머\s.*(맞춰줘|설정해줘))|.*(뒤에\s*알려줘)"
|
|
|
|
|
|
|
|
print("[Timer] Settable timer module, Timer V1 loaded.")
|
|
|
|
|
|
|
|
async def execute_module(self, ctx):
|
|
|
|
print(f"[Timer] Got Timer Related Message : {ctx.content}")
|
2023-10-03 04:01:27 +02:00
|
|
|
|
2023-09-08 02:49:37 +02:00
|
|
|
text = ctx.content
|
2023-10-03 04:01:27 +02:00
|
|
|
seconds_query = re.search(r"([0-9]+)초", text)
|
|
|
|
minutes_query = re.search(r"([0-9]+)분", text)
|
|
|
|
hours_query = re.search(r"([0-9]+)(시간)", text)
|
2023-09-08 02:49:37 +02:00
|
|
|
|
|
|
|
seconds = int(seconds_query.group(1)) if seconds_query else 0
|
|
|
|
minutes = int(minutes_query.group(1)) if minutes_query else 0
|
|
|
|
hours = int(hours_query.group(1)) if hours_query else 0
|
|
|
|
|
2023-10-03 04:01:27 +02:00
|
|
|
if (seconds + minutes + hours) == 0:
|
2023-09-08 02:49:37 +02:00
|
|
|
await ctx.api.action.reply("올바른 값이 아니에요...")
|
|
|
|
|
|
|
|
time = (seconds) + (60 * minutes) + (60 * 60 * hours)
|
|
|
|
|
|
|
|
await ctx.api.action.reply("타이머를 설정할게요!")
|
|
|
|
await asyncio.sleep(int(time))
|
|
|
|
await ctx.api.action.reply("시간이 다 되었어요!")
|