aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
* Add global bot instanceGravatar MarkKoz2020-10-16-3/+10
| | | | | | Is **very** convenient when writing utility functions that rely on the bot's state, but aren't in cogs and therefore lack the typical way to access the instance. No more passing around of the instance as an arg!
* Snekbox: raise paste character lengthGravatar MarkKoz2020-10-15-1/+1
| | | | | | | It doesn't make sense for it to be at 1000 when the code gets truncated to 1000 as well. Fixes #1239
* Code block: fix _fix_indentation failing for line counts of 1Gravatar MarkKoz2020-10-14-0/+4
| | | | | | | | | This could be reproduced by editing a tracked message to a single line of invalid Python that lacks any back ticks. The code was assuming there would be multiple lines because that's what the default value for the threshold is, but this threshold is not applied to edited messages. Fixes BOT-A5
* Merge pull request #886 from ↵Gravatar Mark2020-10-14-357/+733
|\ | | | | | | | | python-discord/bug/utility/829/non-py-code-detection Code block detection rewrite
| * Utils: clarify why has_lines counts by splitting by newlinesGravatar MarkKoz2020-10-14-0/+1
| |
| * Merge master and fix conflictsGravatar MarkKoz2020-10-05-3820/+3457
| |\ | | | | | | | | | | | | | | | | | | * Use absolute imports in the code block modules for consistency * Move has_lines utility function into the helpers module * Prefix names of code block modules with underscores so they won't get picked up as extensions by the extension manager
| * | Code block: support the "pycon" language specifierGravatar MarkKoz2020-10-05-1/+1
| | | | | | | | | | | | It's used for code copied from the Python REPL.
| * | Fix conflict for webhook token check in code block detectionGravatar MarkKoz2020-09-09-604/+203
| |\ \
| * | | Code block: make _get_leading_spaces more readableGravatar MarkKoz2020-08-25-7/+5
| | | | | | | | | | | | | | | | A for loop is less confusing according to reviews.
| * | | Stats: use the is_in_category util functionGravatar MarkKoz2020-08-25-2/+2
| | | |
| * | | Use category_id attribute in is_in_categoryGravatar MarkKoz2020-08-25-2/+1
| | | | | | | | | | | | | | | | Simplify the code by removing the need to check if the category is None.
| * | | Code block: fix conflict with wait_for_deletion argsGravatar MarkKoz2020-08-23-161/+264
| |\ \ \
| * | | | Code block: clarify that the original message can be editedGravatar MarkKoz2020-08-23-6/+9
| | | | | | | | | | | | | | | | | | | | Fix #497
| * | | | HelpChannels: fix conflict with pin functionsGravatar MarkKoz2020-08-08-1127/+3763
| |\ \ \ \
| * | | | | Code block: dedent code before validating itGravatar MarkKoz2020-06-28-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | If it's indented too far, the AST parser will fail.
| * | | | | Code block: re-add indentation fixing functionGravatar MarkKoz2020-06-28-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's still useful to fix indentation to ensure AST is correctly parsed. This function deals with the relatively common case of a the leading spaces of the first line being left out when copy-pasting.
| * | | | | Code block: support IPython REPL detectionGravatar MarkKoz2020-06-27-6/+53
| | | | | |
| * | | | | Code block: fix BadLanguage creationGravatar MarkKoz2020-06-27-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Forgot to change the kwarg names when the attributes were renamed.
| * | | | | HelpChannels: fix is_in_category callGravatar MarkKoz2020-06-27-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was still using it like it was a method of the class rather than calling it from the channel utils module.
| * | | | | Code block: clarify get_instructions's docstringGravatar MarkKoz2020-06-27-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | It wasn't clear that it also parses the message content.
| * | | | | Code block: simplify channel cooldown dict creationGravatar MarkKoz2020-06-27-1/+1
| | | | | |
| * | | | | 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.