minya_hotomoe/modules/K_Josa.py

34 lines
826 B
Python
Raw Normal View History

2023-09-12 14:44:28 +02:00
from module_interface import ModuleInterface
from mipac.models import Note
2023-10-03 04:01:27 +02:00
2023-09-12 14:44:28 +02:00
class KJosa(ModuleInterface):
def __init__(self):
super().__init__()
self.name = "K-Josa"
self.regex_pattern = None
2023-10-03 04:01:27 +02:00
2023-09-12 14:44:28 +02:00
self.funcs["process_josa"] = self._process
print("[K-Josa] Korean postposition processor, K-Josa V1 loaded.")
2023-10-03 04:01:27 +02:00
2023-09-12 14:44:28 +02:00
async def execute_module(self, ctx: Note):
pass
def _process(self, w, t, f):
2023-10-03 04:01:27 +02:00
return (
(
w
+ (
(t if ((ord(w[-1]) - 44032) % 28 != 0) else f)
if (44032 <= ord(w[-1]) <= 55203)
else f"{t}({f})"
)
)
if (t and f)
else w
)
2023-09-12 14:44:28 +02:00
def module_ready(self):
print("[K-josa] Module Ready.")