aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
...
| | * | | | | | | | | Code block: use config constant for cooldownGravatar MarkKoz2020-06-27-2/+4
| | | | | | | | | | |
| | * | | | | | | | | Code block: make PY_LANG_CODES more visibleGravatar MarkKoz2020-06-27-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The declaration was a bit hidden between the two regular expressions.
| | * | | | | | | | | Code block: rename BadLanguage attributesGravatar MarkKoz2020-06-27-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `has_` prefix it clarifies that they're booleans. Co-authored-by: Numerlor <[email protected]>
| | * | | | | | | | | Merge remote-tracking branch 'origin/master' into ↵Gravatar MarkKoz2020-06-22-133/+469
| | |\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bug/utility/829/non-py-code-detection
| | * | | | | | | | | | Code block: remove needless f-stringsGravatar MarkKoz2020-06-14-3/+3
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: add statsGravatar MarkKoz2020-06-14-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Increment `codeblock_corrections` when instructions are sent * Import our Bot subclass instead of discord.py's
| | * | | | | | | | | | Code block: simplify retrieval of channel ID from payloadGravatar MarkKoz2020-06-14-1/+1
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: add configurable variablesGravatar MarkKoz2020-06-13-21/+41
| | | | | | | | | | | |
| | * | | | | | | | | | Create a utility function to count lines in a stringGravatar MarkKoz2020-06-13-2/+13
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: adjust logging levelsGravatar MarkKoz2020-06-13-4/+4
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: fix missing newline before generic exampleGravatar MarkKoz2020-06-13-1/+1
| | | | | | | | | | | |
| | * | | | | | | | | | Move some functions into a new channel utility moduleGravatar MarkKoz2020-06-13-37/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change `is_help_channel` to`internally use `is_in_category`
| | * | | | | | | | | | Code block: document the cogGravatar MarkKoz2020-06-13-7/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add docstrings for modules * Rephrase some docstrings and comments * Fix the grammar of some comments
| | * | | | | | | | | | Code block: fix wrong message shown for bad ticks with a valid languageGravatar MarkKoz2020-06-13-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the code block had invalid ticks, instructions for syntax highlighting were being shown despite the code block having a valid language.
| | * | | | | | | | | | Code block: don't return bad language instructions if nothing's wrongGravatar MarkKoz2020-06-13-14/+19
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: join bad language instructions by spacesGravatar MarkKoz2020-06-13-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was a mistake to join them by newlines in the first place. It looks and reads better as a paragraph. * Remove extra space after bad ticks instructions
| | * | | | | | | | | | Code block: fix message content being edited instead of the embedGravatar MarkKoz2020-06-13-1/+1
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: add function to create the instructions embedGravatar MarkKoz2020-06-13-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While it may be simple now, if the embed needs to changed later, it won't need to be done in multiple places since everything can rely on this function to create the embed.
| | * | | | | | | | | | Code block: use regex to parse incorrect languagesGravatar MarkKoz2020-06-13-18/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Regex is simpler and more versatile in this case. The functions in the `instructions` module should be more focused on formatting than parsing, so the parsing was moved to the `parsing` module. * Move _PY_LANG_CODES to the `parsing` module * Create a separate function in the `parsing` module to parse bad languages
| | * | | | | | | | | | Code block: create a function to format the example code blocksGravatar MarkKoz2020-06-13-17/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, this reduces code redundancy. Furthermore, it moves the relatively big block of code for checking the language away from `_get_bad_ticks_message` and into its own, smaller unit.
| | * | | | | | | | | | Code block: rename some things to be "private"Gravatar MarkKoz2020-06-13-26/+26
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: refactor `send_guide_embed`Gravatar MarkKoz2020-06-13-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Rename to `send_instructions` to be consistent with the use of "instructions" rather than "guide" elsewhere * Rename the `description` parameter to `instructions`
| | * | | | | | | | | | Code block: fix error retrieving a deleted instructions messageGravatar MarkKoz2020-06-13-4/+17
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: clarify log messages in message edit eventGravatar MarkKoz2020-06-13-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If statement was separated so there could be separate messages that are more specific. The message ID was also included to distinguish events.
| | * | | | | | | | | | Code block: edit instructions if edited message is still invalidGravatar MarkKoz2020-06-13-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Editing instructions means the user will always see what is currently relevant to them. Sometimes an incorrect edit could result in a different problem that was not mentioned in the original instructions. This change also fixes detection of fixed messages by using the same detection logic as the original `on_message`. Previously, it considered an edited message without code blocks to be fixed.
| | * | | | | | | | | | Code block: move bot message retrieval to a separate functionGravatar MarkKoz2020-06-13-16/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bot message retrieval is the actual part of `remove_instructions` that will soon get re-used elsewhere. * Remove `remove_instructions` since it became a bit too simple given the separation of bot message retrieval.
| | * | | | | | | | | | Code block: move instructions retrieval to a separate functionGravatar MarkKoz2020-06-13-26/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not only is it cleaner and more testable, but it allows for other functions to also retrieve instructions.
| | * | | | | | | | | | Code block: move instructions deletion to a separate functionGravatar MarkKoz2020-06-13-7/+16
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: fix valid code block being parsed as a missing blockGravatar MarkKoz2020-06-13-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `find_code_blocks` was returning an empty tuple if there was at least one valid code block. However, the caller could not distinguish between that case and simply no code blocks being found. Therefore, None is explicitly returned to distinguish it from a lack of results.
| | * | | | | | | | | | Code block: add trace loggingGravatar MarkKoz2020-06-13-6/+48
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: use same lang specifier as the user for the py exampleGravatar MarkKoz2020-06-13-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keeping examples consistent will hopefully make things clearer to the user.
| | * | | | | | | | | | Code block: fix formatting of the additional messageGravatar MarkKoz2020-06-13-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The newlines should be replaced with a space rather than with 1 newline. To separate the two issues, a double newline is prepended to the entire additional message.
| | * | | | | | | | | | Code block: fix missing space between words in messageGravatar MarkKoz2020-06-13-1/+1
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: fix formatting of example code blocksGravatar MarkKoz2020-06-13-4/+4
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: fix find_code_blocks iteration and missing returnGravatar MarkKoz2020-06-13-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add named capture groups to the regex
| | * | | | | | | | | | Code block: load the extensionGravatar MarkKoz2020-06-13-0/+1
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: use find_code_blocks to check if an edited msg was fixedGravatar MarkKoz2020-06-13-16/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove has_bad_ticks - it's obsolete
| | * | | | | | | | | | Code block: use new formatting functions in on_messageGravatar MarkKoz2020-06-13-17/+20
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: remove truncate functionGravatar MarkKoz2020-06-13-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No longer used anywhere.
| | * | | | | | | | | | Code block: rework the instruction formatting functionsGravatar MarkKoz2020-06-13-65/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new module, `instructions`, was created to house the functions. 4 ways in which code blocks can be incorrect are considered: 1. The code is not within a code block at all 2. Incorrect characters are used for back ticks 3. A language is not specified 4. A language is specified incorrectly Splitting it up into these 4 cases allows for more specific and relevant instructions to be shown to users. If a message has both incorrect back ticks and an issue with the language specifier, the instructions for fixing both issues are combined. The instructions show a generic code example rather than using the original code from the message. This circumvents any ambiguities when parsing their message and trying to fix it. The escaped code block also failed to preserve indentation. This was a problem because some users would copy it anyway and end up with poorly formatted code. By using a simple example that doesn't rely on indentation, it makes it clear the example is not meant to be copied. Finally, the new examples are shorter and thus make the embed not as giant.
| | * | | | | | | | | | Code block: move parsing functions to a separate moduleGravatar MarkKoz2020-06-13-119/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces clutter in the cog. The cog should only have Discord- related functionality.
| | * | | | | | | | | | Code block: remove obsolete functionsGravatar MarkKoz2020-06-13-108/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The user's original code will not be displayed in the output so there is no longer a need for the functions which format their code.
| | * | | | | | | | | | Code block: add function to check if REPL code existsGravatar MarkKoz2020-06-13-17/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `repl_stripping` function was re-purposed. The plan going forward is to not show the user's code in the output so actual stripping is no longer necessary.
| | * | | | | | | | | | Code block: exclude code blocks 3 lines or shorterGravatar MarkKoz2020-06-13-1/+3
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: add function to check for valid Python codeGravatar MarkKoz2020-06-13-29/+43
| | | | | | | | | | | |
| | * | | | | | | | | | Code block: add function to truncate contentGravatar MarkKoz2020-06-13-21/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code was duplicated in each of the format message functions. The function also ensures content is truncated to 10 lines. Previously, code could have skipped truncating by being 100 lines long but under 204 characters in length.
| | * | | | | | | | | | Code block: return code blocks with valid ticks but no langGravatar MarkKoz2020-06-13-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Such code block will be useful down the road for sending information on including a language specified if the content successfully parses as valid Python.
| | * | | | | | | | | | Code block: add function to find invalid code blocksGravatar MarkKoz2020-06-13-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Create a `NamedTuple` representing a code block
| | * | | | | | | | | | Code block: add regex to search for any code blocksGravatar MarkKoz2020-06-13-12/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This regex supports both valid and invalid ticks. The ticks are in a group so it's later possible to detect if valid ones were used.
| | * | | | | | | | | | Code block: fix code block language regexGravatar MarkKoz2020-06-13-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was missing a quantifier to match more than 1 character.