Skip to content

Commit

Permalink
Merge branch 'master' into add-generic-oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
NeuroAssassin authored Aug 5, 2023
2 parents 9d52986 + 6ad4ec4 commit 19b3851
Show file tree
Hide file tree
Showing 91 changed files with 715 additions and 490 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 99
select = E9,F7,F82
extend-exclude=.venv/,.stubs/
26 changes: 0 additions & 26 deletions .github/workflows/lint_python.yaml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/matchers/check-json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"__comment": "Credits to: https://github.com/home-assistant/core/blob/d32c364d7f9e138e0dd9363b34b3cb39f4afcd06/.github/workflows/matchers/check-json.json",
"problemMatcher": [
{
"owner": "check-json",
"pattern": [
{
"regexp": "^(.+):\\s(Failed to json decode\\s.+\\sline\\s(\\d+)\\scolumn\\s(\\d+).+)$",
"file": 1,
"message": 2,
"line": 3,
"column": 4
}
]
}
]
}
16 changes: 16 additions & 0 deletions .github/workflows/matchers/check-toml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "check-toml",
"pattern": [
{
"regexp": "^(.+\\.toml):\\s(.+line\\s(\\d+)\\scolumn\\s(\\d+).+)$",
"file": 1,
"message": 2,
"line": 3,
"column": 4
}
]
}
]
}
19 changes: 19 additions & 0 deletions .github/workflows/matchers/check-yaml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"problemMatcher": [
{
"owner": "check-yaml",
"pattern": [
{
"regexp": "^(.+)$",
"message": 1
},
{
"regexp": "^ in \"(.+\\.ya?ml)\", line (\\d+), column (\\d+)$",
"file": 1,
"line": 2,
"column": 3
}
]
}
]
}
32 changes: 32 additions & 0 deletions .github/workflows/matchers/flake8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"__comment": "Credits to: https://github.com/home-assistant/core/blob/d32c364d7f9e138e0dd9363b34b3cb39f4afcd06/.github/workflows/matchers/flake8.json",
"problemMatcher": [
{
"owner": "flake8-error",
"severity": "error",
"pattern": [
{
"regexp": "^(.+):(\\d+):(\\d+):\\s(([EF]\\d{3})\\s.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4,
"code": 5
}
]
},
{
"owner": "flake8-warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.+):(\\d+):(\\d+):\\s(([CDNW]\\d{3})\\s.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}
41 changes: 41 additions & 0 deletions .github/workflows/run_precommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Run pre-commit

on: [push, pull_request]

jobs:
run_precommit:
name: Run pre-commit
runs-on: ubuntu-latest

steps:
# Checkout repository
- uses: actions/checkout@v3

# Setup Python and install pre-commit
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install pre-commit
run: |
pip install -U pre-commit
# Load cached pre-commit environment
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}

# Register problem matchers
- name: Register problem matchers
run: |
echo "::add-matcher::.github/workflows/matchers/check-json.json"
echo "::add-matcher::.github/workflows/matchers/check-toml.json"
echo "::add-matcher::.github/workflows/matchers/check-yaml.json"
echo "::add-matcher::.github/workflows/matchers/flake8.json"
# Run pre-commit
- name: Run pre-commit
run: |
pre-commit run --show-diff-on-failure --color=never --all-files --verbose
17 changes: 0 additions & 17 deletions .github/workflows/style.yaml

This file was deleted.

55 changes: 55 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
default_language_version:
python: python3.8
exclude: ^.stubs/
repos:
- repo: https://github.com/psf/black
rev: 'refs/tags/23.7.0:refs/tags/23.7.0'
hooks:
- id: black
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker
rev: 'v1.1.3'
hooks:
- id: black-disable-checker
- repo: https://github.com/pycqa/flake8
rev: '6.1.0'
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
# `.gitattributes` should technically already handle this
# but autocrlf can result in local files keeping the CRLF
# which is problematic for codespell
- id: end-of-file-fixer
# normally you would want this but Neuro is not very consistent :P
# - id: mixed-line-ending
# args:
# - "--fix=lf"

# Trailing whitespace is evil
- id: trailing-whitespace

# Require literal syntax when initializing builtin types
- id: check-builtin-literals

# Ensure that links to code on GitHub use the permalinks
- id: check-vcs-permalinks

# Syntax validation
- id: check-ast
- id: check-json
- id: check-toml
# can be switched to yamllint when this issue gets resolved:
# https://github.com/adrienverge/yamllint/issues/238
- id: check-yaml

# JSON auto-formatter
- id: pretty-format-json
args:
- "--autofix"
- "--indent=4"
- "--no-sort-keys"

# Checks for git-related issues
- id: check-case-conflict
- id: check-merge-conflict
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PYTHON ?= python3.8

# Python Code Style
reformat:
$(PYTHON) -m black -l 99 .
$(PYTHON) -m black .
stylecheck:
$(PYTHON) -m black --check -l 99 .
$(PYTHON) -m black --check .
stylediff:
$(PYTHON) -m black --check --diff -l 99 .
$(PYTHON) -m black --check --diff .
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ For bugs, contact me at Neuro Assassin#4779 <@473541068378341376>. It would be

[PrettyTable](https://pypi.org/project/PrettyTable/) and [FuzzyWuzzy](https://pypi.org/project/fuzzywuzzy/) are required for the listpermissions cog.

[Back to Table of Contents](#table-of-contents)
[Back to Table of Contents](#table-of-contents)
4 changes: 2 additions & 2 deletions authgg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .authgg import AuthGG


def setup(bot):
bot.add_cog(AuthGG(bot))
async def setup(bot):
await bot.add_cog(AuthGG(bot))
8 changes: 4 additions & 4 deletions authgg/authgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from redbot.core.utils.predicates import MessagePredicate
from redbot.core.utils.chat_formatting import humanize_list, inline
from redbot.core import commands, Config, checks
from redbot.core import commands, Config
from typing import Optional
import discord
import asyncio
Expand All @@ -50,7 +50,7 @@ async def authgg(self, ctx):
@authgg.command()
async def resethwid(self, ctx, apikey: str, *, name: Optional[str] = None):
"""Reset a user's HWID lock on auth.gg for the specified API key name.
The API key name must be the friendly name provided by `[p]authgg keys add`."""
if not await self.bot.is_owner(ctx.author):
roles = await self.conf.roles()
Expand Down Expand Up @@ -135,7 +135,7 @@ async def changepw(self, ctx, apikey: str, username: str, password: str):
"I was unable to delete your command message due to lack of perms. It is recommended to due so to prevent your user's password from getting leaked."
)

@checks.is_owner()
@commands.is_owner()
@authgg.group()
async def keys(self, ctx):
"""Manage API keys for auth.gg"""
Expand Down Expand Up @@ -183,7 +183,7 @@ async def _keys_list(self, ctx):
message = f"The following keys are currently registered: {humanize_list(list(map(inline, keys.keys())))}"
await ctx.send(message)

@checks.is_owner()
@commands.is_owner()
@authgg.group()
async def roles(self, ctx):
"""Control what roles have access to reseting a user's HWID"""
Expand Down
2 changes: 1 addition & 1 deletion authgg/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
],
"requirements": [],
"hidden": false
}
}
4 changes: 2 additions & 2 deletions color/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
)


