From 8cca379d378df79feedd5b05795742727a442756 Mon Sep 17 00:00:00 2001 From: Bobloy Date: Fri, 11 May 2018 12:53:12 -0400 Subject: [PATCH] Toggle lint and Alpha release Signed-off-by: Bobloy --- README.md | 2 +- coglint/coglint.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ff22d4..f3837a3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Cog Function | --- | --- | --- | | ccrole | **Beta** |
Create custom commands that also assign rolesMay have some bugs, please create an issue if you find any
| | chatter | **Alpha** |
Chat-bot trained to talk like your guildMissing some key features, but currently functional
| -| coglint | **Incomplete** |
Error check code in python syntax posted to discordStill conceptual, no idea if it'll work
| +| coglint | **Alpha** |
Error check code in python syntax posted to discordWorks, but probably needs more turning to work for cogs
| | fight | **Incomplete** |
Organize bracket tournaments within discordStill in-progress, a massive project
| | flag | **Incomplete** |
Create temporary marks on users that expire after specified timeNot yet ported to v3
| | hangman | **Alpha** |
Play a game of hangmanSome visual glitches and needs more customization
| diff --git a/coglint/coglint.py b/coglint/coglint.py index 473817e..cf93402 100644 --- a/coglint/coglint.py +++ b/coglint/coglint.py @@ -23,6 +23,7 @@ class CogLint: self.path = str(cog_data_path(self)).replace('\\', '/') + self.do_lint = None self.counter = 0 # self.answer_path = self.path + "/tmpfile.py" @@ -33,10 +34,18 @@ class CogLint: @commands.command() async def autolint(self, ctx: RedContext): """Toggles automatically linting code""" + curr = await self.config.lint() + + self.do_lint = not curr + await self.config.lint.set(not curr) + await ctx.send("Autolinting is now set to {}".format(not curr)) @commands.command() async def lint(self, ctx: RedContext, *, code): - """Lint python code""" + """Lint python code + + Toggle autolinting with `[p]autolint` + """ await self.lint_message(ctx.message) await ctx.send("Hello World") @@ -59,6 +68,10 @@ class CogLint: return pylint_stdout, pylint_stderr async def lint_message(self, message): + if self.do_lint is None: + self.do_lint = await self.config.lint() + if not self.do_lint: + return code_blocks = message.content.split('```')[1::2] for c in code_blocks: