From 485040e687516e7c34765ad76f74f937e77237a1 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 22 Oct 2018 01:13:50 +0300 Subject: [PATCH] Add temporary request_db_engine() implementation --- maubot/command_spec.py | 4 ++-- maubot/plugin_base.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/maubot/command_spec.py b/maubot/command_spec.py index f5136ce..55c3279 100644 --- a/maubot/command_spec.py +++ b/maubot/command_spec.py @@ -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: diff --git a/maubot/plugin_base.py b/maubot/plugin_base.py index 81ac7f0..119f764 100644 --- a/maubot/plugin_base.py +++ b/maubot/plugin_base.py @@ -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)