aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/hydroroll/plugins/plugin_bot/__init__.py
blob: 89ba17b045eb72bb734209dd970d14b55a646fba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import re
from importlib.metadata import version
from plugins.plugin_base import CommandPluginBase
from hydroroll.config import GlobalConfig

from .config import Config


class HydroBot(CommandPluginBase[None, Config]):
    Config = Config
    CurrentConfig = GlobalConfig
    priority = 0

    def __post_init__(self):
        self.re_pattern = re.compile(r"(?P<bot_info_str>.*)", flags=re.I)

    def bot_info(self):
        info_str = f'{self.CurrentConfig._name} '\
                   f'{self.CurrentConfig._version}({self.CurrentConfig._svn}) '\
                   f'by {self.CurrentConfig._author} '\
                   f'on Python {self.CurrentConfig._python_ver_raw} '\
                   f'with {" & ".join([adapter + "("+version("iamai-adapter-"+adapter) +")" for adapter in dict(self.bot.config.adapter)])} '\
                   f'for iamai({self.CurrentConfig._iamai_version})'

        return info_str

    async def handle(self) -> None:
        await self.event.reply(
            self.format_str(self.config.message_str, self.bot_info())
        )