Skip to content

Commit

Permalink
PyLav PR #228 (#309)
Browse files Browse the repository at this point in the history
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Draper <[email protected]>
Co-authored-by: Crowdin Bot <[email protected]>
  • Loading branch information
3 people authored May 19, 2023
1 parent ef457bc commit 3d32ca4
Show file tree
Hide file tree
Showing 36 changed files with 617 additions and 196 deletions.
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
- id: check-json
- id: check-symlinks
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.1
rev: v2.0.2
hooks:
- id: autoflake
args: [--remove-all-unused-imports, --recursive, --in-place, --remove-unused-variables, --ignore-init-module-imports, --remove-duplicate-keys]
Expand Down Expand Up @@ -61,24 +61,19 @@ repos:
- id: upgrade-type-hints
args: [--futures=true]
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.21.0
rev: 0.22.0
hooks:
- id: check-github-actions
- id: check-dependabot
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.7.0
rev: v2.8.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '4']
- repo: https://github.com/asottile/blacken-docs
rev: 1.13.0
hooks:
- id: blacken-docs
- repo: https://github.com/sourcery-ai/sourcery
rev: v1.0.5
hooks:
- id: sourcery
args: [--diff=git diff HEAD, --in-place, --no-summary]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
Expand All @@ -96,7 +91,7 @@ repos:
- repo: https://github.com/psf/black
# The `refs/tags/<tag>:refs/tags/<tag>` is needed for black's required-version to work:
# https://github.com/psf/black/issues/2493#issuecomment-1081987650
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker
Expand Down
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.DEFAULT_GOAL := help
PYTHON ?= python3
POETRY ?= poetry
PRECOMMIT ?= pre-commit

ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))


ifneq ($(wildcard $(ROOT_DIR)/venv/.),)
VENV_PYTHON = $(ROOT_DIR)/venv/bin/python
VENV_POETRY = $(ROOT_DIR)/venv/bin/poetry
VENV_PRECOMMIT = $(ROOT_DIR)/venv/bin/pre-commit
else
VENV_PYTHON = $(PYTHON)
VENV_POETRY = $(POETRY)
VENV_PRECOMMIT = $(PRECOMMIT)
endif


define HELP_BODY
Usage:
make <command>

Commands:
reformat Reformat all staged files being tracked by git.
full-reformat Reformat all files being tracked by git.

bumpdeps Run's Poetry up
bump Bump the packages version
syncenv Sync this project's virtual environment to Red's latest dependencies.
lock Update the Poetry.lock file
plugins Install all necesarry Poetry Plugins

endef
export HELP_BODY

# Python Code Style
reformat:
$(VENV_PRECOMMIT) run
full-reformat:
$(VENV_PRECOMMIT) run --all