def setup(bot):
bot.add_cog(Color(bot))
async def setup(bot):
await bot.add_cog(Color(bot))
14 changes: 7 additions & 7 deletions color/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import re

import discord
from redbot.core import Config, checks, commands
from redbot.core import Config, commands

from colour import Color as col
from colour import rgb2hex
Expand Down Expand Up @@ -147,7 +147,7 @@ async def color(self, ctx):
"""Group command for color commands"""
pass

@checks.bot_has_permissions(embed_links=True)
@commands.bot_has_permissions(embed_links=True)
@color.command()
async def name(self, ctx, name):
"""Provides the hexadecimal value, RGB value and HSL value of a passed color. For example, pass `red` or `blue` as the name argument."""
Expand All @@ -159,7 +159,7 @@ async def name(self, ctx, name):
except (ValueError, AttributeError):
await ctx.send("That color is not recognized.")

@checks.bot_has_permissions(embed_links=True)
@commands.bot_has_permissions(embed_links=True)
@color.command()
async def hex(self, ctx, hexa: str):
"""Provides the RGB value and HSL value of a passed hexadecimal value. Hexadecimal value must in the format of something like `#ffffff` or `0xffffff` to be used."""
Expand All @@ -175,7 +175,7 @@ async def hex(self, ctx, hexa: str):
"Invalid formatting for the hexadecimal. Must be the hexadecimal value, with an optional `0x` or `#` in the beginning."
)

@checks.bot_has_permissions(embed_links=True)
@commands.bot_has_permissions(embed_links=True)
@color.command()
async def rgb(self, ctx, highest: int, r: float, g: float, b: float):
"""Provides the hexadecimal value and HSL value of the rgb value given. Each value must have a space between them. Highest argument must be 1 or 255, indicating the highest value of a single value (r, g, or b)."""
Expand All @@ -192,7 +192,7 @@ async def rgb(self, ctx, highest: int, r: float, g: float, b: float):
except (ValueError, AttributeError):
await ctx.send("That rgb number is not recognized.")

@checks.bot_has_permissions(embed_links=True)
@commands.bot_has_permissions(embed_links=True)
@color.command()
async def hsl(self, ctx, h: float, s: float, l: float):
"""Provides the hexadecimal value and the RGB value of the hsl value given. Each value must have a space between them."""
Expand All @@ -203,7 +203,7 @@ async def hsl(self, ctx, h: float, s: float, l: float):
except (ValueError, AttributeError):
await ctx.send("That hsl number is not recognized.")

@checks.bot_has_permissions(embed_links=True)
@commands.bot_has_permissions(embed_links=True)
@color.command()
async def decimal(self, ctx, decimal: int):
"""Provides the RGB value of the decimal value given."""
Expand All @@ -213,7 +213,7 @@ async def decimal(self, ctx, decimal: int):
except (ValueError, AttributeError):
await ctx.send("That decimal value is not recognized.")

@checks.admin()
@commands.admin()
@color.command()
async def msgshort(self, ctx, enable: bool):
"""Enable or disable the in-message shortcut.
Expand Down
Loading

0 comments on commit 19b3851

Please sign in to comment.