mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
7d5c4666b8 |
@@ -3,9 +3,19 @@
|
|||||||
|
|
||||||
# Don't ignore nugetconfig
|
# Don't ignore nugetconfig
|
||||||
!./NuGet.Config
|
!./NuGet.Config
|
||||||
|
|
||||||
# Don't ignore src projects
|
# Don't ignore src projects
|
||||||
!src/**
|
!src/Nadeko.Econ/**
|
||||||
|
!src/Nadeko.Common/**
|
||||||
|
# Use Nadeko.Medusa project
|
||||||
|
!src/Nadeko.Medusa/**
|
||||||
|
# Use NadekoBot project
|
||||||
|
!src/NadekoBot/**
|
||||||
|
# Use NadekoBot.Coordinator project
|
||||||
|
!src/NadekoBot.Coordinator/**
|
||||||
|
# Use Generators project
|
||||||
|
!src/NadekoBot.Generators/**
|
||||||
|
# Use Ayu stuff
|
||||||
|
!src/ayu/**
|
||||||
!docker-entrypoint.sh
|
!docker-entrypoint.sh
|
||||||
|
|
||||||
# ignore bin and obj folders in projects
|
# ignore bin and obj folders in projects
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,7 +3,8 @@
|
|||||||
src/NadekoBot/data/last_known_version.txt
|
src/NadekoBot/data/last_known_version.txt
|
||||||
|
|
||||||
# medusa stuff
|
# medusa stuff
|
||||||
src/NadekoBot/data/medusae/
|
!src/NadekoBot/data/medusae/medusa.yml
|
||||||
|
src/NadekoBot/data/medusae/**
|
||||||
|
|
||||||
# other
|
# other
|
||||||
|
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
image: mcr.microsoft.com/dotnet/sdk:8.0
|
image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
- build-installer
|
|
||||||
- upload-builds
|
- upload-builds
|
||||||
- release
|
- release
|
||||||
|
- publish-windows
|
||||||
|
- upload-windows-updater-release
|
||||||
- publish-medusa-package
|
- publish-medusa-package
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
@@ -13,16 +14,8 @@ variables:
|
|||||||
tests: "NadekoBot.Tests"
|
tests: "NadekoBot.Tests"
|
||||||
LINUX_X64_OUTPUT_DIR: "nadekobot-linux-x64"
|
LINUX_X64_OUTPUT_DIR: "nadekobot-linux-x64"
|
||||||
LINUX_X64_RELEASE: "$CI_COMMIT_TAG-linux-x64-build.tar"
|
LINUX_X64_RELEASE: "$CI_COMMIT_TAG-linux-x64-build.tar"
|
||||||
LINUX_ARM64_OUTPUT_DIR: "nadekobot-linux-arm64"
|
|
||||||
LINUX_ARM64_RELEASE: "$CI_COMMIT_TAG-linux-arm64-build.tar"
|
|
||||||
MACOS_X64_OUTPUT_DIR: "nadekobot-osx-x64"
|
|
||||||
MACOS_X64_RELEASE: "$CI_COMMIT_TAG-osx-x64-build.tar"
|
|
||||||
MACOS_ARM64_OUTPUT_DIR: "nadekobot-osx-arm64"
|
|
||||||
MACOS_ARM64_RELEASE: "$CI_COMMIT_TAG-osx-arm64-build.tar"
|
|
||||||
WIN_X64_OUTPUT_DIR: "nadekobot-windows-x64"
|
WIN_X64_OUTPUT_DIR: "nadekobot-windows-x64"
|
||||||
WIN_X64_RELEASE: "$CI_COMMIT_TAG-windows-x64-build.zip"
|
WIN_X64_RELEASE: "$CI_COMMIT_TAG-windows-x64-build.zip"
|
||||||
WIN_ARM64_OUTPUT_DIR: "nadekobot-windows-arm64"
|
|
||||||
WIN_ARM64_RELEASE: "$CI_COMMIT_TAG-windows-arm64-build.zip"
|
|
||||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/NadekoBot-build/${CI_COMMIT_TAG}"
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/NadekoBot-build/${CI_COMMIT_TAG}"
|
||||||
INSTALLER_OUTPUT_DIR: "nadeko-installers/${CI_COMMIT_TAG}"
|
INSTALLER_OUTPUT_DIR: "nadeko-installers/${CI_COMMIT_TAG}"
|
||||||
INSTALLER_FILE_NAME: "nadeko-setup-${CI_COMMIT_TAG}.exe"
|
INSTALLER_FILE_NAME: "nadeko-setup-${CI_COMMIT_TAG}.exe"
|
||||||
@@ -30,25 +23,12 @@ variables:
|
|||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- |
|
- "dotnet publish -c Release -r linux-x64 --self-contained -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
VERSION_STRING=""
|
- "dotnet publish -c Release -r win7-x64 --self-contained -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
||||||
if [ -n "$CI_COMMIT_TAG" ]; then
|
|
||||||
VERSION_STRING="-p:Version=$CI_COMMIT_TAG"
|
|
||||||
fi
|
|
||||||
- "dotnet publish -c Release -r linux-x64 --self-contained $VERSION_STRING -o $LINUX_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
|
||||||
- "dotnet publish -c Release -r linux-arm64 --self-contained $VERSION_STRING -o $LINUX_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
|
||||||
- "dotnet publish -c Release -r win-x64 --self-contained $VERSION_STRING -o $WIN_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
|
||||||
- "dotnet publish -c Release -r win-arm64 --self-contained $VERSION_STRING -o $WIN_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
|
||||||
- "dotnet publish -c Release -r osx-x64 --self-contained $VERSION_STRING -o $MACOS_X64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
|
||||||
- "dotnet publish -c Release -r osx-arm64 --self-contained $VERSION_STRING -o $MACOS_ARM64_OUTPUT_DIR src/NadekoBot/NadekoBot.csproj"
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "$LINUX_X64_OUTPUT_DIR/"
|
- "$LINUX_X64_OUTPUT_DIR/"
|
||||||
- "$LINUX_ARM64_OUTPUT_DIR/"
|
|
||||||
- "$WIN_X64_OUTPUT_DIR/"
|
- "$WIN_X64_OUTPUT_DIR/"
|
||||||
- "$WIN_ARM64_OUTPUT_DIR/"
|
|
||||||
- "$MACOS_X64_OUTPUT_DIR/"
|
|
||||||
- "$MACOS_ARM64_OUTPUT_DIR/"
|
|
||||||
|
|
||||||
upload-builds:
|
upload-builds:
|
||||||
stage: upload-builds
|
stage: upload-builds
|
||||||
@@ -58,26 +38,11 @@ upload-builds:
|
|||||||
script:
|
script:
|
||||||
- apk add --no-cache curl tar zip
|
- apk add --no-cache curl tar zip
|
||||||
- "tar cvf $LINUX_X64_RELEASE $LINUX_X64_OUTPUT_DIR/*"
|
- "tar cvf $LINUX_X64_RELEASE $LINUX_X64_OUTPUT_DIR/*"
|
||||||
- "tar cvf $LINUX_ARM64_RELEASE $LINUX_ARM64_OUTPUT_DIR/*"
|
|
||||||
- "tar cvf $MACOS_X64_RELEASE $MACOS_X64_OUTPUT_DIR/*"
|
|
||||||
- "tar cvf $MACOS_ARM64_RELEASE $MACOS_ARM64_OUTPUT_DIR/*"
|
|
||||||
- "zip -r $WIN_X64_RELEASE $WIN_X64_OUTPUT_DIR/*"
|
- "zip -r $WIN_X64_RELEASE $WIN_X64_OUTPUT_DIR/*"
|
||||||
- "zip -r $WIN_ARM64_RELEASE $WIN_ARM64_OUTPUT_DIR/*"
|
|
||||||
- "mv $INSTALLER_OUTPUT_DIR/$INSTALLER_FILE_NAME $INSTALLER_FILE_NAME"
|
|
||||||
- |
|
- |
|
||||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_X64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_X64_RELEASE
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_X64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_X64_RELEASE
|
||||||
- |
|
|
||||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $LINUX_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$LINUX_ARM64_RELEASE
|
|
||||||
- |
|
- |
|
||||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_X64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_X64_RELEASE
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_X64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_X64_RELEASE
|
||||||
- |
|
|
||||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $WIN_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_ARM64_RELEASE
|
|
||||||
- |
|
|
||||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $MACOS_X64_RELEASE $PACKAGE_REGISTRY_URL/$MACOS_X64_RELEASE
|
|
||||||
- |
|
|
||||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $MACOS_ARM64_RELEASE $PACKAGE_REGISTRY_URL/$MACOS_ARM64_RELEASE
|
|
||||||
- |
|
|
||||||
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file $INSTALLER_FILE_NAME $PACKAGE_REGISTRY_URL/$INSTALLER_FILE_NAME
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@@ -86,14 +51,9 @@ release:
|
|||||||
- if: $CI_COMMIT_TAG
|
- if: $CI_COMMIT_TAG
|
||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/kwoth/nadekobot/-/blob/v5/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \
|
release-cli create --name "NadekoBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/Kwoth/nadekobot/-/blob/v4/CHANGELOG.md#$(echo "$CI_COMMIT_TAG" | sed "s/\.//g")-$(date +%d%m%Y))" --tag-name $CI_COMMIT_TAG \
|
||||||
--assets-link "{\"name\":\"${LINUX_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_RELEASE}\"}" \
|
--assets-link "{\"name\":\"${LINUX_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_X64_RELEASE}\"}" \
|
||||||
--assets-link "{\"name\":\"${LINUX_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${LINUX_ARM64_RELEASE}\"}" \
|
--assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}"
|
||||||
--assets-link "{\"name\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}" \
|
|
||||||
--assets-link "{\"name\":\"${WIN_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_ARM64_RELEASE}\"}" \
|
|
||||||
--assets-link "{\"name\":\"${MACOS_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${MACOS_X64_RELEASE}\"}" \
|
|
||||||
--assets-link "{\"name\":\"${MACOS_ARM64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${MACOS_ARM64_RELEASE}\"}" \
|
|
||||||
--assets-link "{\"name\":\"${INSTALLER_FILE_NAME}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${INSTALLER_FILE_NAME}\"}"
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
@@ -103,14 +63,14 @@ test:
|
|||||||
- "cd $tests_path"
|
- "cd $tests_path"
|
||||||
- "dotnet test"
|
- "dotnet test"
|
||||||
|
|
||||||
build-installer:
|
publish-windows:
|
||||||
stage: build-installer
|
stage: publish-windows
|
||||||
rules:
|
rules:
|
||||||
- if: "$CI_COMMIT_TAG"
|
- if: "$CI_COMMIT_TAG"
|
||||||
image: scottyhardy/docker-wine
|
image: scottyhardy/docker-wine
|
||||||
before_script:
|
before_script:
|
||||||
- choco install dotnet-runtime --version=8.0.4 -y
|
- choco install dotnet-6.0-runtime --version=6.0.4 -y
|
||||||
- choco install dotnet-sdk --version=8.0.204 -y
|
- choco install dotnet-6.0-sdk --version=6.0.202 -y
|
||||||
- choco install innosetup -y
|
- choco install innosetup -y
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
@@ -118,22 +78,33 @@ build-installer:
|
|||||||
script:
|
script:
|
||||||
- dotnet clean
|
- dotnet clean
|
||||||
- dotnet restore -f --no-cache -v n
|
- dotnet restore -f --no-cache -v n
|
||||||
- dotnet publish -c Release --self-contained --runtime win-x64 /p:Version=$CI_COMMIT_TAG src/NadekoBot
|
- dotnet publish -c Release --runtime win7-x64 /p:Version=$CI_COMMIT_TAG src/NadekoBot
|
||||||
- $env:NADEKOBOT_INSTALL_VERSION = $CI_COMMIT_TAG
|
- $env:NADEKOBOT_INSTALL_VERSION = $CI_COMMIT_TAG
|
||||||
- iscc.exe "/O+" ".\exe_builder.iss"
|
- iscc.exe "/O+" ".\exe_builder.iss"
|
||||||
tags:
|
tags:
|
||||||
- saas-windows-medium-amd64
|
- windows
|
||||||
|
|
||||||
|
upload-windows-updater-release:
|
||||||
|
stage: upload-windows-updater-release
|
||||||
|
rules:
|
||||||
|
- if: "$CI_COMMIT_TAG"
|
||||||
|
image:
|
||||||
|
name: amazon/aws-cli
|
||||||
|
entrypoint: [""]
|
||||||
|
script:
|
||||||
|
- sed -i "s/_INSTALLER_FILE_NAME_/$INSTALLER_FILE_NAME/g" releases-v3.json
|
||||||
|
- sed -i "s/_VERSION_/$CI_COMMIT_TAG/g" releases-v3.json
|
||||||
|
- aws --version
|
||||||
|
- aws --endpoint-url $AWS_SERVICE_URL s3api put-object --bucket "$AWS_BUCKET_NAME" --key "dl/bot/$INSTALLER_FILE_NAME" --acl public-read --body "$INSTALLER_OUTPUT_DIR/$INSTALLER_FILE_NAME"
|
||||||
|
- aws --endpoint-url $AWS_SERVICE_URL s3api put-object --bucket "$AWS_BUCKET_NAME" --key "dl/bot/releases-v3.json" --acl public-read --body "releases-v3.json"
|
||||||
|
|
||||||
publish-medusa-package:
|
publish-medusa-package:
|
||||||
stage: publish-medusa-package
|
stage: publish-medusa-package
|
||||||
allow_failure: true
|
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
||||||
when: never
|
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG
|
||||||
script:
|
script:
|
||||||
- LAST_TAG=$(git describe --tags --abbrev=0)
|
- LAST_TAG=$(git describe --tags --abbrev=0)
|
||||||
- if [ $CI_COMMIT_TAG ];then MEDUSA_VERSION="$CI_COMMIT_TAG"; else MEDUSA_VERSION="$LAST_TAG-alpha$CI_COMMIT_SHORT_SHA"; fi
|
- if [ $CI_COMMIT_TAG ];then MEDUSA_VERSION="$CI_COMMIT_TAG"; else MEDUSA_VERSION="$LAST_TAG-$CI_COMMIT_SHA"; fi
|
||||||
- cd src/Nadeko.Medusa/
|
- cd src/Nadeko.Medusa/
|
||||||
- dotnet pack -c Release /p:Version=$MEDUSA_VERSION -o bin/Release/packed
|
- dotnet pack -c Release /p:Version=$MEDUSA_VERSION -o bin/Release/packed
|
||||||
- dotnet nuget push bin/Release/packed/ --source https://www.myget.org/F/nadeko/api/v2/package --api-key "$MYGET_API_KEY"
|
- dotnet nuget push bin/Release/packed/ --source https://www.myget.org/F/nadeko/api/v2/package --api-key "$MYGET_API_KEY"
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
# Read the Docs configuration file for MkDocs projects
|
|
||||||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
||||||
|
|
||||||
# Required
|
|
||||||
version: 2
|
|
||||||
|
|
||||||
# Set the version of Python and other tools you might need
|
|
||||||
build:
|
|
||||||
os: ubuntu-22.04
|
|
||||||
tools:
|
|
||||||
python: "3.12"
|
|
||||||
|
|
||||||
mkdocs:
|
|
||||||
configuration: mkdocs.yml
|
|
||||||
|
|
||||||
# Optionally declare the Python requirements required to build your docs
|
|
||||||
python:
|
|
||||||
install:
|
|
||||||
- requirements: mkdocs-requirements.txt
|
|
943
CHANGELOG.md
943
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
34
Dockerfile
34
Dockerfile
@@ -1,24 +1,18 @@
|
|||||||
# Use the .NET 8.0 SDK as the base image for the build stage
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
|
|
||||||
# Copy the .csproj files for each project
|
|
||||||
COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/
|
COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/
|
||||||
|
COPY src/Nadeko.Econ/*.csproj src/Nadeko.Econ/
|
||||||
|
COPY src/Nadeko.Common/*.csproj src/Nadeko.Common/
|
||||||
COPY src/NadekoBot/*.csproj src/NadekoBot/
|
COPY src/NadekoBot/*.csproj src/NadekoBot/
|
||||||
COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/
|
COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/
|
||||||
COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/
|
COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/
|
||||||
COPY src/NadekoBot.Voice/*.csproj src/NadekoBot.Voice/
|
COPY src/ayu/Ayu.Discord.Voice/*.csproj src/ayu/Ayu.Discord.Voice/
|
||||||
|
COPY NuGet.Config ./
|
||||||
# Restore the dependencies for the NadekoBot project
|
|
||||||
RUN dotnet restore src/NadekoBot/
|
RUN dotnet restore src/NadekoBot/
|
||||||
|
|
||||||
# Copy the rest of the source code
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Set the working directory to the NadekoBot project
|
|
||||||
WORKDIR /source/src/NadekoBot
|
WORKDIR /source/src/NadekoBot
|
||||||
|
|
||||||
# Build and publish the NadekoBot project, then clean up unnecessary files
|
|
||||||
RUN set -xe; \
|
RUN set -xe; \
|
||||||
dotnet --version; \
|
dotnet --version; \
|
||||||
dotnet publish -c Release -o /app --no-restore; \
|
dotnet publish -c Release -o /app --no-restore; \
|
||||||
@@ -27,33 +21,29 @@ RUN set -xe; \
|
|||||||
find /app -type f -exec chmod -x {} \; ;\
|
find /app -type f -exec chmod -x {} \; ;\
|
||||||
chmod +x /app/NadekoBot
|
chmod +x /app/NadekoBot
|
||||||
|
|
||||||
# Use the .NET 8.0 runtime as the base image for the final stage
|
# final stage/image
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
FROM mcr.microsoft.com/dotnet/runtime:6.0
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Create a new user, install dependencies, and set up sudoers file
|
|
||||||
RUN set -xe; \
|
RUN set -xe; \
|
||||||
useradd -m nadeko; \
|
useradd -m nadeko; \
|
||||||
apt-get update; \
|
apt-get update; \
|
||||||
apt-get install -y --no-install-recommends libsqlite3-0 curl ffmpeg sudo python3; \
|
apt-get install -y --no-install-recommends libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 python3-pip sudo; \
|
||||||
|
update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1; \
|
||||||
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
echo 'Defaults>nadeko env_keep+="ASPNETCORE_* DOTNET_* NadekoBot_* shard_id total_shards TZ"' > /etc/sudoers.d/nadeko; \
|
||||||
curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \
|
pip3 install --no-cache-dir --upgrade youtube-dl; \
|
||||||
chmod a+rx /usr/local/bin/yt-dlp; \
|
apt-get purge -y python3-pip; \
|
||||||
|
chmod +x /usr/local/bin/youtube-dl; \
|
||||||
apt-get autoremove -y; \
|
apt-get autoremove -y; \
|
||||||
apt-get autoclean -y
|
apt-get autoclean -y
|
||||||
|
|
||||||
# Copy the built application and the entrypoint script from the build stage
|
|
||||||
COPY --from=build /app ./
|
COPY --from=build /app ./
|
||||||
COPY docker-entrypoint.sh /usr/local/sbin
|
COPY docker-entrypoint.sh /usr/local/sbin
|
||||||
|
|
||||||
# Set environment variables
|
|
||||||
ENV shard_id=0
|
ENV shard_id=0
|
||||||
ENV total_shards=1
|
ENV total_shards=1
|
||||||
ENV NadekoBot__creds=/app/data/creds.yml
|
ENV NadekoBot__creds=/app/data/creds.yml
|
||||||
|
|
||||||
# Define the data directory as a volume
|
|
||||||
VOLUME [ "/app/data" ]
|
VOLUME [ "/app/data" ]
|
||||||
|
|
||||||
# Set the entrypoint and default command
|
|
||||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||||
CMD dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
CMD dotnet NadekoBot.dll "$shard_id" "$total_shards"
|
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2023 Kwoth
|
Copyright 2021 Kwoth
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
|
@@ -12,25 +12,28 @@ ProjectSection(SolutionItems) = preProject
|
|||||||
README.md = README.md
|
README.md = README.md
|
||||||
.gitlab-ci.yml = .gitlab-ci.yml
|
.gitlab-ci.yml = .gitlab-ci.yml
|
||||||
Dockerfile = Dockerfile
|
Dockerfile = Dockerfile
|
||||||
migrate.ps1 = migrate.ps1
|
NuGet.Config = NuGet.Config
|
||||||
remove-migration.ps1 = remove-migration.ps1
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NadekoBot", "src\NadekoBot\NadekoBot.csproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NadekoBot", "src\NadekoBot\NadekoBot.csproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Voice", "src\NadekoBot.Voice\NadekoBot.Voice.csproj", "{2F4CF6D6-0C2F-4944-B204-9508CDA53195}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ayu", "ayu", "{6058FEDF-A318-4CD4-8F04-A7E8E7EC8874}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ayu.Discord.Voice", "src\ayu\Ayu.Discord.Voice\Ayu.Discord.Voice.csproj", "{2F4CF6D6-0C2F-4944-B204-9508CDA53195}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Tests", "src\NadekoBot.Tests\NadekoBot.Tests.csproj", "{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Tests", "src\NadekoBot.Tests\NadekoBot.Tests.csproj", "{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Coordinator", "src\NadekoBot.Coordinator\NadekoBot.Coordinator.csproj", "{AE9B7F8C-81D7-4401-83A3-643B38258374}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Coordinator", "src\NadekoBot.Coordinator\NadekoBot.Coordinator.csproj", "{AE9B7F8C-81D7-4401-83A3-643B38258374}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Generators", "src\NadekoBot.Generators\NadekoBot.Generators.csproj", "{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}"
|
||||||
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.VotesApi", "src\NadekoBot.VotesApi\NadekoBot.VotesApi.csproj", "{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.VotesApi", "src\NadekoBot.VotesApi\NadekoBot.VotesApi.csproj", "{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Medusa", "src\Nadeko.Medusa\Nadeko.Medusa.csproj", "{E685977E-31A4-46F4-A5D7-4E3E39E82E43}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Medusa", "src\Nadeko.Medusa\Nadeko.Medusa.csproj", "{E685977E-31A4-46F4-A5D7-4E3E39E82E43}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.Generators", "src\NadekoBot.Generators\NadekoBot.Generators.csproj", "{92770AF3-83EE-49F1-A0BB-79124D19A13D}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Common", "src\Nadeko.Common\Nadeko.Common.csproj", "{A6022F5F-A764-4D3F-847B-36F0391FF659}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NadekoBot.GrpcApiBase", "src\NadekoBot.GrpcApiBase\NadekoBot.GrpcApiBase.csproj", "{FB74B9EA-10B9-4542-ACB1-35523A95A587}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Econ", "src\Nadeko.Econ\Nadeko.Econ.csproj", "{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -63,6 +66,12 @@ Global
|
|||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{AE9B7F8C-81D7-4401-83A3-643B38258374}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Release|Any CPU.Build.0 = Release|Any CPU
|
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
@@ -75,31 +84,33 @@ Global
|
|||||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{A6022F5F-A764-4D3F-847B-36F0391FF659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A6022F5F-A764-4D3F-847B-36F0391FF659}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
{A6022F5F-A764-4D3F-847B-36F0391FF659}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{A6022F5F-A764-4D3F-847B-36F0391FF659}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A6022F5F-A764-4D3F-847B-36F0391FF659}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A6022F5F-A764-4D3F-847B-36F0391FF659}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{45EC1473-C678-4857-A544-07DFE0D0B478} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{6058FEDF-A318-4CD4-8F04-A7E8E7EC8874} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195} = {6058FEDF-A318-4CD4-8F04-A7E8E7EC8874}
|
||||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{AE9B7F8C-81D7-4401-83A3-643B38258374} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{E685977E-31A4-46F4-A5D7-4E3E39E82E43} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{92770AF3-83EE-49F1-A0BB-79124D19A13D} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{A6022F5F-A764-4D3F-847B-36F0391FF659} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{4F4FBF7C-74F0-4AE4-B451-9E60BDCA9C37} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{FB74B9EA-10B9-4542-ACB1-35523A95A587} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}
|
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}
|
||||||
|
6
NuGet.Config
Normal file
6
NuGet.Config
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
|
<add key="nadeko.bot" value="https://www.myget.org/F/nadeko/api/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
@@ -1,3 +1,8 @@
|
|||||||
|
[](https://discord.gg/nadekobot)
|
||||||
|
[](http://nadekobot.readthedocs.io/en/v4/?badge=v4)
|
||||||
|
[](https://top.gg/bot/116275390695079945)
|
||||||
|
|
||||||
|
|
||||||
[](https://nadeko.bot/)
|
[](https://nadeko.bot/)
|
||||||
|
|
||||||
[](https://invite.nadeko.bot/)
|
[](https://invite.nadeko.bot/)
|
||||||
@@ -5,5 +10,5 @@
|
|||||||
[](https://nadeko.bot/commands)
|
[](https://nadeko.bot/commands)
|
||||||
|
|
||||||
### Useful links
|
### Useful links
|
||||||
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/latest)
|
- [Self hosting Guides and Docs](https://nadekobot.readthedocs.io/en/v4)
|
||||||
- [Discord support server](https://discord.nadeko.bot)
|
- [Discord support server](https://discord.nadeko.bot)
|
||||||
|
@@ -24,10 +24,6 @@ The list below is not complete. Use commands above to see up-to-date list for yo
|
|||||||
|
|
||||||
`trivia.min_win_req` - Restricts a user's ability to make a trivia game with a win requirement less than the set value.
|
`trivia.min_win_req` - Restricts a user's ability to make a trivia game with a win requirement less than the set value.
|
||||||
`trivia.currency_reward` - Sets the amount of currency a user will win if they place first in a completed trivia game.
|
`trivia.currency_reward` - Sets the amount of currency a user will win if they place first in a completed trivia game.
|
||||||
`hangman.currency_reward` - Sets the amount of currency a user will win if they win a game of hangman.
|
|
||||||
`chatbot` - Sets which chatbot API the bot should use, values: `gpt3`, `cleverbot`.
|
|
||||||
`gpt.model` - Sets which GPT-3 model the bot should use, values: `ada001`, `babbage001`, `curie001`, `davinci003`.
|
|
||||||
`gpt.max_tokens` - Sets the limit of tokens GPT-3 can use per call. Find out more about tokens [here](https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them).
|
|
||||||
|
|
||||||
*more settings may be available in `data/games.yml` file*
|
*more settings may be available in `data/games.yml` file*
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# How to contribute
|
# How to contribute
|
||||||
|
|
||||||
1. Make Merge Requests to the [**v5 branch**](https://gitlab.com/kwoth/nadekobot/tree/v5)
|
1. Make Merge Requests to the [**v4 branch**](https://gitlab.com/Kwoth/nadekobot/tree/v4)
|
||||||
2. Keep a single Merge Request to a single feature
|
2. Keep a single Merge Request to a single feature
|
||||||
3. Fill out the MR template
|
3. Fill out the MR template
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ You can also donate to us through [PayPal][paypal] for one-time donations using
|
|||||||
|
|
||||||
[![img][paypal-button]][paypal]
|
[![img][paypal-button]][paypal]
|
||||||
|
|
||||||
[gitlab]: https://gitlab.com/kwoth/nadekobot
|
[gitlab]: https://gitlab.com/Kwoth/nadekobot
|
||||||
[discord-server]: https://discord.nadeko.bot/
|
[discord-server]: https://discord.nadeko.bot/
|
||||||
[patreon]: https://www.patreon.com/nadekobot
|
[patreon]: https://www.patreon.com/nadekobot
|
||||||
[patreon-button]: ./assets/patreon.png
|
[patreon-button]: ./assets/patreon.png
|
||||||
|
@@ -1,76 +1,46 @@
|
|||||||
# Deploying NadekoBot with Docker: A Comprehensive Guide
|
# Setting up NadekoBot with Docker
|
||||||
|
|
||||||
## Getting Started
|
# WORK IN PROGRESS
|
||||||
|
|
||||||
Ensure Docker and Docker Compose are installed on your system. If not, follow the official Docker guides for your specific operating system:
|
### Installation
|
||||||
|
|
||||||
- [Docker Installation Guide](https://docs.docker.com/engine/install/)
|
|
||||||
- [Docker Compose Installation Guide](https://docs.docker.com/compose/install/)
|
|
||||||
|
|
||||||
## Step-by-Step Installation
|
|
||||||
|
|
||||||
1. **Choose Your Workspace:** Select a directory where you'll set up your NadekoBot stack. Use your terminal to navigate to this directory. For the purpose of this guide, we'll use `/opt/stacks/nadekobot/` as an example, but you can choose any directory that suits your needs.
|
|
||||||
|
|
||||||
2. **Create a Docker Compose File:** In this directory, create a Docker Compose file named `docker-compose.yml`. You can use any text editor for this task. For instance, to use the `nano` editor, type `nano docker-compose.yml`.
|
|
||||||
|
|
||||||
3. **Configure Your Docker Compose File:** Populate your Docker Compose file with the following configuration:
|
|
||||||
|
|
||||||
|
1. Create a `/srv/nadeko` folder
|
||||||
|
- `mkdir -p /srv/nadeko`
|
||||||
|
2. Create a `docker-compose.yml`
|
||||||
|
- nano `docker-compose.yml`
|
||||||
|
- copy the following contents into it:
|
||||||
|
##### docker-compose.yml
|
||||||
```yml
|
```yml
|
||||||
|
version: "3.7"
|
||||||
services:
|
services:
|
||||||
nadeko:
|
nadeko:
|
||||||
image: registry.gitlab.com/kwoth/nadekobot:latest
|
image: registry.gitlab.com/kwoth/nadekobot:latest
|
||||||
container_name: nadeko
|
depends_on:
|
||||||
restart: unless-stopped
|
- redis
|
||||||
environment:
|
environment:
|
||||||
TZ: Europe/Rome
|
TZ: Europe/Paris
|
||||||
|
NadekoBot_RedisOptions: redis,name=nadeko
|
||||||
|
#NadekoBot_ShardRunCommand: dotnet
|
||||||
|
#NadekoBot_ShardRunArguments: /app/NadekoBot.dll {0} {1}
|
||||||
volumes:
|
volumes:
|
||||||
- /opt/stacks/nadekobot/conf/creds.yml:/app/data/creds.yml
|
- /srv/nadeko/conf/creds.yml:/app/creds.yml:ro
|
||||||
- /opt/stacks/nadekobot/data:/app/data
|
- /srv/nadeko/data:/app/data
|
||||||
networks: {}
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Prepare Your Credentials File:** Before running Docker Compose, ensure the `creds.yml` file exists in the `/opt/stacks/nadekobot/conf/` directory. If it's missing, create it using `touch /opt/stacks/nadekobot/conf/creds.yml`. You may need to use `sudo`. Remember to replace `/opt/stacks/nadekobot/` with your chosen directory.
|
redis:
|
||||||
|
image: redis:4-alpine
|
||||||
5. **Edit Your Credentials File:** Populate the `creds.yml` file in `/opt/stacks/nadekobot/conf/creds.yml` with your bot's credentials. You can use any text editor for this task. For instance, to use the `nano` editor, type `nano /opt/stacks/nadekobot/conf/creds.yml`. You may need to use `sudo`. Again, replace `/opt/stacks/nadekobot/` with your chosen directory.
|
sysctls:
|
||||||
|
- net.core.somaxconn=511
|
||||||
6. **Launch Your Bot:** Now, you're ready to run Docker Compose. Use the following command: `docker-compose up -d`.
|
command: redis-server --maxmemory 32M --maxmemory-policy volatile-lru
|
||||||
|
|
||||||
## Keeping Your Bot Up-to-Date
|
|
||||||
|
|
||||||
There are two methods to update your NadekoBot:
|
|
||||||
|
|
||||||
### Manual Update
|
|
||||||
|
|
||||||
1. **Navigate to Your Directory:** Use `cd /path/to/your/directory` to go to the directory containing your Docker Compose file.
|
|
||||||
|
|
||||||
2. **Pull the Latest Images:** Use `docker-compose pull` to fetch the latest images.
|
|
||||||
|
|
||||||
3. **Restart Your Containers:** Use `docker-compose up -d` to restart the containers.
|
|
||||||
|
|
||||||
### Automatic Update with Watchtower
|
|
||||||
|
|
||||||
If you prefer an automated update process, consider using Watchtower. Watchtower automatically updates your Docker containers to the latest versions.
|
|
||||||
|
|
||||||
To use Watchtower with NadekoBot, you need to add a specific label to the service in your Docker Compose file. Here's how your Docker Compose file should look:
|
|
||||||
|
|
||||||
```yml
|
|
||||||
services:
|
|
||||||
nadeko:
|
|
||||||
image: registry.gitlab.com/kwoth/nadekobot:latest
|
|
||||||
container_name: nadeko
|
|
||||||
restart: unless-stopped
|
|
||||||
labels:
|
|
||||||
- com.centurylinklabs.watchtower.enable=true
|
|
||||||
environment:
|
|
||||||
TZ: Europe/Rome
|
|
||||||
volumes:
|
volumes:
|
||||||
- /opt/stacks/nadekobot/conf/creds.yml:/app/data/creds.yml
|
- /srv/nadeko/redis-data:/data
|
||||||
- /opt/stacks/nadekobot/data:/app/data
|
|
||||||
networks: {}
|
|
||||||
```
|
```
|
||||||
|
3. Save your file and run docker compose
|
||||||
|
- `docker-compose up`
|
||||||
|
4. Edit creds in `/srv/nadeko/conf/creds.yml`
|
||||||
|
5. Run it again with
|
||||||
|
- `docker-compose up`
|
||||||
|
|
||||||
Remember to replace `/opt/stacks/nadekobot/` with your chosen directory in the Docker Compose file.
|
### Updating
|
||||||
|
- `cd /srv/nadeko`
|
||||||
To install and run Watchtower, follow the guide provided by Containrrr:
|
- `docker-compose pull`
|
||||||
|
- `docker-compose up -d`
|
||||||
- [Watchtower Installation and Usage Guide](https://containrrr.dev/watchtower/)
|
|
||||||
|
@@ -13,23 +13,24 @@
|
|||||||
|
|
||||||
#### Operating System Compatibility
|
#### Operating System Compatibility
|
||||||
|
|
||||||
|
It is recommended that you use **Ubuntu 20.04**, as there have been nearly no problems with it. Also, **32-bit systems are incompatible**.
|
||||||
|
|
||||||
##### Compatible operating systems:
|
##### Compatible operating systems:
|
||||||
|
|
||||||
- Ubuntu: 20.04, 22.04, 24.04
|
- Ubuntu: 16.04, 18.04, 20.04, 21.04, 21.10 22.04
|
||||||
- Mint: 19, 20, 21
|
- Mint: 19, 20
|
||||||
- Debian: 10, 11, 12
|
- Debian: 9, 10
|
||||||
- RockyLinux: 8, 9
|
- CentOS: 7
|
||||||
- AlmaLinux: 8, 9
|
- openSUSE
|
||||||
- openSUSE Leap: 15.5, 15.6 & Tumbleweed
|
- Fedora: 33, 34, 35
|
||||||
- Fedora: 38, 39, 40, 41, 42
|
|
||||||
|
|
||||||
## Linux From Source
|
## Linux From Source
|
||||||
|
|
||||||
##### Migration from v3 -> v5
|
##### Migration from v3 -> v4
|
||||||
|
|
||||||
Follow the following few steps only if you're migrating from v3. If not, skip to installation instructions.
|
Follow the following few steps only if you're migrating from v3. If not, skip to installation instructions.
|
||||||
|
|
||||||
Use the new installer script: `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
Use the new installer script: `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
> - Install prerequisites (type `1` and press `enter`)
|
> - Install prerequisites (type `1` and press `enter`)
|
||||||
> - Download (type `2` and press `enter`)
|
> - Download (type `2` and press `enter`)
|
||||||
> - Run (type `3` and press `enter`)
|
> - Run (type `3` and press `enter`)
|
||||||
@@ -39,7 +40,7 @@ Use the new installer script: `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-
|
|||||||
|
|
||||||
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
|
Open Terminal (if you're on an installation with a window manager) and navigate to the location where you want to install the bot (for example `cd ~`)
|
||||||
|
|
||||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
2. Install prerequisites (type `1` and press enter)
|
2. Install prerequisites (type `1` and press enter)
|
||||||
3. Download the bot (type `2` and press enter)
|
3. Download the bot (type `2` and press enter)
|
||||||
4. Exit the installer (type `6` and press enter)
|
4. Exit the installer (type `6` and press enter)
|
||||||
@@ -51,13 +52,13 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
|||||||
- `CTRL` + `X`
|
- `CTRL` + `X`
|
||||||
- `Y`
|
- `Y`
|
||||||
- `Enter`
|
- `Enter`
|
||||||
8. Run the installer script again `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
8. Run the installer script again `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
9. Run the bot (type `3` and press enter)
|
9. Run the bot (type `3` and press enter)
|
||||||
|
|
||||||
##### Source Update Instructions
|
##### Source Update Instructions
|
||||||
|
|
||||||
1. ⚠ Stop the bot ⚠
|
1. ⚠ Stop the bot ⚠
|
||||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
3. Update the bot (type `2` and press enter)
|
3. Update the bot (type `2` and press enter)
|
||||||
4. Run the bot (type `3` and press enter)
|
4. Run the bot (type `3` and press enter)
|
||||||
5. 🎉
|
5. 🎉
|
||||||
@@ -70,16 +71,16 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
|||||||
|
|
||||||
1. (Optional) Installing Redis
|
1. (Optional) Installing Redis
|
||||||
- ubuntu installation command: `sudo apt-get install redis-server`
|
- ubuntu installation command: `sudo apt-get install redis-server`
|
||||||
2. Playing music requires `ffmpeg`, `libopus`, `libsodium` and `yt-dlp` (which in turn requires python3)
|
2. Playing music requires `ffmpeg`, `libopus`, `libsodium` and `youtube-dl` (which in turn requires python3)
|
||||||
- Ubuntu installation command: `sudo apt-get install ffmpeg libopus0 opus-tools libopus-dev libsodium-dev -y`
|
- ubuntu installation command: `sudo apt-get install ffmpeg libopus0 opus-tools libopus-dev libsodium-dev -y`
|
||||||
- yt-dlp installation command: `sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp && sudo chmod a+rx /usr/local/bin/yt-dlp`
|
|
||||||
3. Make sure your python is version 3+ with `python --version`
|
3. Make sure your python is version 3+ with `python --version`
|
||||||
- if it's not, you can install python 3 and make it the default with: `sudo apt-get install python3.8 python-is-python3`
|
- if it's not, you can install python 3 and make it the default with: `sudo apt-get install python3.8 python-is-python3`
|
||||||
*You can use nadeko bash script [prerequisites installer](https://gitlab.com/kwoth/nadeko-bash-installer/-/blob/v5/n-prereq.sh) as a reference*
|
|
||||||
|
*You can use nadeko bash script [prerequisites installer](https://gitlab.com/Kwoth/nadeko-bash-installer/-/blob/v4/n-prereq.sh) as a reference*
|
||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
1. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
1. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||||
2. Untar it
|
2. Untar it
|
||||||
- ⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
- ⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
||||||
@@ -103,7 +104,7 @@ Open Terminal (if you're on an installation with a window manager) and navigate
|
|||||||
##### Release Update Instructions
|
##### Release Update Instructions
|
||||||
|
|
||||||
1. Stop the bot
|
1. Stop the bot
|
||||||
2. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
2. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "x.x.x-linux-x64-build.tar" (where `X.X.X` is a version, for example 3.0.4) and download it
|
- Look for the file called "x.x.x-linux-x64-build.tar" (where `X.X.X` is a version, for example 3.0.4) and download it
|
||||||
3. Untar it
|
3. Untar it
|
||||||
- ⚠ Make sure that you change `X.X.X` to the same series of numbers as in step 2!
|
- ⚠ Make sure that you change `X.X.X` to the same series of numbers as in step 2!
|
||||||
@@ -159,30 +160,15 @@ If you are presented with the installer main menu, exit it by choosing Option `8
|
|||||||
|
|
||||||
The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer, it's your session name)*.
|
The above command will create a new session named **nadeko** *(you can replace “nadeko” with anything you prefer, it's your session name)*.
|
||||||
|
|
||||||
2. Run the installer: `bash linuxAIO.sh`
|
2. Navigate to the project's root directory
|
||||||
|
- Project root directory location example: `cd /home/user/nadekobot/`
|
||||||
3. There are a few options when it comes to running Nadeko.
|
3. Enter the `output` directory:
|
||||||
|
- `cd output`
|
||||||
- Run `3` to *Run the bot normally*
|
4. Run the bot using:
|
||||||
- Run `4` to *Run the bot with Auto Restart* (This is may or may not work)
|
- `dotnet NadekoBot.dll`
|
||||||
|
5. Detatch the tmux session:
|
||||||
4. If option `4` was selected, you have the following options
|
|
||||||
```
|
|
||||||
1. Run Auto Restart normally without updating NadekoBot.
|
|
||||||
2. Run Auto Restart and update NadekoBot.
|
|
||||||
3. Exit
|
|
||||||
|
|
||||||
Choose:
|
|
||||||
[1] to Run NadekoBot with Auto Restart on "die" command without updating.
|
|
||||||
[2] to Run with Auto Updating on restart after using "die" command.
|
|
||||||
```
|
|
||||||
- Run `1` to restart the bot without updating. (This is done using the `.die` command)
|
|
||||||
- Run `2` to update the bot upon restart. (This is also done using the `.die` command)
|
|
||||||
|
|
||||||
5. That's it! to detatch the tmux session:
|
|
||||||
- Press `Ctrl` + `B`
|
- Press `Ctrl` + `B`
|
||||||
- Then press `D`
|
- Then press `D`
|
||||||
|
|
||||||
Now check your Discord server, the bot should be online. Nadeko should now be running in the background of your system.
|
Now check your Discord server, the bot should be online. Nadeko should now be running in the background of your system.
|
||||||
|
|
||||||
To re-open the tmux session to either update, restart, or whatever, execute `tmux a -t nadeko`. *(Make sure to replace "nadeko" with your session name. If you didn't change it, leave it as it.)*
|
To re-open the tmux session to either update, restart, or whatever, execute `tmux a -t nadeko`. *(Make sure to replace "nadeko" with your session name. If you didn't change it, leave it as it.)*
|
||||||
@@ -268,7 +254,7 @@ This method is similar to the one above, but requires one extra step, with the a
|
|||||||
echo '#!/bin/bash'
|
echo '#!/bin/bash'
|
||||||
echo ""
|
echo ""
|
||||||
echo "echo \"Running NadekoBot in the background with auto restart\"
|
echo "echo \"Running NadekoBot in the background with auto restart\"
|
||||||
yt-dlp -U
|
youtube-dl -U
|
||||||
|
|
||||||
# If you want Nadeko to be compiled prior to every startup, uncomment the lines
|
# If you want Nadeko to be compiled prior to every startup, uncomment the lines
|
||||||
# below. Note that it's not necessary unless you are personally modifying the
|
# below. Note that it's not necessary unless you are personally modifying the
|
||||||
@@ -300,7 +286,7 @@ This method is similar to the one above, but requires one extra step, with the a
|
|||||||
|
|
||||||
echo \"Waiting for 5 seconds...\"
|
echo \"Waiting for 5 seconds...\"
|
||||||
sleep 5
|
sleep 5
|
||||||
yt-dlp -U
|
youtube-dl -U
|
||||||
echo \"Restarting NadekoBot...\"
|
echo \"Restarting NadekoBot...\"
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -315,26 +301,6 @@ This method is similar to the one above, but requires one extra step, with the a
|
|||||||
|
|
||||||
If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (by using this link, you will get **$10 credit** and also support Nadeko)
|
If you want Nadeko to play music for you 24/7 without having to hosting it on your PC and want to keep it cheap, reliable and convenient as possible, you can try Nadeko on Linux Digital Ocean Droplet using the link [DigitalOcean](http://m.do.co/c/46b4d3d44795/) (by using this link, you will get **$10 credit** and also support Nadeko)
|
||||||
|
|
||||||
To set up the VPS, please select the options below
|
|
||||||
```
|
|
||||||
These are the min requirements you must follow:
|
|
||||||
|
|
||||||
OS: Any between Ubuntu, Fedora, and Debian
|
|
||||||
|
|
||||||
Plan: Basic
|
|
||||||
|
|
||||||
CPU options: regular with SSD
|
|
||||||
1 GB / 1 CPU
|
|
||||||
25 GB SSD Disk
|
|
||||||
1000 GB transfer
|
|
||||||
|
|
||||||
Note: You can select the cheapest option with 512 MB /1 CPU but this has been a hit or miss.
|
|
||||||
|
|
||||||
Datacenter region: Choose one depending on where you are located.
|
|
||||||
|
|
||||||
Authentication: Password or SSH
|
|
||||||
(Select SSH if you know what you are doing, otherwise choose password)
|
|
||||||
```
|
|
||||||
**Setting up NadekoBot**
|
**Setting up NadekoBot**
|
||||||
Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started.
|
Assuming you have followed the link above to setup an account and a Droplet with a 64-bit operational system on Digital Ocean and got the `IP address and root password (in your e-mail)` to login, it's time to get started.
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ Open Terminal (if you don't know how to, click on the magnifying glass on the to
|
|||||||
###### Homebrew/wget
|
###### Homebrew/wget
|
||||||
*Skip this step if you already have homebrew installed*
|
*Skip this step if you already have homebrew installed*
|
||||||
- Copy and paste this command, then press Enter:
|
- Copy and paste this command, then press Enter:
|
||||||
- `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
|
- `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
|
||||||
- Install wget
|
- Install wget
|
||||||
- `brew install wget`
|
- `brew install wget`
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
1. Download and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
2. Install prerequisites (type `1` and press enter)
|
2. Install prerequisites (type `1` and press enter)
|
||||||
3. Download the bot (type `2` and press enter)
|
3. Download the bot (type `2` and press enter)
|
||||||
4. Exit the installer in order to set up your `creds.yml`
|
4. Exit the installer in order to set up your `creds.yml`
|
||||||
@@ -49,7 +49,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
##### Update Instructions
|
##### Update Instructions
|
||||||
|
|
||||||
1. ⚠ Stop the bot
|
1. ⚠ Stop the bot
|
||||||
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/kwoth/nadeko-bash-installer/-/raw/v5/linuxAIO.sh && bash linuxAIO.sh`
|
2. Update and run the **new** installer script `cd ~ && wget -N https://gitlab.com/Kwoth/nadeko-bash-installer/-/raw/v4/linuxAIO.sh && bash linuxAIO.sh`
|
||||||
3. Update the bot (type `2` and press enter)
|
3. Update the bot (type `2` and press enter)
|
||||||
4. Run the bot (type `3` and press enter)
|
4. Run the bot (type `3` and press enter)
|
||||||
5. 🎉
|
5. 🎉
|
||||||
@@ -60,7 +60,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
1. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
1. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||||
2. Untar it
|
2. Untar it
|
||||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
||||||
@@ -84,7 +84,7 @@ sudo ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
|
|||||||
##### Update Instructions
|
##### Update Instructions
|
||||||
|
|
||||||
1. Stop the bot
|
1. Stop the bot
|
||||||
2. Download the latest release from <https://gitlab.com/kwoth/nadekobot/-/releases>
|
2. Download the latest release from <https://gitlab.com/Kwoth/nadekobot/-/releases>
|
||||||
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
- Look for the file called "X.XX.X-linux-x64-build.tar" (where X.XX.X is a series of numbers) and download it
|
||||||
3. Untar it
|
3. Untar it
|
||||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 2!
|
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 2!
|
||||||
|
@@ -10,9 +10,11 @@
|
|||||||
|
|
||||||
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source](#windows-from-source) guide instead.*
|
*Note: If you want to make changes to Nadeko's source code, please follow the [From Source](#windows-from-source) guide instead.*
|
||||||
|
|
||||||
|
*If you have Windows 7 or a 32-bit system, please refer to the [From Source](#windows-from-source)) guide.*
|
||||||
|
|
||||||
#### Prerequisites
|
#### Prerequisites
|
||||||
|
|
||||||
- Windows 10 or later (64-bit)
|
- Windows 8 or later (64-bit)
|
||||||
- [Create a Discord Bot application and invite the bot to your server](../creds-guide.md)
|
- [Create a Discord Bot application and invite the bot to your server](../creds-guide.md)
|
||||||
|
|
||||||
**Optional**
|
**Optional**
|
||||||
@@ -29,8 +31,10 @@
|
|||||||

|

|
||||||
- Click on **`DOWNLOAD`** at the lower right
|
- Click on **`DOWNLOAD`** at the lower right
|
||||||

|

|
||||||
- **Note: Redis is optional. install Redis manually here: [Redis] Download and run the **`.msi`** file.**
|
- Click on **`Install`** next to **`Redis`**.
|
||||||
- If you will use the music module, click on **`Install`** next to **`FFMPEG`** and **`Youtube-DLP`**.
|
- **(Note: Redis is optional unless you are are using the bot on 2000+ servers)**
|
||||||
|
- Note: If Redis fails to install, install Redis manually here: [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) Download and run the **`.msi`** file.
|
||||||
|
- If you will use the music module, click on **`Install`** next to **`FFMPEG`** and **`Youtube-DL`**.
|
||||||
- If any dependencies fail to install, you can temporarily disable your Windows Defender/AV until you install them. If you don't want to, then read [the last section of this guide](#Manual-Prerequisite-Installation).
|
- If any dependencies fail to install, you can temporarily disable your Windows Defender/AV until you install them. If you don't want to, then read [the last section of this guide](#Manual-Prerequisite-Installation).
|
||||||
- When installation is finished, click on **`CREDS`** to the left of **`RUN`** at the lower right.
|
- When installation is finished, click on **`CREDS`** to the left of **`RUN`** at the lower right.
|
||||||
- Follow the guide on how to [Set up the creds.yml](../../creds-guide) file.
|
- Follow the guide on how to [Set up the creds.yml](../../creds-guide) file.
|
||||||
@@ -56,9 +60,9 @@
|
|||||||
|
|
||||||
You can still install them manually:
|
You can still install them manually:
|
||||||
|
|
||||||
- [Redis] (OPTIONAL) - Download and run the **`.msi`** file
|
- [Redis Installer](https://github.com/MicrosoftArchive/redis/releases/tag/win-3.0.504) - Download and run the **`.msi`** file
|
||||||
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, then just move the `ffmpeg.exe` file to NadekoBot/system
|
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, then just move the `ffmpeg.exe` file to NadekoBot/system
|
||||||
- [youtube-dlp] - Click to download the `yt-dlp.exe` file then put `yt-dlp.exe` in a path that's in your PATH environment variable. If you don't know what that is, then just move the `yt-dlp.exe` file to NadekoBot/system
|
- [youtube-dl] - Click to download the file. Then put `youtube-dl.exe` in a path that's in your PATH environment variable. If you don't know what that is, then just move the `youtube-dl.exe` file to NadekoBot/system
|
||||||
|
|
||||||
## **⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
## **⚠ IF YOU ARE FOLLOWING THE GUIDE ABOVE, IGNORE THIS SECTION ⚠**
|
||||||
|
|
||||||
@@ -67,15 +71,15 @@ You can still install them manually:
|
|||||||
##### Prerequisites
|
##### Prerequisites
|
||||||
|
|
||||||
**Install these before proceeding or your bot will not work!**
|
**Install these before proceeding or your bot will not work!**
|
||||||
- [.net 8](https://dotnet.microsoft.com/en-us/download) - needed to compile and run the bot
|
- [.net 6](https://dotnet.microsoft.com/download/dotnet/6.0) - needed to compile and run the bot
|
||||||
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
- [git](https://git-scm.com/downloads) - needed to clone the repository (you can also download the zip manually and extract it, but this guide assumes you're using git)
|
||||||
- [Redis] (OPTIONAL)- to cache things needed by some features and persist through restarts
|
- [redis](https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi) - to cache things needed by some features and persist through restarts
|
||||||
|
|
||||||
##### Installation Instructions
|
##### Installation Instructions
|
||||||
|
|
||||||
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
Open PowerShell (press windows button on your keyboard and type powershell, it should show up; alternatively, right click the start menu and select Windows PowerShell), and navigate to the location where you want to install the bot (for example `cd ~/Desktop/`)
|
||||||
|
|
||||||
1. `git clone https://gitlab.com/kwoth/nadekobot -b v5 --depth 1`
|
1. `git clone https://gitlab.com/kwoth/nadekobot -b v4 --depth 1`
|
||||||
2. `cd nadekobot`
|
2. `cd nadekobot`
|
||||||
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
|
3. `dotnet publish -c Release -o output/ src/NadekoBot/`
|
||||||
4. `cd output`
|
4. `cd output`
|
||||||
@@ -93,11 +97,7 @@ Open PowerShell as described above and run the following commands:
|
|||||||
- ⚠️ Make sure you don't have your database, credentials or any other nadekobot folder open in some application, this might prevent some of the steps from executing succesfully
|
- ⚠️ Make sure you don't have your database, credentials or any other nadekobot folder open in some application, this might prevent some of the steps from executing succesfully
|
||||||
2. Navigate to your bot's folder, example:
|
2. Navigate to your bot's folder, example:
|
||||||
- `cd ~/Desktop/nadekobot`
|
- `cd ~/Desktop/nadekobot`
|
||||||
3. Pull the new version, and make sure you're on the v5 branch
|
3. Pull the new version
|
||||||
- *⚠️ the first 3 lines can be omitted if you're already on v5. If you're updating from v4, you must run them*
|
|
||||||
- `git remote set-branches origin '*'`
|
|
||||||
- `git fetch -v --depth=1`
|
|
||||||
- `git checkout v5`
|
|
||||||
- `git pull`
|
- `git pull`
|
||||||
- ⚠️ If this fails, you may want to stash or remove your code changes if you don't know how to resolve merge conflicts
|
- ⚠️ If this fails, you may want to stash or remove your code changes if you don't know how to resolve merge conflicts
|
||||||
4. **Backup** old output in case your data is overwritten
|
4. **Backup** old output in case your data is overwritten
|
||||||
@@ -119,11 +119,11 @@ Open PowerShell as described above and run the following commands:
|
|||||||
🎉 Enjoy
|
🎉 Enjoy
|
||||||
|
|
||||||
#### Music prerequisites
|
#### Music prerequisites
|
||||||
In order to use music commands, you need ffmpeg and yt-dlp installed.
|
In order to use music commands, you need ffmpeg and youtube-dl installed.
|
||||||
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
|
- [ffmpeg-32bit] | [ffmpeg-64bit] - Download the **appropriate version** for your system (32 bit if you're running a 32 bit OS, or 64 if you're running a 64bit OS). Unzip it, and move `ffmpeg.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `ffmpeg.exe` file to `NadekoBot/output`.
|
||||||
- [youtube-dlp] - Click to download the `yt-dlp.exe` file, then move `yt-dlp.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `yt-dlp.exe` file to `NadekoBot/system`.
|
- [youtube-dl] - Click to download the file, then move `youtube-dl.exe` to a path that's in your PATH environment variable. If you don't know what that is, just move the `youtube-dl.exe` file to `NadekoBot/system`.
|
||||||
|
|
||||||
[Updater]: https://dl.nadeko.bot/v3/
|
[Updater]: https://dl.nadeko.bot/
|
||||||
[Notepad++]: https://notepad-plus-plus.org/
|
[Notepad++]: https://notepad-plus-plus.org/
|
||||||
[.net]: https://dotnet.microsoft.com/download/dotnet/5.0
|
[.net]: https://dotnet.microsoft.com/download/dotnet/5.0
|
||||||
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
|
[Redis]: https://github.com/MicrosoftArchive/redis/releases/download/win-3.0.504/Redis-x64-3.0.504.msi
|
||||||
@@ -131,4 +131,4 @@ In order to use music commands, you need ffmpeg and yt-dlp installed.
|
|||||||
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
|
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
|
||||||
[ffmpeg-32bit]: https://cdn.nadeko.bot/dl/ffmpeg-32.zip
|
[ffmpeg-32bit]: https://cdn.nadeko.bot/dl/ffmpeg-32.zip
|
||||||
[ffmpeg-64bit]: https://cdn.nadeko.bot/dl/ffmpeg-64.zip
|
[ffmpeg-64bit]: https://cdn.nadeko.bot/dl/ffmpeg-64.zip
|
||||||
[youtube-dlp]: https://github.com/yt-dlp/yt-dlp/releases
|
[youtube-dl]: https://yt-dl.org/downloads/latest/youtube-dl.exe
|
||||||
|
@@ -36,6 +36,6 @@ If you're unsure whether something is an issue, ask in our support server first.
|
|||||||
[macos-guide]: ./guides/osx-guide.md
|
[macos-guide]: ./guides/osx-guide.md
|
||||||
[from-source-guide]: ./guides/from-source.md
|
[from-source-guide]: ./guides/from-source.md
|
||||||
[discord-server]: https://discord.nadeko.bot/
|
[discord-server]: https://discord.nadeko.bot/
|
||||||
[gitlab]: https://gitlab.com/kwoth/nadekobot
|
[gitlab]: https://gitlab.com/Kwoth/nadekobot
|
||||||
[issues]: https://gitlab.com/kwoth/nadekobot/issues
|
[issues]: https://gitlab.com/Kwoth/nadekobot/issues
|
||||||
[donate]: ./donate.md
|
[donate]: ./donate.md
|
||||||
|
@@ -1,61 +1,14 @@
|
|||||||
# Creating A Medusa
|
# Creating A Medusa
|
||||||
|
|
||||||
## Getting started
|
|
||||||
|
|
||||||
This section will guide you through how to create a simple custom medusa. You can find the entirety of this code hosted [here](https://gitlab.com/nadeko/example_medusa)
|
|
||||||
|
|
||||||
#### Prerequisite
|
|
||||||
- [.net8 sdk](https://dotnet.microsoft.com/en-us/download) installed
|
|
||||||
- Optional: use [vscode](https://code.visualstudio.com/download) to write code
|
|
||||||
|
|
||||||
#### Guide
|
|
||||||
|
|
||||||
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
|
||||||
|
|
||||||
- Create a new folder and move into it
|
|
||||||
- `mkdir example_medusa `
|
|
||||||
- `cd example_medusa`
|
|
||||||
|
|
||||||
- Install nadeko-medusa template
|
|
||||||
- `dotnet new install nadeko-medusa`
|
|
||||||
|
|
||||||
- Make a new Nadeko Medusa project
|
|
||||||
- `dotnet new nadeko-medusa`
|
|
||||||
|
|
||||||
### Build it
|
|
||||||
|
|
||||||
- Build your Medusa into a dll that Nadeko can load. In your terminal, type:
|
|
||||||
- `dotnet publish -o bin/medusae/example_medusa /p:DebugType=embedded`
|
|
||||||
|
|
||||||
- Done. You can now try it out in action.
|
|
||||||
|
|
||||||
### Try it out
|
|
||||||
|
|
||||||
- Copy the `bin/medusae/example_medusa` folder into your NadekoBot's `data/medusae/` folder. (Nadeko version 4.1.0+)
|
|
||||||
|
|
||||||
- Load it with `.meload example_medusa`
|
|
||||||
|
|
||||||
- In the channel your bot can see, run the following commands to try it out
|
|
||||||
- `.hello` and
|
|
||||||
- `.hello @<someone>`
|
|
||||||
|
|
||||||
- Check its information with
|
|
||||||
- `.meinfo example_medusa`
|
|
||||||
|
|
||||||
- Unload it
|
|
||||||
- `.meunload example_medusa`
|
|
||||||
|
|
||||||
- :tada: Congrats! You've just made your first medusa! :tada:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Theory
|
## Theory
|
||||||
|
|
||||||
|
### Introduction
|
||||||
|
|
||||||
Medusa system allows you to write independent medusae (known as "modules", "cogs" or "plugins" in other software) which you can then load, unload and update at will without restarting the bot.
|
Medusa system allows you to write independent medusae (known as "modules", "cogs" or "plugins" in other software) which you can then load, unload and update at will without restarting the bot.
|
||||||
|
|
||||||
The system itself borrows some design from the current way Nadeko's Modules are written but mostly from never-released `Ayu.Commands` system which was designed to be used for a full Nadeko v3 rewrite.
|
The system itself borrows some design from the current way Nadeko's Modules are written but mostly from never-released `Ayu.Commands` system which was designed to be used for a full Nadeko v3 rewrite.
|
||||||
|
|
||||||
The medusa base classes used for development are open source [here](https://gitlab.com/kwoth/nadekobot/-/tree/v5/src/Nadeko.Medusa) in case you need reference, as there is no generated documentation at the moment.
|
The medusa base classes used for development are open source [here](https://gitlab.com/Kwoth/nadekobot/-/tree/v4/src/Nadeko.Medusa) in case you need reference, as there is no generated documentation at the moment.
|
||||||
|
|
||||||
### Term list
|
### Term list
|
||||||
|
|
||||||
@@ -146,9 +99,9 @@ If you don't want any auxiliary files, and you don't want to bother making new .
|
|||||||
|
|
||||||
If you update your response strings .yml file(s) while the medusa is loaded and running, running `.stringsreload` will reload the responses without the need to reload the medusa or restart the bot.
|
If you update your response strings .yml file(s) while the medusa is loaded and running, running `.stringsreload` will reload the responses without the need to reload the medusa or restart the bot.
|
||||||
|
|
||||||
#### Bot medusa config file
|
#### Config
|
||||||
|
|
||||||
- Medusa config is kept in `data/medusae/medusa.yml` file in NadekoBot installation folder
|
- Medusa config is kept in `medusae/medusa.yml` file
|
||||||
- At the moment this config only keeps track of which medusae are currently loaded (they will also be always loaded at startup)
|
- At the moment this config only keeps track of which medusae are currently loaded (they will also be always loaded at startup)
|
||||||
- If a medusa is causing issues and you're unable to unload it, you can remove it from the `loaded:` list in this config file and restart the bot. It won't be loaded next time the bot is started up
|
- If a medusa is causing issues and you're unable to unload it, you can remove it from the `loaded:` list in this config file and restart the bot. It won't be loaded next time the bot is started up
|
||||||
|
|
||||||
@@ -162,4 +115,137 @@ To make sure your medusa can be properly unloaded/reloaded you must:
|
|||||||
|
|
||||||
- If you are still having issues, you can always run `.meunload` followed by a bot restart, or if you want to find what is causing the medusa unloadability issues, you can check the [microsoft's assembly unloadability debugging guide](https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability)
|
- If you are still having issues, you can always run `.meunload` followed by a bot restart, or if you want to find what is causing the medusa unloadability issues, you can check the [microsoft's assembly unloadability debugging guide](https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability)
|
||||||
|
|
||||||
|
## Practice
|
||||||
|
|
||||||
|
This section will guide you through how to create a simple custom medusa. You can find the entirety of this code hosted [here](https://gitlab.com/nadeko/example_medusa)
|
||||||
|
|
||||||
|
#### Prerequisite
|
||||||
|
- [.net6 sdk](https://dotnet.microsoft.com/en-us/download) installed
|
||||||
|
- Optional: use [vscode](https://code.visualstudio.com/download) to write code
|
||||||
|
|
||||||
|
#### Guide
|
||||||
|
|
||||||
|
|
||||||
|
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
||||||
|
|
||||||
|
- Create a new folder
|
||||||
|
- `mkdir example_medusa`
|
||||||
|
- Create a new .net class library
|
||||||
|
- `dotnet new classlib`
|
||||||
|
- Open the current folder with your favorite editor/IDE. In this case we'll use VsCode
|
||||||
|
- `code .`
|
||||||
|
- Remove the `Class1.cs` file
|
||||||
|
- Replace the contents of the `.csproj` file with the following contents
|
||||||
|
```xml
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
|
||||||
|
<!-- Reduces some boilerplate in your .cs files -->
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
|
||||||
|
<!-- Use latest .net features -->
|
||||||
|
<LangVersion>preview</LangVersion>
|
||||||
|
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||||
|
|
||||||
|
<!-- tell .net that this library will be used as a plugin -->
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- Base medusa package. You MUST reference this in order to have a working medusa -->
|
||||||
|
<!-- Also, this package comes from MyGet, which requires you to have a NuGet.Config file next to your .csproj -->
|
||||||
|
<PackageReference Include="Nadeko.Medusa" Version="1.0.1">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
|
||||||
|
<!-- Note: If you want to use NadekoBot services etc... You will have to manually clone
|
||||||
|
the gitlab.com/kwoth/nadekobot repo locally and reference the NadekoBot.csproj because there is no NadekoBot package atm.
|
||||||
|
It is strongly recommended that you checkout a specific tag which matches your version of nadeko,
|
||||||
|
as there could be breaking changes even between minor versions of NadekoBot.
|
||||||
|
For example if you're running NadekoBot 4.1.0 locally for which you want to create a medusa for,
|
||||||
|
you should do "git checkout 4.1.0" in your NadekoBot solution and then reference the NadekoBot.csproj
|
||||||
|
-->
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Copy shortcut and full strings to output (if they exist) -->
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="res.yml;cmds.yml;strings/**">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
|
|
||||||
|
```
|
||||||
|
- Create a `MySnek.cs` file and add the following contents
|
||||||
|
```cs
|
||||||
|
using Nadeko.Snake;
|
||||||
|
using NadekoBot;
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
public sealed class MySnek : Snek
|
||||||
|
{
|
||||||
|
[cmd]
|
||||||
|
public async Task Hello(AnyContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.Channel.SendMessageAsync($"Hello everyone!");
|
||||||
|
}
|
||||||
|
|
||||||
|
[cmd]
|
||||||
|
public async Task Hello(AnyContext ctx, IUser target)
|
||||||
|
{
|
||||||
|
await ctx.ConfirmLocalizedAsync("hello", target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Create `res.yml` and `cmds.yml` files with the following contents
|
||||||
|
`res.yml`
|
||||||
|
```yml
|
||||||
|
medusa.description: "This is my medusa's description"
|
||||||
|
hello: "Hello {0}, from res.yml!"
|
||||||
|
```
|
||||||
|
|
||||||
|
`cmds.yml`
|
||||||
|
```yml
|
||||||
|
hello:
|
||||||
|
desc: "This is a basic hello command"
|
||||||
|
args:
|
||||||
|
- ""
|
||||||
|
- "@Someone"
|
||||||
|
```
|
||||||
|
|
||||||
|
- Add `NuGet.Config` file which will let you use the base Nadeko.Medusa package. This file should always look like this and you shouldn't change it
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||||
|
<add key="nadeko.bot" value="https://www.myget.org/F/nadeko/api/v3/index.json" protocolVersion="3" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build it
|
||||||
|
|
||||||
|
- Build your Medusa into a dll that Nadeko can load. In your terminal, type:
|
||||||
|
- `dotnet publish -o bin/medusae/example_medusa /p:DebugType=embedded`
|
||||||
|
|
||||||
|
- Done. You can now try it out in action.
|
||||||
|
|
||||||
|
### Try it out
|
||||||
|
|
||||||
|
- Copy the `bin/medusae/example_medusa` folder into your NadekoBot's `data/medusae/` folder. (Nadeko version 4.1.0+)
|
||||||
|
|
||||||
|
- Load it with `.meload example_medusa`
|
||||||
|
|
||||||
|
- In the channel your bot can see, run the following commands to try it out
|
||||||
|
- `.hello` and
|
||||||
|
- `.hello @<someone>`
|
||||||
|
|
||||||
|
- Check its information with
|
||||||
|
- `.meinfo example_medusa`
|
||||||
|
|
||||||
|
- Unload it
|
||||||
|
- `.meunload example_medusa`
|
||||||
|
|
||||||
|
- Congrats! You've just made your first medusa!
|
@@ -8,7 +8,7 @@ Permissions are very handy at setting who can use what commands in a server. All
|
|||||||
|
|
||||||
Several commands still require that you have the correct permissions on Discord to be able to use them, so for users to be able to use commands like `.kick` and `.voicemute`, they need **Kick** and **Mute Members** server permissions, respectively.
|
Several commands still require that you have the correct permissions on Discord to be able to use them, so for users to be able to use commands like `.kick` and `.voicemute`, they need **Kick** and **Mute Members** server permissions, respectively.
|
||||||
|
|
||||||
With the permissions system it possible to restrict who can skip the current song.
|
With the permissions system it possible to restrict who can skip the current song, pick NadekoFlowers or use the NSFW module.
|
||||||
|
|
||||||
## First Time Setup
|
## First Time Setup
|
||||||
|
|
||||||
@@ -64,6 +64,15 @@ To allow users to only see the current song and have a DJ role for queuing follo
|
|||||||
4. `.rm Music enable DJ`
|
4. `.rm Music enable DJ`
|
||||||
- Enables all music commands only for the DJ role
|
- Enables all music commands only for the DJ role
|
||||||
|
|
||||||
|
#### How do I create a NSFW role?
|
||||||
|
|
||||||
|
Say you want to only enable NSFW commands for a specific role, just do the following two steps.
|
||||||
|
|
||||||
|
1. `.sm NSFW disable`
|
||||||
|
- Disables the NSFW module from being used
|
||||||
|
2. `.rm NSFW enable Lewd`
|
||||||
|
- Enables usage of the NSFW module for the Lewd role
|
||||||
|
|
||||||
#### How do I disable Expressions from triggering?
|
#### How do I disable Expressions from triggering?
|
||||||
|
|
||||||
If you don't want server or global Expressions, just block the module that controls their usage:
|
If you don't want server or global Expressions, just block the module that controls their usage:
|
||||||
|
@@ -38,7 +38,7 @@ Some features have their own specific placeholders which are noted in that featu
|
|||||||
- `%channel.name%` - Channel name
|
- `%channel.name%` - Channel name
|
||||||
- `%channel.id%` - Channel ID
|
- `%channel.id%` - Channel ID
|
||||||
- `%channel.created%` - Channel creation date
|
- `%channel.created%` - Channel creation date
|
||||||
- `%channel.nsfw%` - Returns either `True` or `False`, depending on if the channel is designated as age-restricted in discord
|
- `%channel.nsfw%` - Returns either `True` or `False`, depending on if the channel is designated as NSFW using discord
|
||||||
- `%channel.topic%` - Channel topic
|
- `%channel.topic%` - Channel topic
|
||||||
|
|
||||||
### User placeholders
|
### User placeholders
|
||||||
@@ -68,6 +68,11 @@ Some features have their own specific placeholders which are noted in that featu
|
|||||||
- `%ban.reason%` - Reason for the ban, if provided
|
- `%ban.reason%` - Reason for the ban, if provided
|
||||||
- `%ban.duration%` - Duration of the ban in the form Days.Hours:Minutes (6.05:04)
|
- `%ban.duration%` - Duration of the ban in the form Days.Hours:Minutes (6.05:04)
|
||||||
|
|
||||||
|
### Bot stats placeholders
|
||||||
|
|
||||||
|
- `%servers%` - Server count bot has joined
|
||||||
|
- `%users%` - Combined user count on servers the bot has joined
|
||||||
|
|
||||||
### Shard stats placeholders
|
### Shard stats placeholders
|
||||||
|
|
||||||
- `%shard.servercount%` - Server count on current shard
|
- `%shard.servercount%` - Server count on current shard
|
||||||
@@ -84,5 +89,6 @@ Some features have their own specific placeholders which are noted in that featu
|
|||||||
|
|
||||||
- `%rngX-Y%` - Returns a random number between X and Y
|
- `%rngX-Y%` - Returns a random number between X and Y
|
||||||
- `%target%` - Returns anything the user has written after the trigger (only works on Expressions)
|
- `%target%` - Returns anything the user has written after the trigger (only works on Expressions)
|
||||||
|
- `%img:stuff%` - Returns an `imgur.com` search for "stuff" (only works on Expressions)
|
||||||
|
|
||||||

|

|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#define sysfolder "system"
|
#define sysfolder "system"
|
||||||
#define version GetEnv("NADEKOBOT_INSTALL_VERSION")
|
#define version GetEnv("NADEKOBOT_INSTALL_VERSION")
|
||||||
#define target "win-x64"
|
#define target "win7-x64"
|
||||||
#define platform "net8.0"
|
#define platform "net6.0"
|
||||||
|
|
||||||
[Setup]
|
[Setup]
|
||||||
AppName = {param:botname|NadekoBot}
|
AppName = {param:botname|NadekoBot}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
site_name: 'NadekoBot'
|
site_name: 'NadekoBot'
|
||||||
site_url: 'https://nadeko.bot'
|
site_url: 'https://nadeko.bot'
|
||||||
repo_url: 'https://gitlab.com/nadeko/nadekobot'
|
repo_url: 'https://gitlab.com/kwoth/nadekobot'
|
||||||
site_author: 'Kwoth'
|
site_author: 'Kwoth'
|
||||||
|
|
||||||
theme:
|
theme:
|
||||||
|
63
release.ps1
Normal file
63
release.ps1
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
function Get-Changelog($lastTag)
|
||||||
|
{
|
||||||
|
if(!$lastTag)
|
||||||
|
{
|
||||||
|
$lastTag = git describe --tags --abbrev=0
|
||||||
|
}
|
||||||
|
|
||||||
|
$tag = "$lastTag..HEAD"
|
||||||
|
|
||||||
|
$clArr = (git log $tag --oneline)
|
||||||
|
[array]::Reverse($clArr)
|
||||||
|
$changelog = $clArr | where { "$_" -notlike "*(POEditor.com)*" -and "$_" -notlike "*Merge branch*" -and "$_" -notlike "*Merge pull request*" -and "$_" -notlike "^-*" -and "$_" -notlike "*Merge remote tracking*" }
|
||||||
|
$changelog = [string]::join([Environment]::NewLine, $changelog)
|
||||||
|
|
||||||
|
$cl2 = $clArr | where { "$_" -like "*Merge pull request*" }
|
||||||
|
$changelog = "## Changes$nl$changelog"
|
||||||
|
if ($null -ne $cl2) {
|
||||||
|
$cl2 = [string]::join([Environment]::NewLine, $cl2)
|
||||||
|
$changelog = $changelog + "$nl ## Pull Requests Merged$nl$cl2"
|
||||||
|
}
|
||||||
|
|
||||||
|
return $changelog
|
||||||
|
}
|
||||||
|
|
||||||
|
function Build-Installer($versionNumber)
|
||||||
|
{
|
||||||
|
$env:NADEKOBOT_INSTALL_VERSION = $versionNumber
|
||||||
|
|
||||||
|
dotnet clean
|
||||||
|
# rm -r -fo "src\NadekoBot\bin"
|
||||||
|
dotnet publish -c Release --runtime win7-x64 /p:Version=$versionNumber src/NadekoBot
|
||||||
|
# .\rcedit-x64.exe "src\NadekoBot\bin\Release\netcoreapp2.1\win7-x64\nadekobot.exe" --set-icon "src\NadekoBot\bin\Release\netcoreapp2.1\win7-x64\nadeko_icon.ico"
|
||||||
|
|
||||||
|
& "iscc.exe" "/O+" ".\exe_builder.iss"
|
||||||
|
|
||||||
|
Write-ReleaseFile($versionNumber)
|
||||||
|
# $path = [Environment]::GetFolderPath('MyDocuments') + "\_projekti\new_installer\$versionNumber\";
|
||||||
|
# $binPath = $path + "nadeko-setup-$versionNumber.exe";
|
||||||
|
# Copy-Item -Path $path -Destination $dest -Force -ErrorAction Stop
|
||||||
|
|
||||||
|
# return $path
|
||||||
|
}
|
||||||
|
|
||||||
|
function Write-ReleaseFile($versionNumber) {
|
||||||
|
$changelog = ""
|
||||||
|
# pull the changes if they exist
|
||||||
|
# git pull
|
||||||
|
# attempt to build teh installer
|
||||||
|
# $path = Build-Installer $versionNumber
|
||||||
|
|
||||||
|
# get changelog before tagging
|
||||||
|
$changelog = Get-Changelog
|
||||||
|
# tag the release
|
||||||
|
# & (git tag, $tag)
|
||||||
|
|
||||||
|
# print out the changelog to the console
|
||||||
|
# Write-Host $changelog
|
||||||
|
|
||||||
|
$jsonReleaseFile = "[{""VersionName"": ""$versionNumber"", ""DownloadLink"": ""https://cdn.nadeko.bot/dl/bot/nadeko-setup-$versionNumber.exe"", ""Changelog"": """"}]"
|
||||||
|
|
||||||
|
$releaseJsonOutPath = [Environment]::GetFolderPath('MyDocuments') + "\_projekti\nadeko-installers\$versionNumber\"
|
||||||
|
New-Item -Path $releaseJsonOutPath -Value $jsonReleaseFile -Name "releases.json" -Force
|
||||||
|
}
|
1
releases-v3.json
Normal file
1
releases-v3.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[{ "VersionName":"_VERSION_", "DownloadLink":"https://cdn.nadeko.bot/dl/bot/_INSTALLER_FILE_NAME_" }]
|
@@ -46,8 +46,12 @@ public sealed class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T
|
|||||||
public void CopyTo(T[] array, int arrayIndex)
|
public void CopyTo(T[] array, int arrayIndex)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(array);
|
ArgumentNullException.ThrowIfNull(array);
|
||||||
ArgumentOutOfRangeException.ThrowIfNegative(arrayIndex);
|
|
||||||
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(arrayIndex, array.Length);
|
if (arrayIndex < 0)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||||
|
|
||||||
|
if (arrayIndex >= array.Length)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
||||||
|
|
||||||
CopyToInternal(array, arrayIndex);
|
CopyToInternal(array, arrayIndex);
|
||||||
}
|
}
|
@@ -1,6 +1,4 @@
|
|||||||
using System.Security.Cryptography;
|
namespace Nadeko.Common;
|
||||||
|
|
||||||
namespace Nadeko.Common;
|
|
||||||
|
|
||||||
// made for expressions because they almost never get added
|
// made for expressions because they almost never get added
|
||||||
// and they get looped through constantly
|
// and they get looped through constantly
|
||||||
@@ -50,13 +48,4 @@ public static class ArrayExtensions
|
|||||||
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T? RandomOrDefault<T>(this T[] data)
|
|
||||||
{
|
|
||||||
if (data.Length == 0)
|
|
||||||
return default;
|
|
||||||
|
|
||||||
var index = RandomNumberGenerator.GetInt32(0, data.Length);
|
|
||||||
return data[index];
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -45,11 +45,21 @@ public static class EnumerableExtensions
|
|||||||
/// <param name="items">Items to shuffle</param>
|
/// <param name="items">Items to shuffle</param>
|
||||||
public static IReadOnlyList<T> Shuffle<T>(this IEnumerable<T> items)
|
public static IReadOnlyList<T> Shuffle<T>(this IEnumerable<T> items)
|
||||||
{
|
{
|
||||||
var list = items.ToArray();
|
using var provider = RandomNumberGenerator.Create();
|
||||||
var n = list.Length;
|
var list = items.ToList();
|
||||||
while (n-- > 1)
|
var n = list.Count;
|
||||||
|
while (n > 1)
|
||||||
{
|
{
|
||||||
var k = RandomNumberGenerator.GetInt32(n);
|
var box = new byte[(n / byte.MaxValue) + 1];
|
||||||
|
int boxSum;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
provider.GetBytes(box);
|
||||||
|
boxSum = box.Sum(b => b);
|
||||||
|
} while (!(boxSum < n * (byte.MaxValue * box.Length / n)));
|
||||||
|
|
||||||
|
var k = boxSum % n;
|
||||||
|
n--;
|
||||||
(list[k], list[n]) = (list[n], list[k]);
|
(list[k], list[n]) = (list[n], list[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,22 +82,6 @@ public static class EnumerableExtensions
|
|||||||
where TKey : notnull
|
where TKey : notnull
|
||||||
=> new(dict);
|
=> new(dict);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ConcurrentDictionary{TKey,TValue}" /> class
|
|
||||||
/// that contains elements copied from the specified <see cref="IEnumerable{T}" />
|
|
||||||
/// has the default concurrency level, has the default initial capacity,
|
|
||||||
/// and uses the default comparer for the key type.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dict">
|
|
||||||
/// The <see cref="IEnumerable{T}" /> whose elements are copied to the new
|
|
||||||
/// <see cref="ConcurrentDictionary{TKey,TValue}" />.
|
|
||||||
/// </param>
|
|
||||||
/// <returns>A new instance of the <see cref="ConcurrentDictionary{TKey,TValue}" /> class</returns>
|
|
||||||
public static ConcurrentHashSet<TValue> ToConcurrentSet<TValue>(
|
|
||||||
this IReadOnlyCollection<TValue> dict)
|
|
||||||
where TValue : notnull
|
|
||||||
=> new(dict);
|
|
||||||
|
|
||||||
public static IndexedCollection<T> ToIndexed<T>(this IEnumerable<T> enumerable)
|
public static IndexedCollection<T> ToIndexed<T>(this IEnumerable<T> enumerable)
|
||||||
where T : class, IIndexed
|
where T : class, IIndexed
|
||||||
=> new(enumerable);
|
=> new(enumerable);
|
1
src/Nadeko.Common/GlobalUsings.cs
Normal file
1
src/Nadeko.Common/GlobalUsings.cs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
global using NonBlocking;
|
@@ -1,14 +1,15 @@
|
|||||||
using Serilog.Events;
|
using Serilog.Events;
|
||||||
using Serilog.Sinks.SystemConsole.Themes;
|
using Serilog.Sinks.SystemConsole.Themes;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Nadeko.Common;
|
namespace Nadeko.Common;
|
||||||
|
|
||||||
public static class LogSetup
|
public static class LogSetup
|
||||||
{
|
{
|
||||||
public static void SetupLogger(object source, IBotCreds creds)
|
public static void SetupLogger(object source)
|
||||||
{
|
{
|
||||||
var config = new LoggerConfiguration().MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
Log.Logger = new LoggerConfiguration().MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||||
.MinimumLevel.Override("System", LogEventLevel.Information)
|
.MinimumLevel.Override("System", LogEventLevel.Information)
|
||||||
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
|
.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
|
||||||
.Enrich.FromLogContext()
|
.Enrich.FromLogContext()
|
||||||
@@ -16,12 +17,7 @@ public static class LogSetup
|
|||||||
theme: GetTheme(),
|
theme: GetTheme(),
|
||||||
outputTemplate:
|
outputTemplate:
|
||||||
"[{Timestamp:HH:mm:ss} {Level:u3}] | #{LogSource} | {Message:lj}{NewLine}{Exception}")
|
"[{Timestamp:HH:mm:ss} {Level:u3}] | #{LogSource} | {Message:lj}{NewLine}{Exception}")
|
||||||
.Enrich.WithProperty("LogSource", source);
|
.Enrich.WithProperty("LogSource", source)
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(creds.Seq.Url))
|
|
||||||
config = config.WriteTo.Seq(creds.Seq.Url, apiKey: creds.Seq.ApiKey);
|
|
||||||
|
|
||||||
Log.Logger = config
|
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
|
|
||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
@@ -5,9 +5,9 @@ namespace Nadeko.Common;
|
|||||||
// needs proper invalid input check (character array input out of range)
|
// needs proper invalid input check (character array input out of range)
|
||||||
// needs negative number support
|
// needs negative number support
|
||||||
// ReSharper disable once InconsistentNaming
|
// ReSharper disable once InconsistentNaming
|
||||||
#pragma warning disable CS8981
|
#pragma warning disable IDE1006
|
||||||
public readonly struct kwum : IEquatable<kwum>
|
public readonly struct kwum : IEquatable<kwum>
|
||||||
#pragma warning restore CS8981
|
#pragma warning restore IDE1006
|
||||||
{
|
{
|
||||||
private const string VALID_CHARACTERS = "23456789abcdefghijkmnpqrstuvwxyz";
|
private const string VALID_CHARACTERS = "23456789abcdefghijkmnpqrstuvwxyz";
|
||||||
private readonly int _value;
|
private readonly int _value;
|
||||||
@@ -76,9 +76,6 @@ public readonly struct kwum : IEquatable<kwum>
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (_value == 0)
|
|
||||||
return VALID_CHARACTERS[0].ToString();
|
|
||||||
|
|
||||||
var count = VALID_CHARACTERS.Length;
|
var count = VALID_CHARACTERS.Length;
|
||||||
var localValue = _value;
|
var localValue = _value;
|
||||||
var arrSize = (int)Math.Log(localValue, count) + 1;
|
var arrSize = (int)Math.Log(localValue, count) + 1;
|
14
src/Nadeko.Common/Nadeko.Common.csproj
Normal file
14
src/Nadeko.Common/Nadeko.Common.csproj
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NonBlocking" Version="2.1.0" />
|
||||||
|
|
||||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@@ -3,7 +3,7 @@ using System.Security.Cryptography;
|
|||||||
|
|
||||||
namespace Nadeko.Common;
|
namespace Nadeko.Common;
|
||||||
|
|
||||||
public sealed class NadekoRandom : Random
|
public class NadekoRandom : Random
|
||||||
{
|
{
|
||||||
private readonly RandomNumberGenerator _rng;
|
private readonly RandomNumberGenerator _rng;
|
||||||
|
|
||||||
@@ -17,28 +17,31 @@ public sealed class NadekoRandom : Random
|
|||||||
return Math.Abs(BitConverter.ToInt32(bytes, 0));
|
return Math.Abs(BitConverter.ToInt32(bytes, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates a random integer between 0 (inclusive) and
|
|
||||||
/// a specified exclusive upper bound using a cryptographically strong random number generator.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="maxValue">Exclusive max value</param>
|
|
||||||
/// <returns>A random number</returns>
|
|
||||||
public override int Next(int maxValue)
|
public override int Next(int maxValue)
|
||||||
=> RandomNumberGenerator.GetInt32(maxValue);
|
{
|
||||||
|
if (maxValue <= 0)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(maxValue));
|
||||||
|
var bytes = new byte[sizeof(int)];
|
||||||
|
_rng.GetBytes(bytes);
|
||||||
|
return Math.Abs(BitConverter.ToInt32(bytes, 0)) % maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates a random integer between a specified inclusive lower bound and a
|
|
||||||
/// specified exclusive upper bound using a cryptographically strong random number generator.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="minValue">Inclusive min value</param>
|
|
||||||
/// <param name="maxValue">Exclusive max value</param>
|
|
||||||
/// <returns>A random number</returns>
|
|
||||||
public override int Next(int minValue, int maxValue)
|
public override int Next(int minValue, int maxValue)
|
||||||
=> RandomNumberGenerator.GetInt32(minValue, maxValue);
|
{
|
||||||
|
if (minValue > maxValue)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(maxValue));
|
||||||
|
if (minValue == maxValue)
|
||||||
|
return minValue;
|
||||||
|
var bytes = new byte[sizeof(int)];
|
||||||
|
_rng.GetBytes(bytes);
|
||||||
|
var sign = Math.Sign(BitConverter.ToInt32(bytes, 0));
|
||||||
|
return (sign * BitConverter.ToInt32(bytes, 0) % (maxValue - minValue)) + minValue;
|
||||||
|
}
|
||||||
|
|
||||||
public long NextLong(long minValue, long maxValue)
|
public long NextLong(long minValue, long maxValue)
|
||||||
{
|
{
|
||||||
ArgumentOutOfRangeException.ThrowIfGreaterThan(minValue, maxValue);
|
if (minValue > maxValue)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(maxValue));
|
||||||
if (minValue == maxValue)
|
if (minValue == maxValue)
|
||||||
return minValue;
|
return minValue;
|
||||||
var bytes = new byte[sizeof(long)];
|
var bytes = new byte[sizeof(long)];
|
@@ -1,4 +1,5 @@
|
|||||||
using System.Threading.Channels;
|
using System.Threading.Channels;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Nadeko.Common;
|
namespace Nadeko.Common;
|
||||||
|
|
||||||
@@ -9,7 +10,8 @@ public sealed class QueueRunner
|
|||||||
|
|
||||||
public QueueRunner(int delayMs = 0, int maxCapacity = -1)
|
public QueueRunner(int delayMs = 0, int maxCapacity = -1)
|
||||||
{
|
{
|
||||||
ArgumentOutOfRangeException.ThrowIfNegative(delayMs);
|
if (delayMs < 0)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(delayMs));
|
||||||
|
|
||||||
_delayMs = delayMs;
|
_delayMs = delayMs;
|
||||||
_channel = maxCapacity switch
|
_channel = maxCapacity switch
|
19
src/Nadeko.Common/ShmartBankAmount.cs
Normal file
19
src/Nadeko.Common/ShmartBankAmount.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Nadeko.Common;
|
||||||
|
|
||||||
|
public readonly struct ShmartBankAmount
|
||||||
|
{
|
||||||
|
public long Amount { get; }
|
||||||
|
public ShmartBankAmount(long amount)
|
||||||
|
{
|
||||||
|
Amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator ShmartBankAmount(long num)
|
||||||
|
=> new(num);
|
||||||
|
|
||||||
|
public static implicit operator long(ShmartBankAmount num)
|
||||||
|
=> num.Amount;
|
||||||
|
|
||||||
|
public static implicit operator ShmartBankAmount(int num)
|
||||||
|
=> new(num);
|
||||||
|
}
|
38
src/Nadeko.Common/ShmartNumber.cs
Normal file
38
src/Nadeko.Common/ShmartNumber.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
namespace Nadeko.Common;
|
||||||
|
|
||||||
|
public readonly struct ShmartNumber : IEquatable<ShmartNumber>
|
||||||
|
{
|
||||||
|
public long Value { get; }
|
||||||
|
|
||||||
|
public ShmartNumber(long val)
|
||||||
|
{
|
||||||
|
Value = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator ShmartNumber(long num)
|
||||||
|
=> new(num);
|
||||||
|
|
||||||
|
public static implicit operator long(ShmartNumber num)
|
||||||
|
=> num.Value;
|
||||||
|
|
||||||
|
public static implicit operator ShmartNumber(int num)
|
||||||
|
=> new(num);
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
=> Value.ToString();
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
=> obj is ShmartNumber sn && Equals(sn);
|
||||||
|
|
||||||
|
public bool Equals(ShmartNumber other)
|
||||||
|
=> other.Value == Value;
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
=> Value.GetHashCode();
|
||||||
|
|
||||||
|
public static bool operator ==(ShmartNumber left, ShmartNumber right)
|
||||||
|
=> left.Equals(right);
|
||||||
|
|
||||||
|
public static bool operator !=(ShmartNumber left, ShmartNumber right)
|
||||||
|
=> !(left == right);
|
||||||
|
}
|
@@ -259,10 +259,10 @@ public class Deck
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly string[] _regIndicators =
|
private readonly string[] _regIndicators =
|
||||||
[
|
{
|
||||||
"🇦", ":two:", ":three:", ":four:", ":five:", ":six:", ":seven:", ":eight:", ":nine:", ":keycap_ten:",
|
"🇦", ":two:", ":three:", ":four:", ":five:", ":six:", ":seven:", ":eight:", ":nine:", ":keycap_ten:",
|
||||||
"🇯", "🇶", "🇰"
|
"🇯", "🇶", "🇰"
|
||||||
];
|
};
|
||||||
|
|
||||||
public Card(CardSuit s, int cardNum)
|
public Card(CardSuit s, int cardNum)
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling.Betdraw;
|
namespace Nadeko.Econ.Gambling.Betdraw;
|
||||||
|
|
||||||
public enum BetdrawColorGuess
|
public enum BetdrawColorGuess
|
||||||
{
|
{
|
@@ -1,6 +1,6 @@
|
|||||||
using Nadeko.Econ;
|
using Serilog;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling.Betdraw;
|
namespace Nadeko.Econ.Gambling.Betdraw;
|
||||||
|
|
||||||
public sealed class BetdrawGame
|
public sealed class BetdrawGame
|
||||||
{
|
{
|
@@ -1,6 +1,4 @@
|
|||||||
using Nadeko.Econ;
|
namespace Nadeko.Econ.Gambling.Betdraw;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling.Betdraw;
|
|
||||||
|
|
||||||
public readonly struct BetdrawResult
|
public readonly struct BetdrawResult
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling.Betdraw;
|
namespace Nadeko.Econ.Gambling.Betdraw;
|
||||||
|
|
||||||
public enum BetdrawResultType
|
public enum BetdrawResultType
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling.Betdraw;
|
namespace Nadeko.Econ.Gambling.Betdraw;
|
||||||
|
|
||||||
public enum BetdrawValueGuess
|
public enum BetdrawValueGuess
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
public sealed class BetflipGame
|
public sealed class BetflipGame
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
public readonly struct BetflipResult
|
public readonly struct BetflipResult
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
public sealed class BetrollGame
|
public sealed class BetrollGame
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
public readonly struct BetrollResult
|
public readonly struct BetrollResult
|
||||||
{
|
{
|
@@ -1,12 +1,12 @@
|
|||||||
namespace NadekoBot.Modules.Gambling.Rps;
|
namespace Nadeko.Econ.Gambling.Rps;
|
||||||
|
|
||||||
public sealed class RpsGame
|
public sealed class RpsGame
|
||||||
{
|
{
|
||||||
private static readonly NadekoRandom _rng = new NadekoRandom();
|
private static readonly NadekoRandom _rng = new NadekoRandom();
|
||||||
|
|
||||||
private const decimal WIN_MULTI = 1.95m;
|
const decimal WIN_MULTI = 1.95m;
|
||||||
private const decimal DRAW_MULTI = 1m;
|
const decimal DRAW_MULTI = 1m;
|
||||||
private const decimal LOSE_MULTI = 0m;
|
const decimal LOSE_MULTI = 0m;
|
||||||
|
|
||||||
public RpsGame()
|
public RpsGame()
|
||||||
{
|
{
|
@@ -1,8 +1,5 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
//here is a payout chart
|
|
||||||
//https://lh6.googleusercontent.com/-i1hjAJy_kN4/UswKxmhrbPI/AAAAAAAAB1U/82wq_4ZZc-Y/DE6B0895-6FC1-48BE-AC4F-14D1B91AB75B.jpg
|
|
||||||
//thanks to judge for helping me with this
|
|
||||||
public class SlotGame
|
public class SlotGame
|
||||||
{
|
{
|
||||||
private static readonly NadekoRandom _rng = new NadekoRandom();
|
private static readonly NadekoRandom _rng = new NadekoRandom();
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
public readonly struct SlotResult
|
public readonly struct SlotResult
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
public readonly struct LuLaResult
|
public readonly struct LuLaResult
|
||||||
{
|
{
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Modules.Gambling;
|
namespace Nadeko.Econ.Gambling;
|
||||||
|
|
||||||
public sealed class LulaGame
|
public sealed class LulaGame
|
||||||
{
|
{
|
1
src/Nadeko.Econ/GlobalUsings.cs
Normal file
1
src/Nadeko.Econ/GlobalUsings.cs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
global using Nadeko.Common;
|
13
src/Nadeko.Econ/Nadeko.Econ.csproj
Normal file
13
src/Nadeko.Econ/Nadeko.Econ.csproj
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Nadeko.Common\Nadeko.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overridden to implement custom checks which commands have to pass in order to be executed.
|
/// Overridden to implement custom checks which commands have to pass in order to be executed.
|
||||||
|
@@ -1,10 +0,0 @@
|
|||||||
namespace NadekoBot.Medusa;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used as a marker class for bot_perm and user_perm Attributes
|
|
||||||
/// Has no functionality.
|
|
||||||
/// </summary>
|
|
||||||
public abstract class MedusaPermAttribute : Attribute
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@@ -1,7 +0,0 @@
|
|||||||
namespace NadekoBot.Medusa;
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Method)]
|
|
||||||
public sealed class bot_owner_onlyAttribute : MedusaPermAttribute
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
using Discord;
|
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
|
||||||
public sealed class bot_permAttribute : MedusaPermAttribute
|
|
||||||
{
|
|
||||||
public GuildPermission? GuildPerm { get; }
|
|
||||||
public ChannelPermission? ChannelPerm { get; }
|
|
||||||
|
|
||||||
|
|
||||||
public bot_permAttribute(GuildPermission perm)
|
|
||||||
{
|
|
||||||
GuildPerm = perm;
|
|
||||||
ChannelPerm = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bot_permAttribute(ChannelPermission perm)
|
|
||||||
{
|
|
||||||
ChannelPerm = perm;
|
|
||||||
GuildPerm = null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks a method as a snek command
|
/// Marks a method as a snek command
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks services in command arguments for injection.
|
/// Marks services in command arguments for injection.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks the parameter to take
|
/// Marks the parameter to take
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the priority of a command in case there are multiple commands with the same name but different parameters.
|
/// Sets the priority of a command in case there are multiple commands with the same name but different parameters.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks the class as a service which can be used within the same Medusa
|
/// Marks the class as a service which can be used within the same Medusa
|
||||||
|
@@ -1,22 +0,0 @@
|
|||||||
using Discord;
|
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
|
||||||
public sealed class user_permAttribute : MedusaPermAttribute
|
|
||||||
{
|
|
||||||
public GuildPermission? GuildPerm { get; }
|
|
||||||
public ChannelPermission? ChannelPerm { get; }
|
|
||||||
|
|
||||||
public user_permAttribute(GuildPermission perm)
|
|
||||||
{
|
|
||||||
GuildPerm = perm;
|
|
||||||
ChannelPerm = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public user_permAttribute(ChannelPermission perm)
|
|
||||||
{
|
|
||||||
ChannelPerm = perm;
|
|
||||||
GuildPerm = null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,6 +1,7 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
|
using NadekoBot;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Commands which take this class as a first parameter can be executed in both DMs and Servers
|
/// Commands which take this class as a first parameter can be executed in both DMs and Servers
|
||||||
@@ -22,11 +23,6 @@ public abstract class AnyContext
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract IUser User { get; }
|
public abstract IUser User { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bot user
|
|
||||||
/// </summary>
|
|
||||||
public abstract ISelfUser Bot { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides access to strings used by this medusa
|
/// Provides access to strings used by this medusa
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -39,4 +35,13 @@ public abstract class AnyContext
|
|||||||
/// <param name="args">Arguments (if any) to format in</param>
|
/// <param name="args">Arguments (if any) to format in</param>
|
||||||
/// <returns>A formatted localized string</returns>
|
/// <returns>A formatted localized string</returns>
|
||||||
public abstract string GetText(string key, object[]? args = null);
|
public abstract string GetText(string key, object[]? args = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a context-aware <see cref="IEmbedBuilder"/> instance
|
||||||
|
/// (future feature for guild-based embed colors)
|
||||||
|
/// Any code dealing with embeds should use it for future-proofness
|
||||||
|
/// instead of manually creating embedbuilder instances
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A context-aware <see cref="IEmbedBuilder"/> instance </returns>
|
||||||
|
public abstract IEmbedBuilder Embed();
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Commands which take this type as the first parameter can only be executed in DMs
|
/// Commands which take this type as the first parameter can only be executed in DMs
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Commands which take this type as a first parameter can only be executed in a server
|
/// Commands which take this type as a first parameter can only be executed in a server
|
||||||
|
14
src/Nadeko.Medusa/Extensions/EmbedBuilderExtensions.cs
Normal file
14
src/Nadeko.Medusa/Extensions/EmbedBuilderExtensions.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
namespace NadekoBot;
|
||||||
|
|
||||||
|
public static class EmbedBuilderExtensions
|
||||||
|
{
|
||||||
|
public static IEmbedBuilder WithOkColor(this IEmbedBuilder eb)
|
||||||
|
=> eb.WithColor(EmbedColor.Ok);
|
||||||
|
|
||||||
|
public static IEmbedBuilder WithPendingColor(this IEmbedBuilder eb)
|
||||||
|
=> eb.WithColor(EmbedColor.Pending);
|
||||||
|
|
||||||
|
public static IEmbedBuilder WithErrorColor(this IEmbedBuilder eb)
|
||||||
|
=> eb.WithColor(EmbedColor.Error);
|
||||||
|
|
||||||
|
}
|
@@ -1,32 +1,37 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
|
using Nadeko.Snake;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace NadekoBot;
|
||||||
|
|
||||||
public static class MedusaExtensions
|
public static class MedusaExtensions
|
||||||
{
|
{
|
||||||
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "")
|
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, IEmbedBuilder embed, string msg = "")
|
||||||
=> ch.SendMessageAsync(msg,
|
=> ch.SendMessageAsync(msg,
|
||||||
embed: embed.Build(),
|
embed: embed.Build(),
|
||||||
options: new()
|
options: new()
|
||||||
{
|
{
|
||||||
RetryMode = RetryMode.Retry502
|
RetryMode = RetryMode.AlwaysRetry
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// unlocalized
|
||||||
|
public static Task<IUserMessage> SendConfirmAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||||
|
=> ch.EmbedAsync(ctx.Embed().WithOkColor().WithDescription(msg));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> SendPendingAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||||
|
=> ch.EmbedAsync(ctx.Embed().WithPendingColor().WithDescription(msg));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> SendErrorAsync(this IMessageChannel ch, AnyContext ctx, string msg)
|
||||||
|
=> ch.EmbedAsync(ctx.Embed().WithErrorColor().WithDescription(msg));
|
||||||
|
|
||||||
// unlocalized
|
// unlocalized
|
||||||
public static Task<IUserMessage> SendConfirmAsync(this AnyContext ctx, string msg)
|
public static Task<IUserMessage> SendConfirmAsync(this AnyContext ctx, string msg)
|
||||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
=> ctx.Channel.SendConfirmAsync(ctx, msg);
|
||||||
.WithColor(0, 200, 0)
|
|
||||||
.WithDescription(msg));
|
|
||||||
|
|
||||||
public static Task<IUserMessage> SendPendingAsync(this AnyContext ctx, string msg)
|
public static Task<IUserMessage> SendPendingAsync(this AnyContext ctx, string msg)
|
||||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
=> ctx.Channel.SendPendingAsync(ctx, msg);
|
||||||
.WithColor(200, 200, 0)
|
|
||||||
.WithDescription(msg));
|
|
||||||
|
|
||||||
public static Task<IUserMessage> SendErrorAsync(this AnyContext ctx, string msg)
|
public static Task<IUserMessage> SendErrorAsync(this AnyContext ctx, string msg)
|
||||||
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
=> ctx.Channel.SendErrorAsync(ctx, msg);
|
||||||
.WithColor(200, 0, 0)
|
|
||||||
.WithDescription(msg));
|
|
||||||
|
|
||||||
// localized
|
// localized
|
||||||
public static Task ConfirmAsync(this AnyContext ctx)
|
public static Task ConfirmAsync(this AnyContext ctx)
|
||||||
|
17
src/Nadeko.Medusa/IEmbedBuilder.cs
Normal file
17
src/Nadeko.Medusa/IEmbedBuilder.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace NadekoBot;
|
||||||
|
|
||||||
|
public interface IEmbedBuilder
|
||||||
|
{
|
||||||
|
IEmbedBuilder WithDescription(string? desc);
|
||||||
|
IEmbedBuilder WithTitle(string? title);
|
||||||
|
IEmbedBuilder AddField(string title, object value, bool isInline = false);
|
||||||
|
IEmbedBuilder WithFooter(string text, string? iconUrl = null);
|
||||||
|
IEmbedBuilder WithAuthor(string name, string? iconUrl = null, string? url = null);
|
||||||
|
IEmbedBuilder WithColor(EmbedColor color);
|
||||||
|
Embed Build();
|
||||||
|
IEmbedBuilder WithUrl(string url);
|
||||||
|
IEmbedBuilder WithImageUrl(string url);
|
||||||
|
IEmbedBuilder WithThumbnailUrl(string url);
|
||||||
|
}
|
@@ -1,20 +1,20 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<LangVersion>preview</LangVersion>
|
||||||
|
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||||
|
<RootNamespace>Nadeko.Snake</RootNamespace>
|
||||||
|
|
||||||
<Authors>The NadekoBot Team</Authors>
|
<Authors>The NadekoBot Team</Authors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Discord.Net.Core" Version="3.15.3" />
|
<PackageReference Include="Discord.Net.Core" Version="3.103.0" />
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
|
||||||
<Version>9.0.0</Version>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overridden to implement parsers for custom types
|
/// Overridden to implement parsers for custom types
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
public readonly struct ParseResult<T>
|
public readonly struct ParseResult<T>
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
using Discord;
|
using Discord;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The base class which will be loaded as a module into NadekoBot
|
/// The base class which will be loaded as a module into NadekoBot
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
public readonly struct CommandStrings
|
public readonly struct CommandStrings
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines methods to retrieve and reload medusa strings
|
/// Defines methods to retrieve and reload medusa strings
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implemented by classes which provide localized strings in their own ways
|
/// Implemented by classes which provide localized strings in their own ways
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
public class LocalMedusaStringsProvider : IMedusaStringsProvider
|
public class LocalMedusaStringsProvider : IMedusaStringsProvider
|
||||||
{
|
{
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
public class MedusaStrings : IMedusaStrings
|
public class MedusaStrings : IMedusaStrings
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace NadekoBot.Medusa;
|
namespace Nadeko.Snake;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads strings from the shortcut or localizable path
|
/// Loads strings from the shortcut or localizable path
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<NoWarn>CS8981</NoWarn>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -10,11 +9,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Grpc.AspNetCore" Version="2.62.0" />
|
<PackageReference Include="Grpc.AspNetCore" Version="2.47.0" />
|
||||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -417,7 +417,8 @@ namespace NadekoBot.Coordinator
|
|||||||
{
|
{
|
||||||
lock (locker)
|
lock (locker)
|
||||||
{
|
{
|
||||||
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(shardId, _shardStatuses.Length);
|
if (shardId >= _shardStatuses.Length)
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(shardId));
|
||||||
|
|
||||||
return _shardStatuses[shardId];
|
return _shardStatuses[shardId];
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,8 @@ using Microsoft.CodeAnalysis;
|
|||||||
using Microsoft.CodeAnalysis.CSharp;
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Microsoft.CodeAnalysis.Text;
|
using Microsoft.CodeAnalysis.Text;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Cloneable
|
namespace Cloneable
|
||||||
@@ -21,60 +23,54 @@ namespace Cloneable
|
|||||||
private const string CLONE_ATTRIBUTE_STRING = "CloneAttribute";
|
private const string CLONE_ATTRIBUTE_STRING = "CloneAttribute";
|
||||||
private const string IGNORE_CLONE_ATTRIBUTE_STRING = "IgnoreCloneAttribute";
|
private const string IGNORE_CLONE_ATTRIBUTE_STRING = "IgnoreCloneAttribute";
|
||||||
|
|
||||||
private const string CLONEABLE_ATTRIBUTE_TEXT = $$"""
|
private const string CLONEABLE_ATTRIBUTE_TEXT = @"// <AutoGenerated/>
|
||||||
// <AutoGenerated/>
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace {{CLONEABLE_NAMESPACE}}
|
namespace " + CLONEABLE_NAMESPACE + @"
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
|
||||||
internal sealed class {{CLONEABLE_ATTRIBUTE_STRING}} : Attribute
|
public sealed class " + CLONEABLE_ATTRIBUTE_STRING + @" : Attribute
|
||||||
{
|
{
|
||||||
public {{CLONEABLE_ATTRIBUTE_STRING}}()
|
public " + CLONEABLE_ATTRIBUTE_STRING + @"()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool {{EXPLICIT_DECLARATION_KEY_STRING}} { get; set; }
|
public bool " + EXPLICIT_DECLARATION_KEY_STRING + @" { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
";
|
||||||
|
|
||||||
""";
|
private const string CLONE_PROPERTY_ATTRIBUTE_TEXT = @"// <AutoGenerated/>
|
||||||
|
|
||||||
private const string CLONE_PROPERTY_ATTRIBUTE_TEXT = $$"""
|
|
||||||
// <AutoGenerated/>
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace {{CLONEABLE_NAMESPACE}}
|
namespace " + CLONEABLE_NAMESPACE + @"
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||||
internal sealed class {{CLONE_ATTRIBUTE_STRING}} : Attribute
|
public sealed class " + CLONE_ATTRIBUTE_STRING + @" : Attribute
|
||||||
{
|
{
|
||||||
public {{CLONE_ATTRIBUTE_STRING}}()
|
public " + CLONE_ATTRIBUTE_STRING + @"()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool {{PREVENT_DEEP_COPY_KEY_STRING}} { get; set; }
|
public bool " + PREVENT_DEEP_COPY_KEY_STRING + @" { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
";
|
||||||
|
|
||||||
""";
|
private const string IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT = @"// <AutoGenerated/>
|
||||||
|
|
||||||
private const string IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT = $$"""
|
|
||||||
// <AutoGenerated/>
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace {{CLONEABLE_NAMESPACE}}
|
namespace " + CLONEABLE_NAMESPACE + @"
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||||
internal sealed class {{IGNORE_CLONE_ATTRIBUTE_STRING}} : Attribute
|
public sealed class " + IGNORE_CLONE_ATTRIBUTE_STRING + @" : Attribute
|
||||||
{
|
{
|
||||||
public {{IGNORE_CLONE_ATTRIBUTE_STRING}}()
|
public " + IGNORE_CLONE_ATTRIBUTE_STRING + @"()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
";
|
||||||
""";
|
|
||||||
|
|
||||||
private INamedTypeSymbol? _cloneableAttribute;
|
private INamedTypeSymbol? _cloneableAttribute;
|
||||||
private INamedTypeSymbol? _ignoreCloneAttribute;
|
private INamedTypeSymbol? _ignoreCloneAttribute;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
// Code temporarily yeeted from
|
// Code temporarily yeeted from
|
||||||
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||||
// because of NRT issue
|
// because of NRT issue
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
namespace Cloneable
|
namespace Cloneable
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// Code temporarily yeeted from
|
// Code temporarily yeeted from
|
||||||
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||||
// because of NRT issue
|
// because of NRT issue
|
||||||
|
using System.Collections.Generic;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
|
||||||
|
336
src/NadekoBot.Generators/Command/CommandAttributesGenerator.cs
Normal file
336
src/NadekoBot.Generators/Command/CommandAttributesGenerator.cs
Normal file
@@ -0,0 +1,336 @@
|
|||||||
|
// #nullable enable
|
||||||
|
// using System;
|
||||||
|
// using System.CodeDom.Compiler;
|
||||||
|
// using System.Collections.Generic;
|
||||||
|
// using System.Collections.Immutable;
|
||||||
|
// using System.Collections.ObjectModel;
|
||||||
|
// using System.Diagnostics;
|
||||||
|
// using System.IO;
|
||||||
|
// using System.Linq;
|
||||||
|
// using System.Text;
|
||||||
|
// using System.Threading;
|
||||||
|
// using Microsoft.CodeAnalysis;
|
||||||
|
// using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
// using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
// using Microsoft.CodeAnalysis.Text;
|
||||||
|
//
|
||||||
|
// namespace NadekoBot.Generators.Command;
|
||||||
|
//
|
||||||
|
// [Generator]
|
||||||
|
// public class CommandAttributesGenerator : IIncrementalGenerator
|
||||||
|
// {
|
||||||
|
// public const string ATTRIBUTE = @"// <AutoGenerated />
|
||||||
|
//
|
||||||
|
// namespace NadekoBot.Common;
|
||||||
|
//
|
||||||
|
// [System.AttributeUsage(System.AttributeTargets.Method)]
|
||||||
|
// public class CmdAttribute : System.Attribute
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }";
|
||||||
|
//
|
||||||
|
// public class MethodModel
|
||||||
|
// {
|
||||||
|
// public string? Namespace { get; }
|
||||||
|
// public IReadOnlyCollection<string> Classes { get; }
|
||||||
|
// public string ReturnType { get; }
|
||||||
|
// public string MethodName { get; }
|
||||||
|
// public IEnumerable<string> Params { get; }
|
||||||
|
//
|
||||||
|
// public MethodModel(string? ns, IReadOnlyCollection<string> classes, string returnType, string methodName, IEnumerable<string> @params)
|
||||||
|
// {
|
||||||
|
// Namespace = ns;
|
||||||
|
// Classes = classes;
|
||||||
|
// ReturnType = returnType;
|
||||||
|
// MethodName = methodName;
|
||||||
|
// Params = @params;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public class FileModel
|
||||||
|
// {
|
||||||
|
// public string? Namespace { get; }
|
||||||
|
// public IReadOnlyCollection<string> ClassHierarchy { get; }
|
||||||
|
// public IReadOnlyCollection<MethodModel> Methods { get; }
|
||||||
|
//
|
||||||
|
// public FileModel(string? ns, IReadOnlyCollection<string> classHierarchy, IReadOnlyCollection<MethodModel> methods)
|
||||||
|
// {
|
||||||
|
// Namespace = ns;
|
||||||
|
// ClassHierarchy = classHierarchy;
|
||||||
|
// Methods = methods;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||||
|
// {
|
||||||
|
// // #if DEBUG
|
||||||
|
// // if (!Debugger.IsAttached)
|
||||||
|
// // Debugger.Launch();
|
||||||
|
// // // SpinWait.SpinUntil(() => Debugger.IsAttached);
|
||||||
|
// // #endif
|
||||||
|
// context.RegisterPostInitializationOutput(static ctx => ctx.AddSource(
|
||||||
|
// "CmdAttribute.g.cs",
|
||||||
|
// SourceText.From(ATTRIBUTE, Encoding.UTF8)));
|
||||||
|
//
|
||||||
|
// var methods = context.SyntaxProvider
|
||||||
|
// .CreateSyntaxProvider(
|
||||||
|
// static (node, _) => node is MethodDeclarationSyntax { AttributeLists.Count: > 0 },
|
||||||
|
// static (ctx, cancel) => Transform(ctx, cancel))
|
||||||
|
// .Where(static m => m is not null)
|
||||||
|
// .Where(static m => m?.ChildTokens().Any(static x => x.IsKind(SyntaxKind.PublicKeyword)) ?? false);
|
||||||
|
//
|
||||||
|
// var compilationMethods = context.CompilationProvider.Combine(methods.Collect());
|
||||||
|
//
|
||||||
|
// context.RegisterSourceOutput(compilationMethods,
|
||||||
|
// static (ctx, tuple) => RegisterAction(in ctx, tuple.Left, in tuple.Right));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static void RegisterAction(in SourceProductionContext ctx,
|
||||||
|
// Compilation comp,
|
||||||
|
// in ImmutableArray<MethodDeclarationSyntax?> methods)
|
||||||
|
// {
|
||||||
|
// if (methods is { IsDefaultOrEmpty: true })
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// var models = GetModels(comp, methods, ctx.CancellationToken);
|
||||||
|
//
|
||||||
|
// foreach (var model in models)
|
||||||
|
// {
|
||||||
|
// var name = $"{model.Namespace}.{string.Join(".", model.ClassHierarchy)}.g.cs";
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var source = GetSourceText(model);
|
||||||
|
// ctx.AddSource(name, SourceText.From(source, Encoding.UTF8));
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($"Error writing source file {name}\n" + ex);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static string GetSourceText(FileModel model)
|
||||||
|
// {
|
||||||
|
// using var sw = new StringWriter();
|
||||||
|
// using var tw = new IndentedTextWriter(sw);
|
||||||
|
//
|
||||||
|
// tw.WriteLine("// <AutoGenerated />");
|
||||||
|
// tw.WriteLine("#pragma warning disable CS1066");
|
||||||
|
//
|
||||||
|
// if (model.Namespace is not null)
|
||||||
|
// {
|
||||||
|
// tw.WriteLine($"namespace {model.Namespace};");
|
||||||
|
// tw.WriteLine();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// foreach (var className in model.ClassHierarchy)
|
||||||
|
// {
|
||||||
|
// tw.WriteLine($"public partial class {className}");
|
||||||
|
// tw.WriteLine("{");
|
||||||
|
// tw.Indent ++;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// foreach (var method in model.Methods)
|
||||||
|
// {
|
||||||
|
// tw.WriteLine("[NadekoCommand]");
|
||||||
|
// tw.WriteLine("[NadekoDescription]");
|
||||||
|
// tw.WriteLine("[Aliases]");
|
||||||
|
// tw.WriteLine($"public partial {method.ReturnType} {method.MethodName}({string.Join(", ", method.Params)});");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// foreach (var _ in model.ClassHierarchy)
|
||||||
|
// {
|
||||||
|
// tw.Indent --;
|
||||||
|
// tw.WriteLine("}");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// tw.Flush();
|
||||||
|
// return sw.ToString();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static IReadOnlyCollection<FileModel> GetModels(Compilation compilation,
|
||||||
|
// in ImmutableArray<MethodDeclarationSyntax?> inputMethods,
|
||||||
|
// CancellationToken cancel)
|
||||||
|
// {
|
||||||
|
// var models = new List<FileModel>();
|
||||||
|
//
|
||||||
|
// var methods = inputMethods
|
||||||
|
// .Where(static x => x is not null)
|
||||||
|
// .Distinct();
|
||||||
|
//
|
||||||
|
// var methodModels = methods
|
||||||
|
// .Select(x => MethodDeclarationToMethodModel(compilation, x!))
|
||||||
|
// .Where(static x => x is not null)
|
||||||
|
// .Cast<MethodModel>();
|
||||||
|
//
|
||||||
|
// var groups = methodModels
|
||||||
|
// .GroupBy(static x => $"{x.Namespace}.{string.Join(".", x.Classes)}");
|
||||||
|
//
|
||||||
|
// foreach (var group in groups)
|
||||||
|
// {
|
||||||
|
// if (cancel.IsCancellationRequested)
|
||||||
|
// return new Collection<FileModel>();
|
||||||
|
//
|
||||||
|
// if (group is null)
|
||||||
|
// continue;
|
||||||
|
//
|
||||||
|
// var elems = group.ToList();
|
||||||
|
// if (elems.Count is 0)
|
||||||
|
// continue;
|
||||||
|
//
|
||||||
|
// var model = new FileModel(
|
||||||
|
// methods: elems,
|
||||||
|
// ns: elems[0].Namespace,
|
||||||
|
// classHierarchy: elems![0].Classes
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// models.Add(model);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// return models;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static MethodModel? MethodDeclarationToMethodModel(Compilation comp, MethodDeclarationSyntax decl)
|
||||||
|
// {
|
||||||
|
// // SpinWait.SpinUntil(static () => Debugger.IsAttached);
|
||||||
|
//
|
||||||
|
// SemanticModel semanticModel;
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// semanticModel = comp.GetSemanticModel(decl.SyntaxTree);
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// // for some reason this method can throw "Not part of this compilation" argument exception
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var methodModel = new MethodModel(
|
||||||
|
// @params: decl.ParameterList.Parameters
|
||||||
|
// .Where(p => p.Type is not null)
|
||||||
|
// .Select(p =>
|
||||||
|
// {
|
||||||
|
// var prefix = p.Modifiers.Any(static x => x.IsKind(SyntaxKind.ParamsKeyword))
|
||||||
|
// ? "params "
|
||||||
|
// : string.Empty;
|
||||||
|
//
|
||||||
|
// var type = semanticModel
|
||||||
|
// .GetTypeInfo(p.Type!)
|
||||||
|
// .Type
|
||||||
|
// ?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// var name = p.Identifier.Text;
|
||||||
|
//
|
||||||
|
// var suffix = string.Empty;
|
||||||
|
// if (p.Default is not null)
|
||||||
|
// {
|
||||||
|
// if (p.Default.Value is LiteralExpressionSyntax)
|
||||||
|
// {
|
||||||
|
// suffix = " = " + p.Default.Value;
|
||||||
|
// }
|
||||||
|
// else if (p.Default.Value is MemberAccessExpressionSyntax maes)
|
||||||
|
// {
|
||||||
|
// var maesSemModel = comp.GetSemanticModel(maes.SyntaxTree);
|
||||||
|
// var sym = maesSemModel.GetSymbolInfo(maes.Name);
|
||||||
|
// if (sym.Symbol is null)
|
||||||
|
// {
|
||||||
|
// suffix = " = " + p.Default.Value;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// suffix = " = " + sym.Symbol.ToDisplayString();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return $"{prefix}{type} {name}{suffix}";
|
||||||
|
// })
|
||||||
|
// .ToList(),
|
||||||
|
// methodName: decl.Identifier.Text,
|
||||||
|
// returnType: decl.ReturnType.ToString(),
|
||||||
|
// ns: GetNamespace(decl),
|
||||||
|
// classes: GetClasses(decl)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// return methodModel;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //https://github.com/andrewlock/NetEscapades.EnumGenerators/blob/main/src/NetEscapades.EnumGenerators/EnumGenerator.cs
|
||||||
|
// static string? GetNamespace(MethodDeclarationSyntax declarationSyntax)
|
||||||
|
// {
|
||||||
|
// // determine the namespace the class is declared in, if any
|
||||||
|
// string? nameSpace = null;
|
||||||
|
// var parentOfInterest = declarationSyntax.Parent;
|
||||||
|
// while (parentOfInterest is not null)
|
||||||
|
// {
|
||||||
|
// parentOfInterest = parentOfInterest.Parent;
|
||||||
|
//
|
||||||
|
// if (parentOfInterest is BaseNamespaceDeclarationSyntax ns)
|
||||||
|
// {
|
||||||
|
// nameSpace = ns.Name.ToString();
|
||||||
|
// while (true)
|
||||||
|
// {
|
||||||
|
// if (ns.Parent is not NamespaceDeclarationSyntax parent)
|
||||||
|
// {
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ns = parent;
|
||||||
|
// nameSpace = $"{ns.Name}.{nameSpace}";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return nameSpace;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return nameSpace;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// static IReadOnlyCollection<string> GetClasses(MethodDeclarationSyntax declarationSyntax)
|
||||||
|
// {
|
||||||
|
// // determine the namespace the class is declared in, if any
|
||||||
|
// var classes = new LinkedList<string>();
|
||||||
|
// var parentOfInterest = declarationSyntax.Parent;
|
||||||
|
// while (parentOfInterest is not null)
|
||||||
|
// {
|
||||||
|
// if (parentOfInterest is ClassDeclarationSyntax cds)
|
||||||
|
// {
|
||||||
|
// classes.AddFirst(cds.Identifier.ToString());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// parentOfInterest = parentOfInterest.Parent;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Debug.WriteLine($"Method {declarationSyntax.Identifier.Text} has {classes.Count} classes");
|
||||||
|
//
|
||||||
|
// return classes;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static MethodDeclarationSyntax? Transform(GeneratorSyntaxContext ctx, CancellationToken cancel)
|
||||||
|
// {
|
||||||
|
// var methodDecl = ctx.Node as MethodDeclarationSyntax;
|
||||||
|
// if (methodDecl is null)
|
||||||
|
// return default;
|
||||||
|
//
|
||||||
|
// foreach (var attListSyntax in methodDecl.AttributeLists)
|
||||||
|
// {
|
||||||
|
// foreach (var attSyntax in attListSyntax.Attributes)
|
||||||
|
// {
|
||||||
|
// if (cancel.IsCancellationRequested)
|
||||||
|
// return default;
|
||||||
|
//
|
||||||
|
// var symbol = ctx.SemanticModel.GetSymbolInfo(attSyntax).Symbol;
|
||||||
|
// if (symbol is not IMethodSymbol attSymbol)
|
||||||
|
// continue;
|
||||||
|
//
|
||||||
|
// if (attSymbol.ContainingType.ToDisplayString() == "NadekoBot.Common.CmdAttribute")
|
||||||
|
// return methodDecl;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return default;
|
||||||
|
// }
|
||||||
|
// }
|
@@ -1,184 +0,0 @@
|
|||||||
#nullable enable
|
|
||||||
using System.CodeDom.Compiler;
|
|
||||||
using System.Collections.Immutable;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.CodeAnalysis;
|
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
||||||
using Microsoft.CodeAnalysis.Text;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace NadekoBot.Generators
|
|
||||||
{
|
|
||||||
public readonly record struct MethodPermData
|
|
||||||
{
|
|
||||||
public readonly ImmutableArray<(string Name, string Value)> MethodPerms;
|
|
||||||
public readonly ImmutableArray<string> NoAuthRequired;
|
|
||||||
|
|
||||||
public MethodPermData(ImmutableArray<(string Name, string Value)> methodPerms,
|
|
||||||
ImmutableArray<string> noAuthRequired)
|
|
||||||
{
|
|
||||||
MethodPerms = methodPerms;
|
|
||||||
NoAuthRequired = noAuthRequired;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[Generator]
|
|
||||||
public class GrpcApiPermGenerator : IIncrementalGenerator
|
|
||||||
{
|
|
||||||
public const string GRPC_API_PERM_ATTRIBUTE =
|
|
||||||
"""
|
|
||||||
namespace NadekoBot.GrpcApi;
|
|
||||||
|
|
||||||
[System.AttributeUsage(System.AttributeTargets.Method)]
|
|
||||||
public class GrpcApiPermAttribute : System.Attribute
|
|
||||||
{
|
|
||||||
public GuildPerm Value { get; }
|
|
||||||
public GrpcApiPermAttribute(GuildPerm value) => Value = value;
|
|
||||||
}
|
|
||||||
""";
|
|
||||||
|
|
||||||
public const string GRPC_NO_AUTH_REQUIRED_ATTRIBUTE =
|
|
||||||
"""
|
|
||||||
namespace NadekoBot.GrpcApi;
|
|
||||||
|
|
||||||
[System.AttributeUsage(System.AttributeTargets.Method)]
|
|
||||||
public class GrpcNoAuthRequiredAttribute : System.Attribute
|
|
||||||
{
|
|
||||||
}
|
|
||||||
""";
|
|
||||||
|
|
||||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
|
||||||
{
|
|
||||||
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("GrpcApiPermAttribute.cs",
|
|
||||||
SourceText.From(GRPC_API_PERM_ATTRIBUTE, Encoding.UTF8)));
|
|
||||||
|
|
||||||
context.RegisterPostInitializationOutput(ctx => ctx.AddSource("GrpcNoAuthRequiredAttribute.cs",
|
|
||||||
SourceText.From(GRPC_NO_AUTH_REQUIRED_ATTRIBUTE, Encoding.UTF8)));
|
|
||||||
|
|
||||||
var perms = context.SyntaxProvider
|
|
||||||
.ForAttributeWithMetadataName(
|
|
||||||
"NadekoBot.GrpcApi.GrpcApiPermAttribute",
|
|
||||||
predicate: static (s, _) => s is MethodDeclarationSyntax,
|
|
||||||
transform: static (ctx, _) => GetMethodSemanticTargets(ctx.SemanticModel, ctx.TargetNode))
|
|
||||||
.Where(static m => m is not null)
|
|
||||||
.Select(static (x, _) => x!.Value)
|
|
||||||
.Collect();
|
|
||||||
|
|
||||||
|
|
||||||
var all = context.SyntaxProvider
|
|
||||||
.ForAttributeWithMetadataName(
|
|
||||||
"NadekoBot.GrpcApi.GrpcNoAuthRequiredAttribute",
|
|
||||||
predicate: static (s, _) => s is MethodDeclarationSyntax,
|
|
||||||
transform: static (ctx, _) => GetNoAuthMethodName(ctx.SemanticModel, ctx.TargetNode))
|
|
||||||
.Collect()
|
|
||||||
.Combine(perms)
|
|
||||||
.Select((x, _) => new MethodPermData(x.Right, x.Left));
|
|
||||||
|
|
||||||
context.RegisterSourceOutput(all,
|
|
||||||
static (spc, source) => Execute(source, spc));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetNoAuthMethodName(SemanticModel model, SyntaxNode node)
|
|
||||||
=> ((MethodDeclarationSyntax)node).Identifier.Text;
|
|
||||||
|
|
||||||
private static (string Name, string Value)? GetMethodSemanticTargets(SemanticModel model, SyntaxNode node)
|
|
||||||
{
|
|
||||||
var method = (MethodDeclarationSyntax)node;
|
|
||||||
|
|
||||||
var name = method.Identifier.Text;
|
|
||||||
var attr = method.AttributeLists
|
|
||||||
.SelectMany(x => x.Attributes)
|
|
||||||
.FirstOrDefault();
|
|
||||||
|
|
||||||
if (attr is null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (name, attr.ArgumentList?.Arguments[0].ToString() ?? "__missing_perm__");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Execute(MethodPermData data, SourceProductionContext ctx)
|
|
||||||
{
|
|
||||||
using (var stringWriter = new StringWriter())
|
|
||||||
using (var sw = new IndentedTextWriter(stringWriter))
|
|
||||||
{
|
|
||||||
sw.WriteLine("using System.Collections.Frozen;");
|
|
||||||
sw.WriteLine();
|
|
||||||
sw.WriteLine("namespace NadekoBot.GrpcApi;");
|
|
||||||
sw.WriteLine();
|
|
||||||
|
|
||||||
sw.WriteLine("public partial class GrpcApiPermsInterceptor");
|
|
||||||
sw.WriteLine("{");
|
|
||||||
|
|
||||||
sw.Indent++;
|
|
||||||
|
|
||||||
sw.WriteLine(
|
|
||||||
"private static FrozenDictionary<string, GuildPerm> _perms = new Dictionary<string, GuildPerm>()");
|
|
||||||
sw.WriteLine("{");
|
|
||||||
|
|
||||||
sw.Indent++;
|
|
||||||
foreach (var field in data.MethodPerms)
|
|
||||||
{
|
|
||||||
sw.WriteLine("{{ \"{0}\", {1} }},", field.Name, field.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.Indent--;
|
|
||||||
sw.WriteLine("}.ToFrozenDictionary();");
|
|
||||||
|
|
||||||
sw.WriteLine();
|
|
||||||
sw.WriteLine("private static FrozenSet<string> _noAuthRequired = new HashSet<string>()");
|
|
||||||
sw.WriteLine("{");
|
|
||||||
|
|
||||||
sw.Indent++;
|
|
||||||
foreach (var noauth in data.NoAuthRequired)
|
|
||||||
{
|
|
||||||
sw.WriteLine("{{ \"{0}\" }},", noauth);
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.WriteLine("");
|
|
||||||
|
|
||||||
sw.Indent--;
|
|
||||||
sw.WriteLine("}.ToFrozenSet();");
|
|
||||||
|
|
||||||
sw.Indent--;
|
|
||||||
sw.WriteLine("}");
|
|
||||||
|
|
||||||
sw.Flush();
|
|
||||||
ctx.AddSource("GrpcApiInterceptor.g.cs", stringWriter.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<TranslationPair> GetFields(string? dataText)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(dataText))
|
|
||||||
return new();
|
|
||||||
|
|
||||||
Dictionary<string, string> data;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var output = JsonConvert.DeserializeObject<Dictionary<string, string>>(dataText!);
|
|
||||||
if (output is null)
|
|
||||||
return new();
|
|
||||||
|
|
||||||
data = output;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Debug.WriteLine("Failed parsing responses file.");
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
|
|
||||||
var list = new List<TranslationPair>();
|
|
||||||
foreach (var entry in data)
|
|
||||||
{
|
|
||||||
list.Add(new(
|
|
||||||
entry.Key,
|
|
||||||
entry.Value
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,6 +1,10 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.CodeDom.Compiler;
|
using System.CodeDom.Compiler;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.CodeAnalysis;
|
using Microsoft.CodeAnalysis;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -22,23 +26,24 @@ namespace NadekoBot.Generators
|
|||||||
[Generator]
|
[Generator]
|
||||||
public class LocalizedStringsGenerator : ISourceGenerator
|
public class LocalizedStringsGenerator : ISourceGenerator
|
||||||
{
|
{
|
||||||
// private const string LOC_STR_SOURCE = @"namespace NadekoBot
|
private const string LOC_STR_SOURCE = @"namespace NadekoBot
|
||||||
// {
|
{
|
||||||
// public readonly struct LocStr
|
public readonly struct LocStr
|
||||||
// {
|
{
|
||||||
// public readonly string Key;
|
public readonly string Key;
|
||||||
// public readonly object[] Params;
|
public readonly object[] Params;
|
||||||
//
|
|
||||||
// public LocStr(string key, params object[] data)
|
public LocStr(string key, params object[] data)
|
||||||
// {
|
{
|
||||||
// Key = key;
|
Key = key;
|
||||||
// Params = data;
|
Params = data;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }";
|
}";
|
||||||
|
|
||||||
public void Initialize(GeneratorInitializationContext context)
|
public void Initialize(GeneratorInitializationContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(GeneratorExecutionContext context)
|
public void Execute(GeneratorExecutionContext context)
|
||||||
@@ -50,7 +55,6 @@ namespace NadekoBot.Generators
|
|||||||
using (var stringWriter = new StringWriter())
|
using (var stringWriter = new StringWriter())
|
||||||
using (var sw = new IndentedTextWriter(stringWriter))
|
using (var sw = new IndentedTextWriter(stringWriter))
|
||||||
{
|
{
|
||||||
sw.WriteLine("#pragma warning disable CS8981");
|
|
||||||
sw.WriteLine("namespace NadekoBot;");
|
sw.WriteLine("namespace NadekoBot;");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
@@ -102,7 +106,7 @@ namespace NadekoBot.Generators
|
|||||||
context.AddSource("strs.g.cs", stringWriter.ToString());
|
context.AddSource("strs.g.cs", stringWriter.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// context.AddSource("LocStr.g.cs", LOC_STR_SOURCE);
|
context.AddSource("LocStr.g.cs", LOC_STR_SOURCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TranslationPair> GetFields(string? dataText)
|
private List<TranslationPair> GetFields(string? dataText)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user