brandan-schmitz / plexbot

Plexbot - A discord bot for automating movie libraries.
0 stars 0 forks source link

Escape strings that can contain discord markdown characters #87

Closed brandan-schmitz closed 3 years ago

brandan-schmitz commented 3 years ago

Created a function named "escapeString" that will remove or replace characters appropriately depending on their context. The function wraps select fields that can contain unwanted markdowns but not ones with intentional markdowns.

Strings inside of a code-block remain the same except for the removal of all back-ticks (`). Strings outside of code-blocks use the regular expression "[*|_>~]" to replace each respective character with a black-slash and then itself.

The function also removes all occurrences of "```" to remove unintentional code-blocks, although this will probably never be used, it is there just in case.