Skip to content
Snippets Groups Projects
Commit 0e17952b authored by Sven Mäder's avatar Sven Mäder :speech_balloon:
Browse files

Refactor class names

parent 8ce9c0e4
No related branches found
No related tags found
No related merge requests found
from .bot import ReminderBot
from .bot import ETHzLunchBot
......@@ -25,7 +25,7 @@ from mautrix.util.async_db import UpgradeTable
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
from .migrations import upgrade_table
from .db import ReminderDatabase
from .db import ETHzLunchDatabase
from .util import validate_locale, validate_timezone, CommandSyntaxError
from .reminder import Reminder
from .ethz import (parse_facilities, parse_menus, filter_facilities, markdown_facilities,
......@@ -49,14 +49,14 @@ class Config(BaseProxyConfig):
helper.copy("default_facilities")
class ReminderBot(Plugin):
class ETHzLunchBot(Plugin):
base_command: Tuple[str, ...]
hunger_command: Tuple[str, ...]
default_timezone: pytz.timezone
admin_power_level: int
scheduler: AsyncIOScheduler
reminders: Dict[EventID, Reminder]
db: ReminderDatabase
db: ETHzLunchDatabase
url_facilities: str
url_menus: str
......@@ -71,7 +71,7 @@ class ReminderBot(Plugin):
async def start(self) -> None:
self.scheduler = AsyncIOScheduler()
self.scheduler.start()
self.db = ReminderDatabase(self.database)
self.db = ETHzLunchDatabase(self.database)
self.on_external_config_update()
self.reminders = await self.db.load_all(self)
......@@ -245,7 +245,8 @@ class ReminderBot(Plugin):
f"Available price categories: `int`, `ext`, `stud`\n"
f"Disable prices in menus: `off`")
@lunch.subcommand("remind", help="Create reminder (time: `hh:mm`, days default: `mon-fri`)")
@lunch.subcommand("remind", aliases=["reminder"],
help="Create reminder (time: `hh:mm`, days default: `mon-fri`)")
@command.argument("time", matches="[0-9]{1,2}:[0-9]{2}")
@command.argument("days", required=False)
@command.argument("canteens", required=False, pass_raw=True)
......
......@@ -29,7 +29,7 @@ from mautrix.types import UserID, EventID, RoomID
if TYPE_CHECKING:
from .bot import ReminderBot
from .bot import ETHzLunchBot
from .reminder import Reminder
......@@ -37,7 +37,7 @@ from .reminder import Reminder
logger = logging.getLogger(__name__)
class ReminderDatabase:
class ETHzLunchDatabase:
cache: DefaultDict[UserID, UserInfo]
db: Database
defaults: UserInfo
......@@ -125,7 +125,7 @@ class ReminderDatabase:
reminder.is_agenda,
reminder.creator)
async def load_all(self, bot: ReminderBot) -> Dict[EventID, Reminder]:
async def load_all(self, bot: ETHzLunchBot) -> Dict[EventID, Reminder]:
""" Load all reminders in the database and return them as a dict for the main bot
Args:
bot: it feels dirty to do it this way, but it seems to work and make code cleaner
......
......@@ -18,7 +18,7 @@ except ImportError:
USE_CRON_DESCRIPTOR = False
if TYPE_CHECKING:
from .bot import ReminderBot
from .bot import ETHzLunchBot
logger = logging.getLogger(__name__)
......@@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
class Reminder(object):
def __init__(
self,
bot: ReminderBot,
bot: ETHzLunchBot,
room_id: RoomID,
message: str,
event_id: Optional[EventID] = None,
......
......@@ -3,8 +3,8 @@ id: ch.ethz.phys.lunch
version: 0.0.2
license: AGPL-3.0-or-later
modules:
- reminder
main_class: ReminderBot
- ethzlunch
main_class: ETHzLunchBot
extra_files:
- base-config.yaml
dependencies:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment