TexLiLy/routes.py
LoaD Accumulator 60278db59e
[ADD] Add basic LilyPond support.
Right now, it's using the lily!show command, which might change
(check out #4)
2023-06-14 13:01:27 +02:00

39 lines
1.1 KiB
Python

from router import Router
from nio import *
async def route_help(r: Router, client: Client, room: str, event: RoomMessageText, args: list) -> None:
import router
import utils
txt = "Commands for TeXLily:\n"
print(r)
for cmd in r.routes:
txt += f" {r.name}!{cmd}: {r.helptxt[cmd]}\n"
await utils.send_msg(client, room, txt)
async def route_delete(router: Router, client: Client, room: str, event: RoomMessageText, args: list) -> None:
if len(args) == 1:
import utils
import os
directory = utils.create_user_dir(event.sender)
file = os.path.join(directory, args[0] + ".sty")
try:
os.remove(file)
await utils.send_msg(client, room, "Deleted!")
except FileNotFoundError:
await utils.send_msg(client, room, f"Couldn't delete style {args[0]}")
pass
async def route_lshow(router: Router, client: Client, room: str, event: RoomMessageText, args: list) -> None:
import lilypond
import utils
if len(args) == 1:
file = lilypond.render("", args[0])
await utils.send_png(room, file)