Add temporary request_db_engine() implementation

This commit is contained in:
Tulir Asokan 2018-10-22 01:13:50 +03:00
parent fd14a38546
commit 485040e687
2 changed files with 8 additions and 2 deletions

View File

@ -64,7 +64,7 @@ class ParsedCommand:
self.name = command.name
self.is_passive = True
self.match_against = command.match_against
self.matches = re.compile(command.matches)
self.matches = re.compile(command.matches, re.UNICODE)
self.match_event = command.match_event
def _init_active(self, command: Command) -> None:
@ -90,7 +90,7 @@ class ParsedCommand:
sw_builder.append(word)
regex_builder.append(re.escape(word))
self.starts_with = "!" + " ".join(sw_builder)
self.matches = re.compile("^!" + " ".join(regex_builder) + "$")
self.matches = re.compile("^!" + " ".join(regex_builder) + "$", re.UNICODE)
self.match_against = "body"
def match(self, evt: MessageEvent) -> bool:

View File

@ -17,6 +17,9 @@ from typing import Type, Optional, TYPE_CHECKING
from logging import Logger
from abc import ABC, abstractmethod
from sqlalchemy.engine.base import Engine
import sqlalchemy as sql
if TYPE_CHECKING:
from .client import MaubotMatrixClient
from .command_spec import CommandSpec
@ -36,6 +39,9 @@ class Plugin(ABC):
self.log = log
self.config = config
def request_db_engine(self) -> Engine:
return sql.create_engine(f"sqlite:///{self.id}.db")
def set_command_spec(self, spec: 'CommandSpec') -> None:
self.client.set_command_spec(self.id, spec)