Nyhilo / Duck-Disciple-Bot

A bot for adding helpful tools to the Infinite Nomic discord
http://nomic.gay
MIT License
3 stars 2 forks source link

Fetch rules from the wiki #3

Closed Nyhilo closed 2 years ago

Nyhilo commented 3 years ago

The bot should be able to fetch rule text and (perhaps) gamestate sections from the wiki.

This comes with the challenge of properly formatting such content to be displayed on discord. Gross.

Nyhilo commented 3 years ago

Trying out the libraries markdownify and html2markdown to see if either of them are suitable to our needs.

Input html. The table is reformatted in place before being passed to the library.

<p>If, after performing this quack attack, the Duck Disciple has 0 or fewer quacks, it perishes.
</p>
<ul><li>Ritual Quack Attack. Cost: None. Targets: 1 random named Duck that is not the Duck Disciple. Effect: Target loses 1d6 quacks.</li></ul>
<p>When a Duck Disciple perishes, all ducks that dealt damage to that Duck Disciple gain 1d6 quacks. Additionally, the owner of the duck that reduced the Duck Disciple to 0 or fewer quacks rolls a d20 on the following table and receives the benefit of that roll.
</p>
<pre>
1-10    4d6 seeds
11-14   1 Grapes
15-17   1 Watermelon Slice
18-19   1 Blood Orange
20      1 God Egg
</pre>

markdownify:

Pros: Gives a good effort at formatting everything Cons: Strips the whitespace from the table and adds waaaay too many newlines.

If, after performing this quack attack, the Duck Disciple has 0 or fewer quacks, it perishes.

* Ritual Quack Attack. Cost: None. Targets: 1 random named Duck that is not the Duck Disciple. Effect: Target loses 1d6 quacks.

When a Duck Disciple perishes, all ducks that dealt damage to that Duck Disciple gain 1d6 quacks. Additionally, the owner of the duck that reduced the Duck Disciple to 0 or fewer quacks rolls a d20 on the following table and receives the benefit of that 
roll.

1-10 4d6 seeds
11-14 1 Grapes
15-17 1 Watermelon Slice
18-19 1 Blood Orange
20 1 God Egg

html2markdown

Pros: Retains the formatting of the table, no extraneous newlines. Cons: Fails to strip any tags it's not programmed to recognize.

If, after performing this quack attack, the Duck Disciple has 0 or fewer quacks, it perishes.

*   Ritual Quack Attack. Cost: None. Targets: 1 random named Duck that is not the Duck Disciple. Effect: Target loses 1d6 quacks.

When a Duck Disciple perishes, all ducks that dealt damage to that Duck Disciple gain 1d6 quacks. Additionally, the owner of the duck that reduced the Duck Disciple to 0 or fewer quacks rolls a d20 on the following table and receives the benefit of that 
roll.

<pre>
1-10    4d6 seeds
11-14   1 Grapes
15-17   1 Watermelon Slice
18-19   1 Blood Orange
20      1 God Egg
</pre>
Nyhilo commented 3 years ago

Thinking it might be better just to post a link to the rule, instead of the full rule text.

Let's look at doing a fuzzy search and returning a link to the best match instead. i.e.

&quack naming will give a link to the rule titled "Duck Naming Criteria"

Nyhilo commented 2 years ago

Closing this as it is a feature that I no longer believe is desired.