mirror of
https://git.freetards.xyz/array.in.a.matrix/TexLiLy.git
synced 2025-04-02 13:21:42 -04:00
19 lines
604 B
Python
19 lines
604 B
Python
from nio import RoomMessageText
|
|
import typing
|
|
|
|
|
|
class Router():
|
|
def __init__(self, name: str):
|
|
self.routes = {}
|
|
self.helptxt = {}
|
|
self.name = name
|
|
|
|
def add_route(self, cmd: str, hlp: str, func: typing.Callable) -> None:
|
|
if cmd not in self.routes:
|
|
self.routes[cmd] = func
|
|
self.helptxt[cmd] = hlp
|
|
|
|
async def handle_command(self, command: str, room: str, event: RoomMessageText, args: list):
|
|
import utils
|
|
if command in self.routes.keys():
|
|
await self.routes[command](self, utils.get_client(), room, event, args)
|