# Poetry
bumpdeps:
$(VENV_POETRY) up --latest
syncenv:
$(VENV_POETRY) install
lock:
$(VENV_POETRY) lock
bump:
$(VENV_POETRY) dynamic-versioning
plugins:
$(VENV_POETRY) self add "poetry-dynamic-versioning[plugin]"
$(VENV_POETRY) self add "poetry-plugin-up"
38 changes: 5 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Official [PyLav](https://github.com/PyLav/Py-Lav) Cogs for [Red-DiscordBot](https://github.com/Cog-Creators/Red-DiscordBot)
[![Crowdin](https://badges.crowdin.net/pylav/localized.svg)](https://crowdin.com/project/pylav)[![GitHub license](https://img.shields.io/github/license/PyLav/Py-Lav.svg)](https://github.com/PyLav/Py-Lav/blob/master/LICENSE)
# Official [PyLav](https://github.com/PyLav/PyLav) Cogs for [Red-DiscordBot](https://github.com/Cog-Creators/Red-DiscordBot)
[![Crowdin](https://badges.crowdin.net/pylav/localized.svg)](https://crowdin.com/project/pylav)[![GitHub license](https://img.shields.io/github/license/PyLav/PyLav.svg)](https://github.com/PyLav/Py-Lav/blob/develop/LICENSE)
[![Support Server](https://img.shields.io/discord/970987707834720266)](https://discord.com/invite/vnmcXqtgeY)

About Cogs
Expand All @@ -14,7 +14,7 @@ About Cogs
| [PyLavNotifier](./plnotifier) | 1.0.0 | plnotifier | <details><summary>Load with `[p]load plnotifier`<br/><br/>A simple Cog which allows you enable/disable notify events from PyLav.<br/></summary><br/>This Cog allows you to use granularity when disabling/enabling events so that they are sent to the specified channel in your Discord server, useful for server owners who wish to see when a user takes a certain action in PyLav such as enqueueing tracks.</details> | No (1 text-only command) | No | [Draper](https://github.com/Drapersniper) |
| [PyLavPlaylists](./plplaylists) | 1.0.0 | plplaylists | <details><summary>Load with `[p]load plplaylists`<br/><br/>A Cog which allows you to add, manage, remove and share playlists in the User scope.<br/></summary><br/>Playlists created using this Cog can be shared across servers and support all inputs supported by PyLav.</details> | Yes (1 root level slash command) | No | [Draper](https://github.com/Drapersniper) |
| [PyLavUtils](./plutils) | 1.0.0 | plutils | <details><summary>Load with `[p]load plutils`<br/><br/>A handful of commands for Bot Owners to help them see information about the current track and info about the track cache PyLav uses.</summary></details> | No (1 text-only group command) | No | [Draper](https://github.com/Drapersniper) |
| [PyLavLocalFiles](./pllocal) | 1.0.0 | pllocal | <details><summary>Load with `[p]load pllocal`<br/><br/>Commands to interact with local media files in the local file folder specified by PyLav.</summary>The local file folder is configured using the PyLavConfigurator Cog, this allows you to play a plethora local files assuming Lavalink supports both the file and codecs, a list of all fully and partially supported files can be seen [here](https://github.com/PyLav/PyLav/blob/master/pylav/localfiles/__init__.py#L12).</details> | Yes (1 root level slash command and 1 text-only command) | No | [Draper](https://github.com/Drapersniper) |
| [PyLavLocalFiles](./pllocal) | 1.0.0 | pllocal | <details><summary>Load with `[p]load pllocal`<br/><br/>Commands to interact with local media files in the local file folder specified by PyLav.</summary>The local file folder is configured using the PyLavConfigurator Cog, this allows you to play a plethora local files assuming Lavalink supports both the file and codecs, a list of all fully and partially supported files can be seen [here](https://github.com/PyLav/PyLav/blob/develop/pylav/localfiles/__init__.py#L12).</details> | Yes (1 root level slash command and 1 text-only command) | No | [Draper](https://github.com/Drapersniper) |
| [PyLavEffects](./pleffects) | 1.0.0 | pleffects | <details><summary>Load with `[p]load pleffects`<br/><br/>Slash commands to apply filters to the player.</summary>Effects supported are Channel Mix, Distortion, Karaoke, LowPass, Rotation, Timescale, Tremolo, Vibrato and Equalizer using these effects in conjunction, allows you to achieve some really cool effects such as Nightcore and Vaporwave.</details> | Yes (1 root level slash command and 1 text-only command) | No | [Draper](https://github.com/Drapersniper) |
| [PyLavManagedNode](./plmanagednode) | 1.0.0 | plmanagednode | <details><summary>Load with `[p]load plmanagednode`<br/><br/>Commands to configure Pylav's managed node.</summary>This cog will allow you to enable/disable functionality of PyLav's managed node, the node can be disabled using the PyLavConfigurator Cog</details> | No (1 text-only command) | No | [Draper](https://github.com/Drapersniper) |
| [PyLavRadio](./plradio) | 1.0.0 | plradio | <details><summary>Load with `[p]load plradio`<br/><br/>Play radio stations.</summary>This cog allows you to interact with 30,000+ radio stations.</details> | Yes (1 root level slash command) | No | [Draper](https://github.com/Drapersniper) |
Expand All @@ -24,19 +24,13 @@ About Cogs
* Cogs with version 1.0.0rc0 are considered finished and stable bar feature requests.
* Cogs under version 1.0.0 are considered under development and may change without notice.

Installation
---------------------------
To add the cogs to your Red instance run:
- `[p]repo add PyLav https://github.com/PyLav/Red-Cogs`.
- `[p]cog install PyLav <Package Name>`
- `[p]load <Package Name>`

Documentation
---------------------------

Getting Started
-------------------------------------
Follow [PyLav Setup](https://github.com/PyLav/PyLav/blob/master/SETUP.md)
> **Warning**
> Make sure to follow [PyLav Setup](https://github.com/PyLav/PyLav/blob/develop/SETUP.md)

If you already have a Red instance with PyLav setup then you can do the following
Expand All @@ -46,29 +40,7 @@ If you already have a Red instance with PyLav setup then you can do the followin
[p]cog install PyLav audio
[p]load audio
```
------------------------------------
System Requirements
------------------------------------
With a locally hosted Postgres server and locally hosted/managed lavalink node (**recommended - Best performance**):
- CPU: 3 cores or more
- RAM: 4GB or more
- Disk Space: 10GB or more (NVME Ideally, SSD OK)

With a locally hosted Postgres server and externally hosted lavalink node (Okay performance):
- CPU: 2 cores or more
- RAM: 3GB or more
- Disk Space: 10GB or more (NVME Ideally, SSD OK)

With an externally hosted Postgres server and locally hosted/managed lavalink node (Poor performance):
- CPU: 2 cores or more
- RAM: 2GB or more
- Disk Space: 10GB or more (SSD)

With an externally hosted Postgres server and externally hosted lavalink node (Worst performance):
- CPU: 1 cores or more
- RAM: 1GB or more
- Disk Space: 10GB or more (SSD)
------------------------------------
Translations
------------------------------------
You can help translating the project into your language here:
Expand Down
10 changes: 8 additions & 2 deletions audio/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ def __init__(self, bot: DISCORD_BOT_TYPE, *args: Any, **kwargs: Any):
enable_context=False,
)
self.context_user_play = discord.app_commands.ContextMenu(
name=_("Play from activity"), callback=self._context_user_play, type=AppCommandType.user
name=_("Play from activity"),
callback=self._context_user_play,
type=AppCommandType.user,
extras={"red_force_enable": True},
)
self.context_message_play = discord.app_commands.ContextMenu(
name=_("Play from message"), callback=self._context_message_play, type=AppCommandType.message
name=_("Play from message"),
callback=self._context_message_play,
type=AppCommandType.message,
extras={"red_force_enable": True},
)
self.bot.tree.add_command(self.context_user_play)
self.bot.tree.add_command(self.context_message_play)
Expand Down
13 changes: 11 additions & 2 deletions audio/context_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,16 @@ async def _context_user_play(
await Query.from_string(search_string),
player=interaction.client.pylav.get_player(interaction.guild.id),
)
if not response.tracks:
match response.loadType:
case "track":
tracks = [response.data]
case "search":
tracks = response.data
case "playlist":
tracks = response.data.tracks
case __:
tracks = []
if not tracks:
await interaction.followup.send(
embed=await self.pylav.construct_embed(
description=_("I could not find any tracks matching {query_variable_do_not_translate}.").format(
Expand All @@ -240,7 +249,7 @@ async def _context_user_play(
await self.command_play.callback(
self,
interaction,
query=response.tracks[0],
query=tracks[0],
)
else:
await interaction.followup.send(
Expand Down
Loading

0 comments on commit 3d32ca4

Please sign in to comment.