Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
🔀 Merge pull request #175 from Pincer-org/main
Browse files Browse the repository at this point in the history
🔖 Pincer 0.10.0
  • Loading branch information
Sigmanificient authored Nov 7, 2021
2 parents e65c914 + 182d740 commit c15675c
Show file tree
Hide file tree
Showing 61 changed files with 1,914 additions and 580 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ ignore =
# H405: multi line docstring summary not separated with an empty line
H405,
# H501: Do not use self.__dict__ for string formatting
H501
H501,
# W503: line break before binary operator
W503
exclude =
# No need to traverse our git directory
.git,
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pypi_upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ jobs:
- name: install requirements_img
run: pip install -r packages/img.txt

- name: generate setup.cfg
run: python -m setup_config.generator

- name: compile lib
run: python setup.py sdist bdist_wheel

Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/setup_generator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Generate setup.cfg

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2

with:
persist-credentials: false
fetch-depth: 0
python-version: '3.x'
architecture: 'x64'

- name: install requirements
run: pip install -r requirements.txt

- name: generate setup.cfg
run: python -m setup_config.generator

- name: setup git
run: |
git config user.name "GitHub Actions"
git config user.email "actions@pincer.dev"
- name: add to git
run: |
git pull
git add .
git diff-index --quiet HEAD || git commit -m "🔨 Automatic update of setup.cfg"
git push origin main
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ Pillow = "*"
flake8 = "==4.0.1"
tox = "==3.24.4"
pytest = "==6.2.5"
pytest-asyncio = "==0.16.0"
pytest-cov = "==3.0.0"
mypy = "==0.910"
twine = "==3.4.2"
twine = "==3.5.0"
wheel = "==0.37.0"

[requires]
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.10.0
5 changes: 3 additions & 2 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ We'll use the issue to have a conversation about the problem you found.
## Make your update

Make your changes to the file(s) you'd like to update to solve an issue
or add a new feature.
or add a new feature. When writing docstrings, please use the
[numpydocs](https://numpydoc.readthedocs.io/en/latest/format.html) style guide.

We recommend you using [Gitmoji](https://gitmoji.dev/) for your commits as it
help organization them by categories.
helps to organize them by categories.
If you don't want to use it, we will squash your commits for a cleaner
history.

Expand Down
6 changes: 3 additions & 3 deletions docs/PYPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ You have the possibility to use your own class to inherit from the Pincer bot
base.

```py
from pincer import Client, command
from pincer import Client, command, Descripted
class Bot(Client):
Expand All @@ -140,8 +140,8 @@ class Bot(Client):
@command(description="Add two numbers!")
async def add(
self,
first: (int, "The first number"), # support arg descriptions
second: (int, "The second number") # since 0.7.1
first: Descripted[int, "The first number"],
second: Descripted[int, "The second number"]
):
return f"The addition of `{first}` and `{second}` is `{first + second}`"
```
Expand Down
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ An asynchronous Python API wrapper meant to replace discord.py

## :pushpin: Links

> <img src="../assets/svg/discord.svg" width="16px" alt="Discord Logo"> |Join the Discord server: https://discord.gg/8WkYz3fNFm <br>
> <img src="../assets/svg/discord.svg" width="16px" alt="Discord Logo"> |Join the Discord server: https://discord.gg/pincer <br>
> <img src="../assets/svg/pypi.svg" width="16px" alt="PyPI Logo"> |The PyPI package: https://pypi.org/project/Pincer <br>
> <img src="../assets/svg/pincer.svg" width="16px" alt="Pincer Logo"> |Our website: https://pincer.dev <br>
> 📝 | ReadTheDocs: https://pincer.readthedocs.io
Expand Down Expand Up @@ -125,7 +125,7 @@ You have the possibility to use your own class to inherit from the Pincer bot
base.

```py
from pincer import Client, command
from pincer import Client, command, Descripted
class Bot(Client):
Expand All @@ -152,8 +152,8 @@ class Bot(Client):
@command(description="Add two numbers!")
async def add(
self,
first: (int, "The first number"), # support arg descriptions!
second: (int, "The second number") # since 0.7.1
first: Descripted[int, "The first number"],
second: Descripted[int, "The second number"]
):
return f"The addition of `{first}` and `{second}` is `{first + second}`"
```
Expand Down
32 changes: 32 additions & 0 deletions docs/pincer.middleware.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,38 @@ pincer.middleware.guild\_create module
:undoc-members:
:show-inheritance:

pincer.middleware.guild\_member\_add module
-------------------------------------------

.. automodule:: pincer.middleware.guild_member_add
:members:
:undoc-members:
:show-inheritance:

pincer.middleware.guild\_member\_remove module
----------------------------------------------

.. automodule:: pincer.middleware.guild_member_remove
:members:
:undoc-members:
:show-inheritance:

pincer.middleware.guild\_member\_update module
----------------------------------------------

.. automodule:: pincer.middleware.guild_member_update
:members:
:undoc-members:
:show-inheritance:

pincer.middleware.guild\_members\_chunk module
----------------------------------------------

.. automodule:: pincer.middleware.guild_members_chunk
:members:
:undoc-members:
:show-inheritance:

pincer.middleware.guild\_status module
--------------------------------------

Expand Down
16 changes: 16 additions & 0 deletions docs/pincer.objects.app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ pincer.objects.app.command module
:undoc-members:
:show-inheritance:

pincer.objects.app.command\_types module
----------------------------------------

.. automodule:: pincer.objects.app.command_types
:members:
:undoc-members:
:show-inheritance:

pincer.objects.app.intents module
---------------------------------

Expand All @@ -36,6 +44,14 @@ pincer.objects.app.interaction\_base module
:undoc-members:
:show-inheritance:

pincer.objects.app.interaction\_flags module
--------------------------------------------

.. automodule:: pincer.objects.app.interaction_flags
:members:
:undoc-members:
:show-inheritance:

pincer.objects.app.interactions module
--------------------------------------

Expand Down
8 changes: 8 additions & 0 deletions docs/pincer.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ pincer.utils.conversion module
:undoc-members:
:show-inheritance:

pincer.utils.convert\_message module
------------------------------------

.. automodule:: pincer.utils.convert_message
:members:
:undoc-members:
:show-inheritance:

pincer.utils.directory module
-----------------------------

Expand Down
8 changes: 4 additions & 4 deletions examples/chat_commands_class_based.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pincer import Client, command
from pincer import Client, command, Descripted
from pincer.objects import Message, InteractionFlags, Embed


Expand All @@ -17,13 +17,13 @@ async def say(self, message: str):
@command(description="Add two numbers!")
async def add(
self,
first: (int, "The first number"),
second: (int, "The second number")
first: Descripted[int, "The first number"],
second: Descripted[int, "The second number"]
):
return f"The addition of `{first}` and `{second}` is `{first + second}`"

@command(guild=1324567890)
async def private_say(self, message: (str, "The content of the message")):
async def private_say(self, message: Descripted[str, "The content of the message"]):
return Message(message, flags=InteractionFlags.EPHEMERAL)

@command(description="How to make embed!")
Expand Down
11 changes: 6 additions & 5 deletions examples/chat_commands_function_based.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pincer import command, Client
from pincer import command, Client, Descripted
from pincer.objects import Message, InteractionFlags, Embed


Expand All @@ -11,20 +11,20 @@ async def on_ready(self):


@command(description="Say something as the bot!")
async def say(message: (str, "The content of the message")):
async def say(message: Descripted[str, "The content of the message"]):
return message


@command(description="Add two numbers!")
async def add(
first: (int, "The first number"),
second: (int, "The second number")
first: Descripted[int, "The first number"],
second: Descripted[int, "The second number"]
):
return f"The addition of `{first}` and `{second}` is `{first + second}`"


@command(guild=1324567890)
async def private_say(message: (str, "The content of the message")):
async def private_say(message: Descripted[str, "The content of the message"]):
return Message(message, flags=InteractionFlags.EPHEMERAL)


Expand All @@ -49,5 +49,6 @@ async def pincer_embed():
)
)


