aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugins/alicebot_plugin_luck/__init__.py
blob: f56019bd9c5533ce0f441452cfab406fa01c19e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import re
import time
import random

from plugins.iamai_plugin_base import CommandPluginBase

from .config import Config


class Luck(CommandPluginBase[None, Config]):
    Config = Config

    def __post_init__(self):
        self.re_pattern = re.compile(r".*", flags=re.I)

    async def handle(self) -> None:
        random.seed(
            time.strftime("%Y%j", time.localtime()) + self.format_str("{user_id}")
        )
        lucy = random.randint(self.config.min_int, self.config.max_int)
        await self.event.reply(self.format_str(self.config.message_str, str(lucy)))