mirror of
https://git.freetards.xyz/array.in.a.matrix/TexLiLy.git
synced 2025-04-02 13:21:42 -04:00
49 lines
1.4 KiB
Python
49 lines
1.4 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:
|
|
try:
|
|
version = None
|
|
if len(args) == 2:
|
|
version = args[1]
|
|
|
|
file = lilypond.render("", args[0], version=version)
|
|
await utils.send_png(room, file)
|
|
except FileNotFoundError as e:
|
|
await utils.send_plain(room, e.args[0])
|
|
except Exception:
|
|
# ???
|
|
pass
|