if __name__ == "__main__":
Client("XXXYOURBOTTOKENHEREXXX").run()
4 changes: 2 additions & 2 deletions examples/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pincer import Client, command
from pincer import Client, command, Descripted
from pincer.objects import Embed


Expand All @@ -7,7 +7,7 @@ class Bot(Client):
@command(description="Say something as the bot!")
async def say(
self, ctx,
content: (str, "The content of the message")
content: Descripted[str, "The content of the message"]
) -> Embed:
# Using the ctx to get the command author
return Embed(
Expand Down
2 changes: 1 addition & 1 deletion packages/dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage==6.0.2
coverage==6.1.1
flake8==3.9.2
tox==3.24.4
pytest==6.2.5
Expand Down
8 changes: 4 additions & 4 deletions pincer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .client import Client, Bot
from .commands import command
from .objects import Intents
from .utils import Choices
from .utils import Choices, Descripted

__package__ = "pincer"
__title__ = "Pincer library"
Expand Down Expand Up @@ -43,9 +43,9 @@ def __repr__(self) -> str:
)


__version__ = VersionInfo(0, 9, 3)
__version__ = VersionInfo(0, 10, 0)

__all__ = (
"Bot", "Choices", "Client", "Intents", "__author__", "__email__",
"__package__", "__title__", "__version__", "command"
"Bot", "Choices", "Client", "Descripted", "Intents", "__author__",
"__email__", "__package__", "__title__", "__version__", "command"
)
23 changes: 16 additions & 7 deletions pincer/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Full MIT License can be found in `LICENSE` at the project root.

from dataclasses import dataclass
from typing import Optional


@dataclass
Expand All @@ -13,16 +14,24 @@ class GatewayConfig:
socket_base_url: str = "wss://gateway.discord.gg/"
version: int = 9
encoding: str = "json"
compression: str = "zlib-stream"
compression: Optional[str] = "zlib-stream"

@staticmethod
def uri() -> str:
@classmethod
def uri(cls) -> str:
"""
:return uri:
The GatewayConfig's uri.
"""
return (
f"{GatewayConfig.socket_base_url}"
f"?v={GatewayConfig.version}"
f"&encoding={GatewayConfig.encoding}"
)
f"{cls.socket_base_url}"
f"?v={cls.version}"
f"&encoding={cls.encoding}"
) + f"&compress={cls.compression}" * cls.compressed()

@classmethod
def compressed(cls) -> bool:
"""
:return compressed:
Whether the Gateway should compress payloads or not.
"""
return cls.compression in ["zlib-stream", "zlib-payload"]
Loading

0 comments on commit c15675c

Please sign in to comment.