Compare commits
11 Commits
88e88c0ca2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
7d6373e38b
|
|||
|
3a5e182970
|
|||
|
45b6ccdf22
|
|||
|
0a80999ca7
|
|||
|
8194268ce1
|
|||
|
ed3afdbeae
|
|||
|
3ca6f487c6
|
|||
|
f0e1325a6c
|
|||
|
4185723b8d
|
|||
|
3232e797c8
|
|||
|
1836785b05
|
6
.envrc
Normal file
6
.envrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
dotenv
|
||||||
|
|
||||||
|
export VIRTUAL_ENV=."venv"
|
||||||
|
layout python
|
||||||
|
|
||||||
|
use flake
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.direnv
|
||||||
.env
|
.env
|
||||||
.venv
|
.venv
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ COPY . .
|
|||||||
|
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
CMD ["python", "main.py"]
|
CMD ["python", "-m", "errornocord.main"]
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# ErrorNoCord
|
# ErrorNoCord
|
||||||
|
|
||||||
Discord music bot for testing purposes, with live reloading support
|
Hot-reloadable Discord music bot
|
||||||
|
|||||||
59
default.nix
Normal file
59
default.nix
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
python3Packages,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
disnake = python3Packages.disnake.overrideAttrs (old: {
|
||||||
|
src = self.pins.disnake;
|
||||||
|
|
||||||
|
propagatedBuildInputs =
|
||||||
|
with python3Packages;
|
||||||
|
old.propagatedBuildInputs
|
||||||
|
++ [
|
||||||
|
typing-extensions
|
||||||
|
versioningit
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = old.nativeBuildInputs ++ [ python3Packages.hatchling ];
|
||||||
|
});
|
||||||
|
|
||||||
|
disnake_paginator = python3Packages.buildPythonPackage {
|
||||||
|
pname = "disnake-paginator";
|
||||||
|
version = "1.0.8";
|
||||||
|
|
||||||
|
src = self.pins.disnake-paginator;
|
||||||
|
|
||||||
|
pyproject = true;
|
||||||
|
build-system = [ python3Packages.setuptools ];
|
||||||
|
|
||||||
|
propagatedBuildInputs = [
|
||||||
|
disnake
|
||||||
|
];
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
python3Packages.buildPythonApplication {
|
||||||
|
pname = "errornocord";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
src = lib.cleanSource ./.;
|
||||||
|
|
||||||
|
pyproject = true;
|
||||||
|
build-system = [ python3Packages.setuptools ];
|
||||||
|
|
||||||
|
propagatedBuildInputs = with python3Packages; [
|
||||||
|
aiohttp
|
||||||
|
audioop-lts
|
||||||
|
disnake
|
||||||
|
disnake_paginator
|
||||||
|
psutil
|
||||||
|
typing-extensions
|
||||||
|
youtube-transcript-api
|
||||||
|
yt-dlp
|
||||||
|
];
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
}
|
||||||
0
errornocord/__init__.py
Normal file
0
errornocord/__init__.py
Normal file
@@ -2,7 +2,7 @@ import argparse
|
|||||||
import contextlib
|
import contextlib
|
||||||
import io
|
import io
|
||||||
|
|
||||||
import utils
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
class ArgumentParser:
|
class ArgumentParser:
|
||||||
@@ -4,8 +4,7 @@ from typing import ClassVar, Optional
|
|||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
from constants import BAR_LENGTH, EMBED_COLOR
|
from ..constants import BAR_LENGTH, EMBED_COLOR
|
||||||
|
|
||||||
from .utils import format_duration
|
from .utils import format_duration
|
||||||
from .youtubedl import YTDLSource
|
from .youtubedl import YTDLSource
|
||||||
|
|
||||||
@@ -4,8 +4,7 @@ from typing import Any, Optional
|
|||||||
import disnake
|
import disnake
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
|
|
||||||
from constants import YTDL_OPTIONS
|
from ..constants import YTDL_OPTIONS
|
||||||
|
|
||||||
from .discord import PCMVolumeTransformer, TrackedAudioSource
|
from .discord import PCMVolumeTransformer, TrackedAudioSource
|
||||||
|
|
||||||
ytdl = yt_dlp.YoutubeDL(YTDL_OPTIONS)
|
ytdl = yt_dlp.YoutubeDL(YTDL_OPTIONS)
|
||||||
@@ -6,11 +6,10 @@ import disnake
|
|||||||
import psutil
|
import psutil
|
||||||
from yt_dlp import version
|
from yt_dlp import version
|
||||||
|
|
||||||
import arguments
|
from .. import arguments, commands
|
||||||
import commands
|
from ..constants import EMBED_COLOR
|
||||||
from constants import EMBED_COLOR
|
from ..state import client, start_time
|
||||||
from state import client, start_time
|
from ..utils import format_duration, reply, surround
|
||||||
from utils import format_duration, reply, surround
|
|
||||||
|
|
||||||
|
|
||||||
async def status(message):
|
async def status(message):
|
||||||
@@ -3,11 +3,9 @@ import re
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
import arguments
|
from .. import arguments, commands, utils
|
||||||
import commands
|
from ..constants import APPLICATION_FLAGS, BADGE_EMOJIS, EMBED_COLOR, PUBLIC_FLAGS
|
||||||
import utils
|
from ..state import client
|
||||||
from constants import APPLICATION_FLAGS, BADGE_EMOJIS, EMBED_COLOR, PUBLIC_FLAGS
|
|
||||||
from state import client
|
|
||||||
|
|
||||||
|
|
||||||
async def lookup(message):
|
async def lookup(message):
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
import constants
|
from .. import constants
|
||||||
|
|
||||||
|
|
||||||
class Command(Enum):
|
class Command(Enum):
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import utils
|
from ... import utils
|
||||||
|
from ...state import players
|
||||||
from .utils import command_allowed
|
from .utils import command_allowed
|
||||||
|
|
||||||
|
|
||||||
@@ -20,5 +20,8 @@ async def leave(message):
|
|||||||
if not command_allowed(message):
|
if not command_allowed(message):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if message.guild.id in players:
|
||||||
|
del players[message.guild.id]
|
||||||
await message.guild.voice_client.disconnect()
|
await message.guild.voice_client.disconnect()
|
||||||
|
|
||||||
await utils.add_check_reaction(message)
|
await utils.add_check_reaction(message)
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
import disnake_paginator
|
import disnake_paginator
|
||||||
|
|
||||||
import arguments
|
from ... import arguments, commands, sponsorblock, utils
|
||||||
import commands
|
from ...constants import EMBED_COLOR
|
||||||
import sponsorblock
|
from ...state import players
|
||||||
import utils
|
|
||||||
from constants import EMBED_COLOR
|
|
||||||
from state import players
|
|
||||||
|
|
||||||
from .utils import command_allowed
|
from .utils import command_allowed
|
||||||
|
|
||||||
|
|
||||||
@@ -90,7 +86,9 @@ async def pause(message):
|
|||||||
|
|
||||||
async def fast_forward(message):
|
async def fast_forward(message):
|
||||||
tokens = commands.tokenize(message.content)
|
tokens = commands.tokenize(message.content)
|
||||||
parser = arguments.ArgumentParser(tokens[0], "skip the current sponsorblock segment")
|
parser = arguments.ArgumentParser(
|
||||||
|
tokens[0], "skip the current sponsorblock segment"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-s",
|
"-s",
|
||||||
"--seconds",
|
"--seconds",
|
||||||
@@ -3,13 +3,9 @@ import itertools
|
|||||||
import disnake
|
import disnake
|
||||||
import disnake_paginator
|
import disnake_paginator
|
||||||
|
|
||||||
import arguments
|
from ... import arguments, audio, commands, utils
|
||||||
import audio
|
from ...constants import EMBED_COLOR
|
||||||
import commands
|
from ...state import client, players, trusted_users
|
||||||
import utils
|
|
||||||
from constants import EMBED_COLOR
|
|
||||||
from state import client, players, trusted_users
|
|
||||||
|
|
||||||
from .playback import resume
|
from .playback import resume
|
||||||
from .utils import command_allowed, ensure_joined, play_next
|
from .utils import command_allowed, ensure_joined, play_next
|
||||||
|
|
||||||
@@ -139,8 +135,9 @@ async def queue_or_play(message, edited=False):
|
|||||||
and len(
|
and len(
|
||||||
list(
|
list(
|
||||||
filter(
|
filter(
|
||||||
lambda queued: queued.trigger_message.author.id
|
lambda queued: (
|
||||||
== message.author.id,
|
queued.trigger_message.author.id == message.author.id
|
||||||
|
),
|
||||||
players[message.guild.id].queue,
|
players[message.guild.id].queue,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -254,7 +251,8 @@ async def skip(message):
|
|||||||
if not command_allowed(message):
|
if not command_allowed(message):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not players[message.guild.id] and not players[message.guild.id].queue:
|
if players[message.guild.id] and not players[message.guild.id].queue:
|
||||||
|
del players[message.guild.id]
|
||||||
message.guild.voice_client.stop()
|
message.guild.voice_client.stop()
|
||||||
await utils.reply(
|
await utils.reply(
|
||||||
message,
|
message,
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
import audio
|
from ... import audio, sponsorblock, utils
|
||||||
import sponsorblock
|
from ...constants import EMBED_COLOR, SPONSORBLOCK_CATEGORY_NAMES
|
||||||
import utils
|
from ...state import players
|
||||||
from constants import EMBED_COLOR, SPONSORBLOCK_CATEGORY_NAMES
|
|
||||||
from state import players
|
|
||||||
|
|
||||||
from .utils import command_allowed
|
from .utils import command_allowed
|
||||||
|
|
||||||
|
|
||||||
@@ -2,8 +2,8 @@ from logging import error
|
|||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
import utils
|
from ... import utils
|
||||||
from state import client, players
|
from ...state import client, players
|
||||||
|
|
||||||
|
|
||||||
def play_after_callback(e, message, once):
|
def play_after_callback(e, message, once):
|
||||||
@@ -31,34 +31,34 @@ REACTIONS = {
|
|||||||
"pizza": ["🍕"],
|
"pizza": ["🍕"],
|
||||||
}
|
}
|
||||||
RELOADABLE_MODULES = [
|
RELOADABLE_MODULES = [
|
||||||
"arguments",
|
"errornocord.arguments",
|
||||||
"audio",
|
"errornocord.audio",
|
||||||
"audio.discord",
|
"errornocord.audio.discord",
|
||||||
"audio.queue",
|
"errornocord.audio.queue",
|
||||||
"audio.utils",
|
"errornocord.audio.utils",
|
||||||
"audio.youtubedl",
|
"errornocord.audio.youtubedl",
|
||||||
"commands",
|
"errornocord.commands",
|
||||||
"commands.bot",
|
"errornocord.commands.bot",
|
||||||
"commands.tools",
|
"errornocord.commands.tools",
|
||||||
"commands.utils",
|
"errornocord.commands.utils",
|
||||||
"commands.voice",
|
"errornocord.commands.voice",
|
||||||
"commands.voice.channel",
|
"errornocord.commands.voice.channel",
|
||||||
"commands.voice.playback",
|
"errornocord.commands.voice.playback",
|
||||||
"commands.voice.playing",
|
"errornocord.commands.voice.playing",
|
||||||
"commands.voice.queue",
|
"errornocord.commands.voice.queue",
|
||||||
"commands.voice.sponsorblock",
|
"errornocord.commands.voice.sponsorblock",
|
||||||
"commands.voice.utils",
|
"errornocord.commands.voice.utils",
|
||||||
"constants",
|
"errornocord.constants",
|
||||||
"core",
|
"errornocord.core",
|
||||||
"events",
|
"errornocord.events",
|
||||||
"extra",
|
"errornocord.extra",
|
||||||
"fun",
|
"errornocord.fun",
|
||||||
"sponsorblock",
|
"errornocord.sponsorblock",
|
||||||
"tasks",
|
"errornocord.tasks",
|
||||||
"utils",
|
"errornocord.utils",
|
||||||
"utils.common",
|
"errornocord.utils.common",
|
||||||
"utils.discord",
|
"errornocord.utils.discord",
|
||||||
"voice",
|
"errornocord.voice",
|
||||||
"yt_dlp",
|
"yt_dlp",
|
||||||
"yt_dlp.version",
|
"yt_dlp.version",
|
||||||
]
|
]
|
||||||
@@ -12,11 +12,10 @@ from logging import debug
|
|||||||
import disnake
|
import disnake
|
||||||
import disnake_paginator
|
import disnake_paginator
|
||||||
|
|
||||||
import commands
|
from . import commands, utils
|
||||||
import utils
|
from .commands import Command as C
|
||||||
from commands import Command as C
|
from .constants import EMBED_COLOR, OWNERS, PREFIX, RELOADABLE_MODULES
|
||||||
from constants import EMBED_COLOR, OWNERS, PREFIX, RELOADABLE_MODULES
|
from .state import client, command_cooldowns, command_locks, idle_tracker, players
|
||||||
from state import client, command_cooldowns, command_locks, idle_tracker
|
|
||||||
|
|
||||||
|
|
||||||
async def on_message(message, edited=False):
|
async def on_message(message, edited=False):
|
||||||
@@ -149,27 +148,31 @@ async def on_message(message, edited=False):
|
|||||||
command_locks[(message.guild.id, message.author.id)].release()
|
command_locks[(message.guild.id, message.author.id)].release()
|
||||||
|
|
||||||
|
|
||||||
async def on_voice_state_update(_, before, after):
|
async def on_voice_state_update(member, before, after):
|
||||||
def is_empty(channel):
|
def is_alone(channel):
|
||||||
return [m.id for m in (channel.members if channel else [])] == [client.user.id]
|
return [m.id for m in (channel.members if channel else [])] == [client.user.id]
|
||||||
|
|
||||||
channel = None
|
if member.id == client.user.id and is_alone(after.channel):
|
||||||
if is_empty(before.channel):
|
if before.channel.guild.id in players:
|
||||||
channel = before.channel
|
del players[before.channel.guild.id]
|
||||||
elif is_empty(after.channel):
|
await after.channel.guild.voice_client.disconnect()
|
||||||
channel = after.channel
|
return
|
||||||
|
|
||||||
if channel:
|
if is_alone(before.channel):
|
||||||
await channel.guild.voice_client.disconnect()
|
if before.channel.guild.id in players:
|
||||||
|
del players[before.channel.guild.id]
|
||||||
|
await before.channel.guild.voice_client.disconnect()
|
||||||
|
|
||||||
|
|
||||||
def rreload(reloaded_modules, module):
|
def rreload(reloaded_modules, module):
|
||||||
reloaded_modules.add(module.__name__)
|
reloaded_modules.add(module.__name__)
|
||||||
|
|
||||||
for submodule in filter(
|
for submodule in filter(
|
||||||
lambda sm: inspect.ismodule(sm)
|
lambda sm: (
|
||||||
|
inspect.ismodule(sm)
|
||||||
and sm.__name__ in RELOADABLE_MODULES
|
and sm.__name__ in RELOADABLE_MODULES
|
||||||
and sm.__name__ not in reloaded_modules,
|
and sm.__name__ not in reloaded_modules
|
||||||
|
),
|
||||||
vars(module).values(),
|
vars(module).values(),
|
||||||
):
|
):
|
||||||
rreload(reloaded_modules, submodule)
|
rreload(reloaded_modules, submodule)
|
||||||
@@ -182,8 +185,8 @@ def rreload(reloaded_modules, module):
|
|||||||
|
|
||||||
def reload(*_):
|
def reload(*_):
|
||||||
reloaded_modules = set()
|
reloaded_modules = set()
|
||||||
rreload(reloaded_modules, __import__("core"))
|
rreload(reloaded_modules, __import__("errornocord.core"))
|
||||||
rreload(reloaded_modules, __import__("extra"))
|
rreload(reloaded_modules, __import__("errornocord.extra"))
|
||||||
for module in filter(
|
for module in filter(
|
||||||
lambda v: inspect.ismodule(v) and v.__name__ in RELOADABLE_MODULES,
|
lambda v: inspect.ismodule(v) and v.__name__ in RELOADABLE_MODULES,
|
||||||
globals().values(),
|
globals().values(),
|
||||||
@@ -2,11 +2,8 @@ import asyncio
|
|||||||
import threading
|
import threading
|
||||||
from logging import debug, info, warning
|
from logging import debug, info, warning
|
||||||
|
|
||||||
import commands
|
from . import commands, core, fun, tasks
|
||||||
import core
|
from .state import client
|
||||||
import fun
|
|
||||||
import tasks
|
|
||||||
from state import client
|
|
||||||
|
|
||||||
|
|
||||||
def prepare():
|
def prepare():
|
||||||
@@ -4,7 +4,7 @@ import string
|
|||||||
import disnake
|
import disnake
|
||||||
from youtube_transcript_api._api import YouTubeTranscriptApi
|
from youtube_transcript_api._api import YouTubeTranscriptApi
|
||||||
|
|
||||||
from state import client, kill, players
|
from .state import client, kill, players
|
||||||
|
|
||||||
|
|
||||||
async def transcript(
|
async def transcript(
|
||||||
@@ -31,9 +31,7 @@ async def transcript(
|
|||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
while (
|
while players[message.guild.id].current.player.original.progress < line.start:
|
||||||
players[message.guild.id].current.player.original.progress < line.start
|
|
||||||
):
|
|
||||||
await asyncio.sleep(0.2)
|
await asyncio.sleep(0.2)
|
||||||
|
|
||||||
messages.insert(
|
messages.insert(
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
import commands
|
from . import commands
|
||||||
from constants import REACTIONS
|
from .constants import REACTIONS
|
||||||
|
|
||||||
|
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import constants
|
from . import constants, events
|
||||||
import events
|
from .state import client
|
||||||
from state import client
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
def main():
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format=(
|
format=(
|
||||||
"%(asctime)s %(levelname)s %(name)s:%(module)s %(message)s"
|
"%(asctime)s %(levelname)s %(name)s:%(module)s %(message)s"
|
||||||
@@ -18,3 +18,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
events.prepare()
|
events.prepare()
|
||||||
client.run(constants.SECRETS["TOKEN"])
|
client.run(constants.SECRETS["TOKEN"])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -3,7 +3,7 @@ import json
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from state import sponsorblock_cache
|
from .state import sponsorblock_cache
|
||||||
|
|
||||||
categories = json.dumps(
|
categories = json.dumps(
|
||||||
[
|
[
|
||||||
@@ -2,7 +2,7 @@ import time
|
|||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
from utils import LimitedSizeDict
|
from .utils import LimitedSizeDict
|
||||||
|
|
||||||
intents = disnake.Intents.default()
|
intents = disnake.Intents.default()
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
@@ -4,7 +4,7 @@ from logging import debug, error
|
|||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
from state import client, idle_tracker, players
|
from .state import client, idle_tracker, players
|
||||||
|
|
||||||
|
|
||||||
async def cleanup():
|
async def cleanup():
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from constants import SECRETS
|
from ..constants import SECRETS
|
||||||
|
|
||||||
|
|
||||||
def surround(inner: str, outer="```") -> str:
|
def surround(inner: str, outer="```") -> str:
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
import ctypes
|
import ctypes
|
||||||
import time
|
import time
|
||||||
from logging import debug, error
|
from logging import debug, error
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import disnake
|
import disnake
|
||||||
|
|
||||||
import commands
|
from .. import commands
|
||||||
from constants import OWNERS
|
from ..constants import OWNERS
|
||||||
from state import command_cooldowns, message_responses
|
from ..state import command_cooldowns, message_responses
|
||||||
|
|
||||||
|
|
||||||
def cooldown(message, cooldown_time: int):
|
def cooldown(message, cooldown_time: int):
|
||||||
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772408722,
|
||||||
|
"narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1773821835,
|
||||||
|
"narHash": "sha256-TJ3lSQtW0E2JrznGVm8hOQGVpXjJyXY2guAxku2O9A4=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "b40629efe5d6ec48dd1efba650c797ddbd39ace0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1772328832,
|
||||||
|
"narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "nixpkgs.lib",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
42
flake.nix
Normal file
42
flake.nix
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
flake-parts,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}@inputs:
|
||||||
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
|
systems = [
|
||||||
|
"aarch64-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
perSystem =
|
||||||
|
{ pkgs, self', ... }:
|
||||||
|
{
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
name = "errornocord";
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
ffmpeg
|
||||||
|
self'.packages.default
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = rec {
|
||||||
|
errornocord = pkgs.callPackage ./. { inherit self; };
|
||||||
|
default = errornocord;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
flake.pins = import ./npins;
|
||||||
|
};
|
||||||
|
|
||||||
|
description = "Hot-reloadable Discord music bot";
|
||||||
|
}
|
||||||
249
npins/default.nix
Normal file
249
npins/default.nix
Normal file
@@ -0,0 +1,249 @@
|
|||||||
|
/*
|
||||||
|
This file is provided under the MIT licence:
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.
|
||||||
|
*/
|
||||||
|
# Generated by npins. Do not modify; will be overwritten regularly
|
||||||
|
let
|
||||||
|
# Backwards-compatibly make something that previously didn't take any arguments take some
|
||||||
|
# The function must return an attrset, and will unfortunately be eagerly evaluated
|
||||||
|
# Same thing, but it catches eval errors on the default argument so that one may still call it with other arguments
|
||||||
|
mkFunctor =
|
||||||
|
fn:
|
||||||
|
let
|
||||||
|
e = builtins.tryEval (fn { });
|
||||||
|
in
|
||||||
|
(if e.success then e.value else { error = fn { }; }) // { __functor = _self: fn; };
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
|
||||||
|
range =
|
||||||
|
first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1);
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
|
||||||
|
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
|
||||||
|
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
|
||||||
|
concatStrings = builtins.concatStringsSep "";
|
||||||
|
|
||||||
|
# If the environment variable NPINS_OVERRIDE_${name} is set, then use
|
||||||
|
# the path directly as opposed to the fetched source.
|
||||||
|
# (Taken from Niv for compatibility)
|
||||||
|
mayOverride =
|
||||||
|
name: path:
|
||||||
|
let
|
||||||
|
envVarName = "NPINS_OVERRIDE_${saneName}";
|
||||||
|
saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name;
|
||||||
|
ersatz = builtins.getEnv envVarName;
|
||||||
|
in
|
||||||
|
if ersatz == "" then
|
||||||
|
path
|
||||||
|
else
|
||||||
|
# this turns the string into an actual Nix path (for both absolute and
|
||||||
|
# relative paths)
|
||||||
|
builtins.trace "Overriding path of \"${name}\" with \"${ersatz}\" due to set \"${envVarName}\"" (
|
||||||
|
if builtins.substring 0 1 ersatz == "/" then
|
||||||
|
/. + ersatz
|
||||||
|
else
|
||||||
|
/. + builtins.getEnv "PWD" + "/${ersatz}"
|
||||||
|
);
|
||||||
|
|
||||||
|
mkSource =
|
||||||
|
name: spec:
|
||||||
|
{
|
||||||
|
pkgs ? null,
|
||||||
|
}:
|
||||||
|
assert spec ? type;
|
||||||
|
let
|
||||||
|
# Unify across builtin and pkgs fetchers.
|
||||||
|
# `fetchGit` requires a wrapper because of slight API differences.
|
||||||
|
fetchers =
|
||||||
|
if pkgs == null then
|
||||||
|
{
|
||||||
|
inherit (builtins) fetchTarball fetchurl;
|
||||||
|
# For some fucking reason, fetchGit has a different signature than the other builtin fetchers …
|
||||||
|
fetchGit = args: (builtins.fetchGit args).outPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fetchTarball =
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
sha256,
|
||||||
|
}:
|
||||||
|
pkgs.fetchzip {
|
||||||
|
inherit url sha256;
|
||||||
|
extension = "tar";
|
||||||
|
};
|
||||||
|
inherit (pkgs) fetchurl;
|
||||||
|
fetchGit =
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
submodules,
|
||||||
|
rev,
|
||||||
|
name,
|
||||||
|
narHash,
|
||||||
|
}:
|
||||||
|
pkgs.fetchgit {
|
||||||
|
inherit url rev name;
|
||||||
|
fetchSubmodules = submodules;
|
||||||
|
hash = narHash;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Dispatch to the correct code path based on the type
|
||||||
|
path =
|
||||||
|
if spec.type == "Git" then
|
||||||
|
mkGitSource fetchers spec
|
||||||
|
else if spec.type == "GitRelease" then
|
||||||
|
mkGitSource fetchers spec
|
||||||
|
else if spec.type == "PyPi" then
|
||||||
|
mkPyPiSource fetchers spec
|
||||||
|
else if spec.type == "Channel" then
|
||||||
|
mkChannelSource fetchers spec
|
||||||
|
else if spec.type == "Tarball" then
|
||||||
|
mkTarballSource fetchers spec
|
||||||
|
else if spec.type == "Container" then
|
||||||
|
mkContainerSource pkgs spec
|
||||||
|
else
|
||||||
|
builtins.throw "Unknown source type ${spec.type}";
|
||||||
|
in
|
||||||
|
spec // { outPath = mayOverride name path; };
|
||||||
|
|
||||||
|
mkGitSource =
|
||||||
|
{
|
||||||
|
fetchTarball,
|
||||||
|
fetchGit,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
repository,
|
||||||
|
revision,
|
||||||
|
url ? null,
|
||||||
|
submodules,
|
||||||
|
hash,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
assert repository ? type;
|
||||||
|
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
||||||
|
# In the latter case, there we will always be an url to the tarball
|
||||||
|
if url != null && !submodules then
|
||||||
|
fetchTarball {
|
||||||
|
inherit url;
|
||||||
|
sha256 = hash;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
let
|
||||||
|
url =
|
||||||
|
if repository.type == "Git" then
|
||||||
|
repository.url
|
||||||
|
else if repository.type == "GitHub" then
|
||||||
|
"https://github.com/${repository.owner}/${repository.repo}.git"
|
||||||
|
else if repository.type == "GitLab" then
|
||||||
|
"${repository.server}/${repository.repo_path}.git"
|
||||||
|
else if repository.type == "Forgejo" then
|
||||||
|
"${repository.server}/${repository.owner}/${repository.repo}.git"
|
||||||
|
else
|
||||||
|
throw "Unrecognized repository type ${repository.type}";
|
||||||
|
urlToName =
|
||||||
|
url: rev:
|
||||||
|
let
|
||||||
|
matched = builtins.match "^.*/([^/]*)(\\.git)?$" url;
|
||||||
|
|
||||||
|
short = builtins.substring 0 7 rev;
|
||||||
|
|
||||||
|
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
|
||||||
|
in
|
||||||
|
"${if matched == null then "source" else builtins.head matched}${appendShort}";
|
||||||
|
name = urlToName url revision;
|
||||||
|
in
|
||||||
|
fetchGit {
|
||||||
|
rev = revision;
|
||||||
|
narHash = hash;
|
||||||
|
|
||||||
|
inherit name submodules url;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkPyPiSource =
|
||||||
|
{ fetchurl, ... }:
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
hash,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
fetchurl {
|
||||||
|
inherit url;
|
||||||
|
sha256 = hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkChannelSource =
|
||||||
|
{ fetchTarball, ... }:
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
hash,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
fetchTarball {
|
||||||
|
inherit url;
|
||||||
|
sha256 = hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkTarballSource =
|
||||||
|
{ fetchTarball, ... }:
|
||||||
|
{
|
||||||
|
url,
|
||||||
|
locked_url ? url,
|
||||||
|
hash,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
fetchTarball {
|
||||||
|
url = locked_url;
|
||||||
|
sha256 = hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkContainerSource =
|
||||||
|
pkgs:
|
||||||
|
{
|
||||||
|
image_name,
|
||||||
|
image_tag,
|
||||||
|
image_digest,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
if pkgs == null then
|
||||||
|
builtins.throw "container sources require passing in a Nixpkgs value: https://github.com/andir/npins/blob/master/README.md#using-the-nixpkgs-fetchers"
|
||||||
|
else
|
||||||
|
pkgs.dockerTools.pullImage {
|
||||||
|
imageName = image_name;
|
||||||
|
imageDigest = image_digest;
|
||||||
|
finalImageTag = image_tag;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mkFunctor (
|
||||||
|
{
|
||||||
|
input ? ./sources.json,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
data =
|
||||||
|
if builtins.isPath input then
|
||||||
|
# while `readFile` will throw an error anyways if the path doesn't exist,
|
||||||
|
# we still need to check beforehand because *our* error can be caught but not the one from the builtin
|
||||||
|
# *piegames sighs*
|
||||||
|
if builtins.pathExists input then
|
||||||
|
builtins.fromJSON (builtins.readFile input)
|
||||||
|
else
|
||||||
|
throw "Input path ${toString input} does not exist"
|
||||||
|
else if builtins.isAttrs input then
|
||||||
|
input
|
||||||
|
else
|
||||||
|
throw "Unsupported input type ${builtins.typeOf input}, must be a path or an attrset";
|
||||||
|
version = data.version;
|
||||||
|
in
|
||||||
|
if version == 7 then
|
||||||
|
builtins.mapAttrs (name: spec: mkFunctor (mkSource name spec)) data.pins
|
||||||
|
else
|
||||||
|
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
||||||
|
)
|
||||||
26
npins/sources.json
Normal file
26
npins/sources.json
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"pins": {
|
||||||
|
"disnake": {
|
||||||
|
"type": "Git",
|
||||||
|
"repository": {
|
||||||
|
"type": "GitHub",
|
||||||
|
"owner": "DisnakeDev",
|
||||||
|
"repo": "disnake"
|
||||||
|
},
|
||||||
|
"branch": "master",
|
||||||
|
"submodules": false,
|
||||||
|
"revision": "79afc2d8673299f43636730d4a1518e7901f95fa",
|
||||||
|
"url": "https://github.com/DisnakeDev/disnake/archive/79afc2d8673299f43636730d4a1518e7901f95fa.tar.gz",
|
||||||
|
"hash": "sha256-7gsHFnqTyANdV+eosLI4MlzsMyebLdYZShEVObJPhl8="
|
||||||
|
},
|
||||||
|
"disnake-paginator": {
|
||||||
|
"type": "PyPi",
|
||||||
|
"name": "disnake-paginator",
|
||||||
|
"version_upper_bound": null,
|
||||||
|
"version": "1.0.8",
|
||||||
|
"url": "https://files.pythonhosted.org/packages/8c/db/3a86b247c7653a3f1676d16a316daf400edcf76295098ab60544f2a8f8b7/disnake_paginator-1.0.8.tar.gz",
|
||||||
|
"hash": "sha256-Sn0qbKNkJIdX8GCRRRPxwWutBtG9c1Zt7JnQAsl5I4s="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
13
pyproject.toml
Normal file
13
pyproject.toml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
[project]
|
||||||
|
name = "errornocord"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
errornocord = "errornocord.main:main"
|
||||||
|
|
||||||
|
[tool.setuptools.packages.find]
|
||||||
|
where = ["."]
|
||||||
|
include = ["errornocord*"]
|
||||||
|
|
||||||
|
[tool.basedpyright]
|
||||||
|
typeCheckingMode = "basic"
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
aiohttp
|
aiohttp
|
||||||
audioop-lts
|
disnake[voice] @ https://github.com/DisnakeDev/disnake/archive/master.tar.gz
|
||||||
disnake @ https://github.com/DisnakeDev/disnake/archive/master.tar.gz
|
|
||||||
disnake_paginator
|
disnake_paginator
|
||||||
psutil
|
psutil
|
||||||
PyNaCl
|
|
||||||
youtube_transcript_api
|
youtube_transcript_api
|
||||||
yt-dlp[default] @ https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz
|
yt-dlp[default] @ https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz
|
||||||
|
|||||||
Reference in New Issue
Block a user