Skip to content

Commit

Permalink
Fix manim rendering when the code block starts with python (#42)
Browse files Browse the repository at this point in the history
* Update dependencies

aiohttp (3.8.1) was not supporting PEP 517 builds. (on M1)

* Fix manim rendering when the code block starts with `python`

regex union matches are eager so when it found `py` it stopped, without looking for `python`

* More detailed instructions in the README

---------

Co-authored-by: kraktus <[email protected]>
Co-authored-by: Benjamin Hackl <[email protected]>
  • Loading branch information
3 people authored Jul 27, 2023
1 parent 418a3c3 commit 193ba74
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 391 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# DiscordManimator

A Manim Rendering Bot for Discord. Requires a working `docker` environment: the `manimcommunity/manim:stable` image is used for rendering.
A Manim Rendering Bot for Discord.

## How to run

### Deploying the Bot
Prerequisites:
- Docker dameon running with the `manimcommunity/manim:stable` image pulled
- `poetry`, a python dependency manager
- A discord bot token with the `MESSAGE CONTENT` Intent enabled.

After obtaining a Discord bot token, make a new file called config.py in the same directory by copying config_example.py. Edit the new config.py and add your token. The bot is then started by running `python DiscordManimator.py`.
Deploy:
- run `poetry install`
- make a new file `config.py` in this directory based on `config_example.py` including the bot token
- run `poetry run python DiscordManimator.py`
2 changes: 1 addition & 1 deletion cogs/render_codeblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def on_submit(self, interaction: discord.Interaction):


def extract_manim_snippets(msg) -> None | str:
pattern = re.compile(r"```(?:py|python)?([^`]*def construct[^`]*)```")
pattern = re.compile(r"```(?:python|py)?([^`]*def construct[^`]*)```")
return pattern.findall(msg)


Expand Down
Loading

0 comments on commit 193ba74

Please sign in to comment.