Compare commits
No commits in common. "3.0.9" and "v6" have entirely different histories.
|
@ -1,16 +1,14 @@
|
||||||
# Ignore all files
|
# Ignore all files
|
||||||
*
|
*
|
||||||
|
|
||||||
# Use WizBot project
|
# Don't ignore nugetconfig
|
||||||
!src/WizBot/**
|
!./NuGet.Config
|
||||||
# Use WizBot.Coordinator project
|
|
||||||
!src/WizBot.Coordinator/**
|
# Don't ignore src projects
|
||||||
# Use Generators project
|
!src/**
|
||||||
!src/WizBot.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
|
||||||
src/**/bin/*
|
src/**/bin/*
|
||||||
src/**/obj/*
|
src/**/obj/*
|
||||||
|
src/NadekoBot/data/creds.yml
|
|
@ -0,0 +1,208 @@
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8-bom
|
||||||
|
end_of_line = crlf
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
insert_final_newline = false
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# Microsoft .NET properties
|
||||||
|
csharp_new_line_before_members_in_object_initializers = false
|
||||||
|
csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion
|
||||||
|
csharp_style_prefer_utf8_string_literals = true:suggestion
|
||||||
|
csharp_style_var_elsewhere = true:suggestion
|
||||||
|
csharp_style_var_for_built_in_types = true:suggestion
|
||||||
|
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||||
|
dotnet_naming_rule.constants_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.constants_rule.resharper_description = Constant fields (not private)
|
||||||
|
dotnet_naming_rule.constants_rule.resharper_guid = 669e5282-fb4b-4e90-91e7-07d269d04b60
|
||||||
|
dotnet_naming_rule.constants_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.constants_rule.style = all_upper_style
|
||||||
|
dotnet_naming_rule.constants_rule.symbols = constants_symbols
|
||||||
|
dotnet_naming_rule.interfaces_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.interfaces_rule.resharper_description = Interfaces
|
||||||
|
dotnet_naming_rule.interfaces_rule.resharper_guid = a7a3339e-4e89-4319-9735-a9dc4cb74cc7
|
||||||
|
dotnet_naming_rule.interfaces_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.interfaces_rule.style = i_upper_camel_case_style
|
||||||
|
dotnet_naming_rule.interfaces_rule.symbols = interfaces_symbols
|
||||||
|
dotnet_naming_rule.local_constants_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.local_constants_rule.resharper_description = Local constants
|
||||||
|
dotnet_naming_rule.local_constants_rule.resharper_guid = a4f433b8-abcd-4e55-a08f-82e78cef0f0c
|
||||||
|
dotnet_naming_rule.local_constants_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.local_constants_rule.style = all_upper_style
|
||||||
|
dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols
|
||||||
|
dotnet_naming_rule.private_constants_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.private_constants_rule.resharper_description = Constant fields (private)
|
||||||
|
dotnet_naming_rule.private_constants_rule.resharper_guid = 236f7aa5-7b06-43ca-bf2a-9b31bfcff09a
|
||||||
|
dotnet_naming_rule.private_constants_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_constants_rule.style = all_upper_style
|
||||||
|
dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule.resharper_description = Instance fields (private)
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule.resharper_guid = 4a98fdf6-7d98-4f5a-afeb-ea44ad98c70c
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style
|
||||||
|
dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols
|
||||||
|
dotnet_naming_rule.private_static_fields_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.private_static_fields_rule.resharper_description = Static fields (private)
|
||||||
|
dotnet_naming_rule.private_static_fields_rule.resharper_exclusive_prefixes_suffixes = true
|
||||||
|
dotnet_naming_rule.private_static_fields_rule.resharper_guid = f9fce829-e6f4-4cb2-80f1-5497c44f51df
|
||||||
|
dotnet_naming_rule.private_static_fields_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style
|
||||||
|
dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols
|
||||||
|
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.private_static_readonly_rule.resharper_description = Static readonly fields (private)
|
||||||
|
dotnet_naming_rule.private_static_readonly_rule.resharper_guid = 15b5b1f1-457c-4ca6-b278-5615aedc07d3
|
||||||
|
dotnet_naming_rule.private_static_readonly_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.private_static_readonly_rule.style = lower_camel_case_style
|
||||||
|
dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols
|
||||||
|
dotnet_naming_rule.type_parameters_rule.import_to_resharper = True
|
||||||
|
dotnet_naming_rule.type_parameters_rule.resharper_description = Type parameters
|
||||||
|
dotnet_naming_rule.type_parameters_rule.resharper_guid = 2c62818f-621b-4425-adc9-78611099bfcb
|
||||||
|
dotnet_naming_rule.type_parameters_rule.severity = suggestion
|
||||||
|
dotnet_naming_rule.type_parameters_rule.style = t_upper_camel_case_style
|
||||||
|
dotnet_naming_rule.type_parameters_rule.symbols = type_parameters_symbols
|
||||||
|
dotnet_naming_style.all_upper_style.capitalization = all_upper
|
||||||
|
dotnet_naming_style.all_upper_style.word_separator = _
|
||||||
|
dotnet_naming_style.i_upper_camel_case_style.capitalization = pascal_case
|
||||||
|
dotnet_naming_style.i_upper_camel_case_style.required_prefix = I
|
||||||
|
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
|
||||||
|
dotnet_naming_style.lower_camel_case_style.required_prefix = _
|
||||||
|
dotnet_naming_style.t_upper_camel_case_style.capitalization = pascal_case
|
||||||
|
dotnet_naming_style.t_upper_camel_case_style.required_prefix = T
|
||||||
|
dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
|
||||||
|
dotnet_naming_symbols.constants_symbols.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.constants_symbols.required_modifiers = const
|
||||||
|
dotnet_naming_symbols.constants_symbols.resharper_applicable_kinds = constant_field
|
||||||
|
dotnet_naming_symbols.constants_symbols.resharper_required_modifiers = any
|
||||||
|
dotnet_naming_symbols.interfaces_symbols.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.interfaces_symbols.applicable_kinds = interface
|
||||||
|
dotnet_naming_symbols.interfaces_symbols.resharper_applicable_kinds = interface
|
||||||
|
dotnet_naming_symbols.interfaces_symbols.resharper_required_modifiers = any
|
||||||
|
dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local
|
||||||
|
dotnet_naming_symbols.local_constants_symbols.required_modifiers = const
|
||||||
|
dotnet_naming_symbols.local_constants_symbols.resharper_applicable_kinds = local_constant
|
||||||
|
dotnet_naming_symbols.local_constants_symbols.resharper_required_modifiers = any
|
||||||
|
dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private
|
||||||
|
dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_constants_symbols.required_modifiers = const
|
||||||
|
dotnet_naming_symbols.private_constants_symbols.resharper_applicable_kinds = constant_field
|
||||||
|
dotnet_naming_symbols.private_constants_symbols.resharper_required_modifiers = any
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols.resharper_applicable_kinds = field,readonly_field
|
||||||
|
dotnet_naming_symbols.private_instance_fields_symbols.resharper_required_modifiers = instance
|
||||||
|
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private
|
||||||
|
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static
|
||||||
|
dotnet_naming_symbols.private_static_fields_symbols.resharper_applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_static_fields_symbols.resharper_required_modifiers = static
|
||||||
|
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private
|
||||||
|
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field
|
||||||
|
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = readonly,static
|
||||||
|
dotnet_naming_symbols.private_static_readonly_symbols.resharper_applicable_kinds = readonly_field
|
||||||
|
dotnet_naming_symbols.private_static_readonly_symbols.resharper_required_modifiers = static
|
||||||
|
dotnet_naming_symbols.type_parameters_symbols.applicable_accessibilities = *
|
||||||
|
dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter
|
||||||
|
dotnet_naming_symbols.type_parameters_symbols.resharper_applicable_kinds = type_parameter
|
||||||
|
dotnet_naming_symbols.type_parameters_symbols.resharper_required_modifiers = any
|
||||||
|
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
|
||||||
|
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
|
||||||
|
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
|
||||||
|
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||||
|
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||||
|
dotnet_style_qualification_for_event = false:suggestion
|
||||||
|
dotnet_style_qualification_for_field = false:suggestion
|
||||||
|
dotnet_style_qualification_for_method = false:suggestion
|
||||||
|
dotnet_style_qualification_for_property = false:suggestion
|
||||||
|
|
||||||
|
# ReSharper properties
|
||||||
|
resharper_autodetect_indent_settings = true
|
||||||
|
resharper_csharp_wrap_arguments_style = chop_if_long
|
||||||
|
resharper_force_attribute_style = join
|
||||||
|
resharper_formatter_off_tag = @formatter:off
|
||||||
|
resharper_formatter_on_tag = @formatter:on
|
||||||
|
resharper_formatter_tags_enabled = true
|
||||||
|
resharper_keep_existing_embedded_arrangement = false
|
||||||
|
resharper_keep_existing_expr_member_arrangement = false
|
||||||
|
resharper_method_or_operator_body = expression_body
|
||||||
|
resharper_object_creation_when_type_not_evident = target_typed
|
||||||
|
resharper_place_accessorholder_attribute_on_same_line = false
|
||||||
|
resharper_place_accessor_attribute_on_same_line = false
|
||||||
|
resharper_place_expr_method_on_single_line = false
|
||||||
|
resharper_place_expr_property_on_single_line = false
|
||||||
|
resharper_place_field_attribute_on_same_line = false
|
||||||
|
resharper_place_simple_embedded_statement_on_same_line = false
|
||||||
|
resharper_show_autodetect_configure_formatting_tip = false
|
||||||
|
resharper_use_indent_from_vs = false
|
||||||
|
resharper_wrap_before_arrow_with_expressions = true
|
||||||
|
|
||||||
|
# ReSharper inspection severities
|
||||||
|
resharper_arrange_constructor_or_destructor_body_highlighting = hint
|
||||||
|
resharper_arrange_method_or_operator_body_highlighting = suggestion
|
||||||
|
resharper_arrange_object_creation_when_type_evident_highlighting = none
|
||||||
|
resharper_arrange_redundant_parentheses_highlighting = suggestion
|
||||||
|
resharper_arrange_this_qualifier_highlighting = hint
|
||||||
|
resharper_arrange_type_member_modifiers_highlighting = none
|
||||||
|
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
|
||||||
|
resharper_built_in_type_reference_style_highlighting = hint
|
||||||
|
resharper_check_namespace_highlighting = none
|
||||||
|
resharper_class_never_instantiated_global_highlighting = hint
|
||||||
|
resharper_convert_to_primary_constructor_highlighting = none
|
||||||
|
resharper_convert_to_using_declaration_highlighting = warning
|
||||||
|
resharper_convert_type_check_pattern_to_null_check_highlighting = hint
|
||||||
|
resharper_empty_general_catch_clause_highlighting = none
|
||||||
|
resharper_function_never_returns_highlighting = suggestion
|
||||||
|
resharper_inconsistent_naming_highlighting = suggestion
|
||||||
|
resharper_invert_if_highlighting = none
|
||||||
|
resharper_lambda_expression_can_be_made_static_highlighting = hint
|
||||||
|
resharper_mvc_action_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_area_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_controller_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_masterpage_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_partial_view_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_template_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_view_component_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_view_component_view_not_resolved_highlighting = warning
|
||||||
|
resharper_mvc_view_not_resolved_highlighting = warning
|
||||||
|
resharper_non_readonly_member_in_get_hash_code_highlighting = suggestion
|
||||||
|
resharper_not_accessed_field_local_highlighting = suggestion
|
||||||
|
resharper_out_parameter_value_is_always_discarded_local_highlighting = suggestion
|
||||||
|
resharper_private_field_can_be_converted_to_local_variable_highlighting = suggestion
|
||||||
|
resharper_razor_assembly_not_resolved_highlighting = warning
|
||||||
|
resharper_redundant_anonymous_type_property_name_highlighting = suggestion
|
||||||
|
resharper_redundant_base_qualifier_highlighting = warning
|
||||||
|
resharper_redundant_pattern_parentheses_highlighting = none
|
||||||
|
resharper_redundant_record_class_keyword_highlighting = suggestion
|
||||||
|
resharper_replace_with_single_call_to_first_or_default_highlighting = hint
|
||||||
|
resharper_suggest_var_or_type_built_in_types_highlighting = hint
|
||||||
|
resharper_suggest_var_or_type_elsewhere_highlighting = hint
|
||||||
|
resharper_suggest_var_or_type_simple_types_highlighting = hint
|
||||||
|
resharper_unused_method_return_value_local_highlighting = suggestion
|
||||||
|
resharper_use_await_using_highlighting = warning
|
||||||
|
resharper_web_config_module_not_resolved_highlighting = warning
|
||||||
|
resharper_web_config_type_not_resolved_highlighting = warning
|
||||||
|
resharper_web_config_wrong_module_highlighting = warning
|
||||||
|
|
||||||
|
[{*.har,*.json,*.jsonc,*.postman_collection,*.postman_collection.json,*.postman_environment,*.postman_environment.json}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[{*.yaml,*.yml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[{*.bash,*.sh,*.zsh}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.proto]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{appxmanifest,asax,ascx,aspx,axaml,blockshader,build,cg,cginc,compute,cs,cshtml,dtd,fx,fxh,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,shaderFoundry,skin,urtshader,usf,ush,vb,xaml,xamlx,xoml,xsd}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
|
@ -0,0 +1,171 @@
|
||||||
|
name: CI/CD
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ v6 ]
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
pull_request:
|
||||||
|
branches: [ v6 ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOTNET_VERSION: '8.0.x'
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Run Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: dotnet test -c Release --verbosity normal
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Build Package
|
||||||
|
needs: test
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
runtime: [linux-x64, linux-arm64, win-x64, win-arm64, osx-x64, osx-arm64]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
run: |
|
||||||
|
dotnet publish -c Release -r ${{ matrix.runtime }} \
|
||||||
|
--self-contained \
|
||||||
|
-p:Version=${{ github.ref_name }} \
|
||||||
|
-o wiz-${{ matrix.runtime }} src/WizBot/WizBot.csproj
|
||||||
|
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: wiz-${{ matrix.runtime }}
|
||||||
|
path: wiz-${{ matrix.runtime }}
|
||||||
|
|
||||||
|
create-release:
|
||||||
|
name: Create Release
|
||||||
|
needs:
|
||||||
|
- build
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download all artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: 'wiz-*'
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Create archives
|
||||||
|
run: |
|
||||||
|
cd artifacts
|
||||||
|
for dir in */; do
|
||||||
|
runtime="${dir%/}"
|
||||||
|
if [[ "$runtime" == *"win"* ]]; then
|
||||||
|
zip -r "$runtime.zip" "$runtime"
|
||||||
|
else
|
||||||
|
chmod +x "$runtime/WizBot"
|
||||||
|
tar -czf "$runtime.tar.gz" "$runtime"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
name: Release ${{ github.ref_name }}
|
||||||
|
body: |
|
||||||
|
[Changelog](https://github.com/Wizkiller96/WizBot/blob/v6/CHANGELOG.md)
|
||||||
|
|
||||||
|
generate_release_notes: true
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
files: |
|
||||||
|
artifacts/*.zip
|
||||||
|
artifacts/*.tar.gz
|
||||||
|
|
||||||
|
docker:
|
||||||
|
name: Build and Push Docker image
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log into registry ${{ env.REGISTRY }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
context: .
|
||||||
|
tags: ghcr.io/wizkiller96/wizbot:latest,ghcr.io/wizkiller96/wizbot:v6,ghcr.io/wizkiller96/wizbot:${{ github.ref_name }}
|
||||||
|
|
||||||
|
publish-medusa-package:
|
||||||
|
name: Publish Medusa Package
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
|
- name: Set version
|
||||||
|
run: |
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
echo "MEDUSA_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
LAST_TAG=$(git describe --tags --abbrev=0)
|
||||||
|
echo "MEDUSA_VERSION=${LAST_TAG}-alpha${GITHUB_SHA::7}" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Pack and Push
|
||||||
|
working-directory: src/Wiz.Medusa
|
||||||
|
run: |
|
||||||
|
dotnet pack -c Release /p:Version=${{ env.MEDUSA_VERSION }} -o bin/Release/packed
|
||||||
|
dotnet nuget push bin/Release/packed/*.nupkg --source https://www.myget.org/F/wizbot/api/v2/package --api-key ${{ secrets.MYGET_API_KEY }}
|
||||||
|
continue-on-error: true
|
|
@ -0,0 +1,36 @@
|
||||||
|
name: Deploy WizBot Docs
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ["v6"]
|
||||||
|
paths:
|
||||||
|
- 'docs/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.12"
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: 'docs/mkdocs-requirements.txt'
|
||||||
|
|
||||||
|
- name: Install project dependencies
|
||||||
|
run: pip install -r docs/mkdocs-requirements.txt
|
||||||
|
|
||||||
|
- name: Build the site with MkDocs
|
||||||
|
working-directory: ./docs
|
||||||
|
run: mkdocs build --strict
|
||||||
|
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
working-directory: ./docs
|
||||||
|
run: mkdocs gh-deploy --force
|
|
@ -1,18 +1,18 @@
|
||||||
#Manually added files
|
#Manually added files
|
||||||
|
|
||||||
command_errors*.txt
|
src/WizBot/data/last_known_version.txt
|
||||||
|
|
||||||
|
# medusa stuff
|
||||||
|
src/WizBot/data/medusae/
|
||||||
|
|
||||||
|
# other
|
||||||
|
|
||||||
output/
|
output/
|
||||||
src/WizBot/output
|
src/WizBot/output
|
||||||
src/WizBot/creds.yml
|
src/WizBot/creds.yml
|
||||||
|
src/WizBot/data/creds.yml
|
||||||
src/WizBot/Command Errors*.txt
|
src/WizBot/Command Errors*.txt
|
||||||
|
src/WizBot/data/WizBot.db*
|
||||||
src/WizBot/creds.yml
|
|
||||||
# credentials file before and after migrations
|
|
||||||
src/WizBot/credentials.json
|
|
||||||
src/WizBot/old_credentials.json
|
|
||||||
src/WizBot/credentials.json.bak
|
|
||||||
src/WizBot/data/WizBot.db
|
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/visualstudio,visualstudiocode,windows,linux,macos
|
# Created by https://www.gitignore.io/api/visualstudio,visualstudiocode,windows,linux,macos
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ PublishScripts/
|
||||||
!**/packages/build/
|
!**/packages/build/
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
#!**/packages/repositories.config
|
#!**/packages/repositories.config
|
||||||
# NuGet v3's project.json files produces more ignoreable files
|
# NuGet v4's project.json files produces more ignoreable files
|
||||||
*.nuget.props
|
*.nuget.props
|
||||||
*.nuget.targets
|
*.nuget.targets
|
||||||
|
|
||||||
|
@ -363,3 +363,14 @@ __pycache__/
|
||||||
### VisualStudio Patch ###
|
### VisualStudio Patch ###
|
||||||
build/
|
build/
|
||||||
site/
|
site/
|
||||||
|
|
||||||
|
## AI
|
||||||
|
|
||||||
|
.aider.*
|
||||||
|
PROMPT.md
|
||||||
|
.*rules
|
||||||
|
|
||||||
|
## Python pip/env files
|
||||||
|
Pipfile
|
||||||
|
Pipfile.lock
|
||||||
|
.venv
|
||||||
|
|
125
.gitlab-ci.yml
|
@ -1,125 +0,0 @@
|
||||||
image: mcr.microsoft.com/dotnet/sdk:5.0
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- build
|
|
||||||
- test
|
|
||||||
- upload-builds
|
|
||||||
- release
|
|
||||||
- publish-windows
|
|
||||||
# - upload-windows-updater-release
|
|
||||||
|
|
||||||
variables:
|
|
||||||
project: "WizBot"
|
|
||||||
tests: "WizBot.Tests"
|
|
||||||
LINUX_X64_OUTPUT_DIR: "wizbot-linux-x64"
|
|
||||||
LINUX_X64_RELEASE: "$CI_COMMIT_TAG-linux-x64-build.tar"
|
|
||||||
WIN_X64_OUTPUT_DIR: "wizbot-windows-x64"
|
|
||||||
WIN_X64_RELEASE: "$CI_COMMIT_TAG-windows-x64-build.zip"
|
|
||||||
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/WizBot-build/${CI_COMMIT_TAG}"
|
|
||||||
INSTALLER_OUTPUT_DIR: "wizbot-installers/${CI_COMMIT_TAG}"
|
|
||||||
INSTALLER_FILE_NAME: "wizbot-setup-${CI_COMMIT_TAG}.exe"
|
|
||||||
|
|
||||||
build:
|
|
||||||
stage: build
|
|
||||||
script:
|
|
||||||
- "dotnet publish -c Release -r linux-x64 -o $LINUX_X64_OUTPUT_DIR src/WizBot/WizBot.csproj"
|
|
||||||
- "dotnet publish -c Release -r win7-x64 -o $WIN_X64_OUTPUT_DIR src/WizBot/WizBot.csproj"
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- "$LINUX_X64_OUTPUT_DIR/"
|
|
||||||
- "$WIN_X64_OUTPUT_DIR/"
|
|
||||||
|
|
||||||
upload-builds:
|
|
||||||
stage: upload-builds
|
|
||||||
image: alpine:latest
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
script:
|
|
||||||
- apk add --no-cache curl tar zip
|
|
||||||
- "tar cvf $LINUX_X64_RELEASE $LINUX_X64_OUTPUT_DIR/*"
|
|
||||||
- "zip -r $WIN_X64_RELEASE $WIN_X64_OUTPUT_DIR/*"
|
|
||||||
- |
|
|
||||||
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 $WIN_X64_RELEASE $PACKAGE_REGISTRY_URL/$WIN_X64_RELEASE
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_TAG
|
|
||||||
script:
|
|
||||||
- |
|
|
||||||
release-cli create --name "WizBot v$CI_COMMIT_TAG" --description "## [Changelog](https://gitlab.com/WizNet/WizBot/-/blob/v3/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\":\"${WIN_X64_RELEASE}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_X64_RELEASE}\"}"
|
|
||||||
|
|
||||||
test:
|
|
||||||
stage: test
|
|
||||||
variables:
|
|
||||||
tests_path: "src/$tests"
|
|
||||||
script:
|
|
||||||
- "cd $tests_path"
|
|
||||||
- "dotnet test"
|
|
||||||
|
|
||||||
publish-windows:
|
|
||||||
stage: publish-windows
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_TAG'
|
|
||||||
image: scottyhardy/docker-wine
|
|
||||||
before_script:
|
|
||||||
- choco install dotnet-5.0-runtime -y
|
|
||||||
- choco install dotnet-5.0-sdk -y
|
|
||||||
- choco install innosetup -y
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- "$INSTALLER_OUTPUT_DIR/$INSTALLER_FILE_NAME"
|
|
||||||
script:
|
|
||||||
- dotnet clean
|
|
||||||
- dotnet restore
|
|
||||||
- dotnet publish -c Release --runtime win7-x64 /p:Version=$CI_COMMIT_TAG src/WizBot
|
|
||||||
- $env:WIZBOT_INSTALL_VERSION = $CI_COMMIT_TAG
|
|
||||||
- iscc.exe "/O+" ".\exe_builder.iss"
|
|
||||||
tags:
|
|
||||||
- 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 "downloads/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 "downloads/bot/releases-v3.json" --acl public-read --body "releases-v3.json"
|
|
||||||
|
|
||||||
docker-build:
|
|
||||||
# Use the official docker image.
|
|
||||||
image: docker:latest
|
|
||||||
stage: build
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
before_script:
|
|
||||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
||||||
# Default branch leaves tag empty (= latest tag)
|
|
||||||
# All other branches are tagged with the escaped branch name (commit ref slug)
|
|
||||||
script:
|
|
||||||
- |
|
|
||||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
|
||||||
tag=""
|
|
||||||
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
|
|
||||||
else
|
|
||||||
tag=":$CI_COMMIT_REF_SLUG"
|
|
||||||
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
|
||||||
fi
|
|
||||||
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
|
|
||||||
- docker push "$CI_REGISTRY_IMAGE${tag}"
|
|
||||||
# Run this job in a branch where a Dockerfile exists
|
|
||||||
rules:
|
|
||||||
- if: $CI_COMMIT_BRANCH
|
|
||||||
exists:
|
|
||||||
- Dockerfile
|
|
|
@ -1,26 +0,0 @@
|
||||||
### Description
|
|
||||||
Write here a summary of the issue you're having.
|
|
||||||
|
|
||||||
### Version
|
|
||||||
- Write here whether you're using public WizBot or hosting one yourself.
|
|
||||||
- If you are hosting, write down:
|
|
||||||
- The bot version (run the command .stats on Discord).
|
|
||||||
- Your operating system and its version.
|
|
||||||
- If you are on Windows, tell us whether you're using the updater version or the source version.
|
|
||||||
- If you are on Linux or OSX, tell us if you're hosting with tmux or pm2 or any other solution for managing processes.
|
|
||||||
|
|
||||||
### Reproduction Steps
|
|
||||||
- Describe, in detail, the steps necessary to consistently reproduce the issue.
|
|
||||||
- Preferably write the entire procedure in step-by-step instructions.
|
|
||||||
|
|
||||||
### Expected Behavior
|
|
||||||
Write here the behavior you were expecting to get from the bot.
|
|
||||||
|
|
||||||
### Actual Behavior
|
|
||||||
Write here the behavior you actually got from the bot.
|
|
||||||
|
|
||||||
### Screenshots
|
|
||||||
Include here any relevant screenshot that illustrates the issue you're having or that might help pinpoint the cause of the bug.
|
|
||||||
|
|
||||||
### Notes
|
|
||||||
Write here anything else you want to say that wasn't covered on the previous topics.
|
|
|
@ -1 +0,0 @@
|
||||||
GitLab is for bug reports only.
|
|
|
@ -1,2 +0,0 @@
|
||||||
GitLab is for bug reports only.
|
|
||||||
Please, head over to our support server at https://wizbot.cc/discord and ask your question in the #help channel.
|
|
|
@ -1,19 +0,0 @@
|
||||||
### Description
|
|
||||||
Write here a summary of the change(s) you're proposing and why this merge request would be a necessary or a nice addition to the project.
|
|
||||||
|
|
||||||
### Changes Proposed
|
|
||||||
Describe, item by item, all changes you'd like to propose. Write them in a list, one proposition per line. For example:
|
|
||||||
|
|
||||||
- Adds `DoStuff()` method to service X.
|
|
||||||
- Changes `SomeMethod()` on service Y, so it can handle situation Z better.
|
|
||||||
- Added a try/catch *somewhere*, so an exception is not thrown on the console when *something* happens.
|
|
||||||
- Replaced `AMethod()` by `AnotherMethod()` in *some command* for performance reasons.
|
|
||||||
|
|
||||||
### Details
|
|
||||||
Elaborate on the major and minor changes you've made to the source code. Try to explain why you've done something in a certain way.
|
|
||||||
|
|
||||||
### Screenshots
|
|
||||||
If applicable, send us screenshots of the result of your changes.
|
|
||||||
|
|
||||||
### Notes
|
|
||||||
Write here additional considerations that weren't covered on the previous topics.
|
|
1137
CHANGELOG.md
61
Dockerfile
|
@ -1,42 +1,49 @@
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
|
# Build stage
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
WORKDIR /source
|
WORKDIR /source
|
||||||
|
|
||||||
|
# Copy the .csproj files for each project
|
||||||
|
COPY src/Wiz.Medusa/*.csproj src/Wiz.Medusa/
|
||||||
COPY src/WizBot/*.csproj src/WizBot/
|
COPY src/WizBot/*.csproj src/WizBot/
|
||||||
COPY src/WizBot.Coordinator/*.csproj src/WizBot.Coordinator/
|
COPY src/WizBot.Coordinator/*.csproj src/WizBot.Coordinator/
|
||||||
COPY src/WizBot.Generators/*.csproj src/WizBot.Generators/
|
COPY src/WizBot.Generators/*.csproj src/WizBot.Generators/
|
||||||
COPY src/ayu/Ayu.Discord.Voice/*.csproj src/ayu/Ayu.Discord.Voice/
|
COPY src/WizBot.Voice/*.csproj src/WizBot.Voice/
|
||||||
RUN dotnet restore src/WizBot/
|
COPY src/WizBot.GrpcApiBase/*.csproj src/WizBot.GrpcApiBase/
|
||||||
|
|
||||||
|
# Restore the dependencies for the WizBot project
|
||||||
|
RUN dotnet restore src/WizBot/ -r linux-musl-x64
|
||||||
|
|
||||||
|
# Copy the rest of the source code
|
||||||
COPY . .
|
COPY . .
|
||||||
WORKDIR /source/src/WizBot
|
|
||||||
RUN set -xe; \
|
|
||||||
dotnet --version; \
|
|
||||||
dotnet publish -c Release -o /app --no-restore; \
|
|
||||||
mv /app/data /app/data_init; \
|
|
||||||
rm -Rf libopus* libsodium* opus.* runtimes/win* runtimes/osx* runtimes/linux-arm* runtimes/linux-mips*; \
|
|
||||||
find /app -type f -exec chmod -x {} \; ;\
|
|
||||||
chmod +x /app/WizBot
|
|
||||||
|
|
||||||
# final stage/image
|
WORKDIR /source/src/WizBot
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:5.0-buster-slim
|
|
||||||
|
# Build for linux-musl-x64 runtime as the image is based on alpine
|
||||||
|
RUN dotnet publish -c Release -o /app --self-contained -r linux-musl-x64 --no-restore \
|
||||||
|
&& mv /app/data /app/data_init \
|
||||||
|
&& chmod +x /app/WizBot
|
||||||
|
|
||||||
|
# Final stage
|
||||||
|
FROM alpine:3.20
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN set -xe; \
|
# Music dependencies
|
||||||
useradd -m wizbot; \
|
ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux /usr/local/bin/yt-dlp
|
||||||
apt-get update; \
|
RUN apk add --no-cache ffmpeg libsodium
|
||||||
apt-get install -y libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 python3-pip sudo; \
|
|
||||||
update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1; \
|
# Required dependencies
|
||||||
echo 'Defaults>wizbot env_keep+="ASPNETCORE_* DOTNET_* WizBot_* shard_id total_shards TZ"' > /etc/sudoers.d/wizbot; \
|
# icu-libs is required for globalization
|
||||||
pip3 install --upgrade youtube-dl; \
|
RUN apk update; \
|
||||||
apt-get remove -y python3-pip; \
|
apk add --no-cache libstdc++ libgcc icu-libs libc6-compat \
|
||||||
chmod +x /usr/local/bin/youtube-dl
|
&& rm -rf /var/cache/apk/*;
|
||||||
|
|
||||||
COPY --from=build /app ./
|
COPY --from=build /app ./
|
||||||
COPY docker-entrypoint.sh /usr/local/sbin
|
COPY docker-entrypoint.sh /usr/local/sbin/
|
||||||
|
|
||||||
ENV shard_id=0
|
RUN rm /app/data_init/lib/libsodium.so \
|
||||||
ENV total_shards=1
|
&& ln -s /usr/lib/libsodium.so.26 /app/data_init/lib/libsodium.so
|
||||||
|
|
||||||
|
VOLUME [ "/app/data" ]
|
||||||
|
|
||||||
VOLUME [ "app/data" ]
|
|
||||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||||
CMD dotnet WizBot.dll "$shard_id" "$total_shards"
|
CMD [ "./WizBot" ]
|
||||||
|
|
|
@ -0,0 +1,619 @@
|
||||||
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
17
LICENSE.md
|
@ -1,7 +1,16 @@
|
||||||
Copyright 2021 WizNet
|
Copyright (C) 2025 NadekoBot
|
||||||
|
|
||||||
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:
|
- This program is dual licensed under AGPLv3 and Commercial license.
|
||||||
|
- You may purchase a commercial license to exempt yourself from some of the AGPLv3 obligations
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
If you're looking for a commercial license, please reach out to me.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Contact: br.eaker on Discord or nadekodiscordbot@gmail.com
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<configuration>
|
|
||||||
<packageSources>
|
|
||||||
<add key="Discord.Net" value="https://www.myget.org/F/discord-net/api/v3/index.json" />
|
|
||||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
||||||
<add key="Kwoth-myget" value="https://www.myget.org/F/kwoth/api/v3/index.json" />
|
|
||||||
</packageSources>
|
|
||||||
</configuration>
|
|
59
README.md
|
@ -1,19 +1,50 @@
|
||||||
# WizBot v3
|
# WizBot
|
||||||
|
|
||||||
## Repo Status
|
[](https://github.com/Wizkiller96/WizBot/actions/workflows/ci.yml)
|
||||||
|
|
||||||
[](https://gitlab.com/WizNet/WizBot/commits/v3)
|
WizBot is an open source Discord bot. It is written in C# and is built on .NET 8.
|
||||||
[](http://wizbot.readthedocs.io/en/v3/?badge=v3)
|
|
||||||
[](https://www.codefactor.io/repository/github/wizkiller96/wizbot)
|
|
||||||

|
|
||||||
[](https://discord.gg/0YNaDOYuD5QOpeNI)
|
|
||||||
|
|
||||||
## For Updates, Help and Guidelines
|
If you want to run your own instance of WizBot, please check out the [Self hosting Guides and Docs](https://docs.wizbot.cc).
|
||||||
|
|
||||||
| [](https://twitter.com/WizBot_Dev) | [](http://wizbot.readthedocs.io/en/v3/) |
|
If you have any questions, please visit our [Discord support server](https://wizbot.cc/discord).
|
||||||
| :--- | :--- |
|
|
||||||
| **Follow me on Twitter.** | **Read the Docs for self-hosting.** |
|
|
||||||
|
|
||||||
### Useful links
|
## Installation
|
||||||
- ❗ [2.x to v3 migration guide](https://wizbot.readthedocs.io/en/v3/guides/migration-guide/)
|
|
||||||
- [Self hosting Guides and Docs](https://wizbot.readthedocs.io/en/v3)
|
### Default option
|
||||||
|
|
||||||
|
You may want to consider using [WizBot Updater](https://github.com/Wizkiller96/wizbot-updater/releases) if you want to run bot on your PC.+
|
||||||
|
|
||||||
|
### Hosting on a linux server
|
||||||
|
|
||||||
|
If you want your bot to be online 24/7, you should [host it on a linux vps](https://docs.wizbot.cc/guides/linux-guide).
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
There is an official Docker image for a [simple setup](https://docs.wizbot.cc/guides/docker-guide/)
|
||||||
|
Short version:
|
||||||
|
```sh
|
||||||
|
docker run -d --name wizbot ghcr.io/wizkiller96/wizbot:v6 -e bot_token=YOUR_TOKEN_HERE -v "./data:/app/data" && docker logs -f --tail 500 wizbot
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing to WizBot
|
||||||
|
|
||||||
|
We love your input! We want to make contributing to this project as easy as possible, whether it's:
|
||||||
|
|
||||||
|
- Reporting a bug
|
||||||
|
- Discussing the current state of the code
|
||||||
|
- Submitting a fix
|
||||||
|
- Proposing new features
|
||||||
|
- Becoming a maintainer
|
||||||
|
|
||||||
|
### Contribution
|
||||||
|
|
||||||
|
By submitting code, content, or materials via pull request or similar means ("Contribution"), you irrevocably assign all
|
||||||
|
intellectual property rights (including copyright and patents) to WizBot Repository Owner and affirm you either:
|
||||||
|
|
||||||
|
- (a) own the Contribution outright, or
|
||||||
|
- (b) it is licensed under compatible terms permitting unrestricted relicensing.
|
||||||
|
|
||||||
|
You grant the WizBot Repository Owner perpetual, worldwide rights to use, modify, distribute, and sublicense the
|
||||||
|
Contribution under AGPLv3, a commercial license, or any other terms without compensation.
|
||||||
|
|
||||||
|
These terms survive termination of this agreement.
|
||||||
|
|
73
WizBot.sln
|
@ -10,78 +10,93 @@ ProjectSection(SolutionItems) = preProject
|
||||||
CHANGELOG.md = CHANGELOG.md
|
CHANGELOG.md = CHANGELOG.md
|
||||||
LICENSE.md = LICENSE.md
|
LICENSE.md = LICENSE.md
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
.gitlab-ci.yml = .gitlab-ci.yml
|
Dockerfile = Dockerfile
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WizBot", "src\WizBot\WizBot.csproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WizBot", "src\WizBot\WizBot.csproj", "{45EC1473-C678-4857-A544-07DFE0D0B478}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ayu", "ayu", "{6058FEDF-A318-4CD4-8F04-A7E8E7EC8874}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.Voice", "src\WizBot.Voice\WizBot.Voice.csproj", "{2F4CF6D6-0C2F-4944-B204-9508CDA53195}"
|
||||||
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}") = "WizBot.Tests", "src\WizBot.Tests\WizBot.Tests.csproj", "{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.Tests", "src\WizBot.Tests\WizBot.Tests.csproj", "{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.Coordinator", "src\WizBot.Coordinator\WizBot.Coordinator.csproj", "{AE9B7F8C-81D7-4401-83A3-643B38258374}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.Coordinator", "src\WizBot.Coordinator\WizBot.Coordinator.csproj", "{AE9B7F8C-81D7-4401-83A3-643B38258374}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.Generators", "src\WizBot.Generators\WizBot.Generators.csproj", "{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.VotesApi", "src\WizBot.VotesApi\WizBot.VotesApi.csproj", "{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.VotesApi", "src\WizBot.VotesApi\WizBot.VotesApi.csproj", "{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wiz.Medusa", "src\Wiz.Medusa\Wiz.Medusa.csproj", "{E685977E-31A4-46F4-A5D7-4E3E39E82E43}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.Generators", "src\WizBot.Generators\WizBot.Generators.csproj", "{92770AF3-83EE-49F1-A0BB-79124D19A13D}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WizBot.GrpcApiBase", "src\WizBot.GrpcApiBase\WizBot.GrpcApiBase.csproj", "{FB74B9EA-10B9-4542-ACB1-35523A95A587}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
GlobalWizBot|Any CPU = GlobalWizBot|Any CPU
|
GlobalNadeko|Any CPU = GlobalNadeko|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.GlobalWizBot|Any CPU.ActiveCfg = Release|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.GlobalNadeko|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.GlobalWizBot|Any CPU.Build.0 = Release|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.GlobalNadeko|Any CPU.Build.0 = Release|Any CPU
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.Build.0 = Release|Any CPU
|
{45EC1473-C678-4857-A544-07DFE0D0B478}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.GlobalWizBot|Any CPU.ActiveCfg = Debug|Any CPU
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.GlobalWizBot|Any CPU.Build.0 = Debug|Any CPU
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Release|Any CPU.Build.0 = Release|Any CPU
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.GlobalWizBot|Any CPU.ActiveCfg = Debug|Any CPU
|
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.GlobalWizBot|Any CPU.Build.0 = Debug|Any CPU
|
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Release|Any CPU.Build.0 = Release|Any CPU
|
{DB448DD4-C97F-40E9-8BD3-F605FF1FF833}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{AE9B7F8C-81D7-4401-83A3-643B38258374}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.GlobalWizBot|Any CPU.ActiveCfg = Debug|Any CPU
|
{AE9B7F8C-81D7-4401-83A3-643B38258374}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{AE9B7F8C-81D7-4401-83A3-643B38258374}.GlobalWizBot|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}.GlobalWizBot|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{3BC3BDF8-1A0B-45EB-AB2B-C0891D4D37B8}.GlobalWizBot|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}.GlobalWizBot|Any CPU.ActiveCfg = Debug|Any CPU
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.GlobalWizBot|Any CPU.Build.0 = Debug|Any CPU
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3BC82CFE-BEE7-451F-986B-17EDD1570C4F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{E685977E-31A4-46F4-A5D7-4E3E39E82E43}.GlobalNadeko|Any CPU.ActiveCfg = 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.Build.0 = Release|Any CPU
|
||||||
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FB74B9EA-10B9-4542-ACB1-35523A95A587}.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}
|
||||||
|
{92770AF3-83EE-49F1-A0BB-79124D19A13D} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{2F4CF6D6-0C2F-4944-B204-9508CDA53195} = {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}
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e;
|
|
||||||
|
|
||||||
data_init=/app/data_init
|
set -e
|
||||||
data=/app/data
|
|
||||||
|
|
||||||
# populate /app/data if empty
|
data_init="/app/data_init"
|
||||||
for i in $(ls $data_init)
|
data="/app/data"
|
||||||
do
|
|
||||||
if [ ! -e "$data/$i" ]; then
|
|
||||||
[ -f "$data_init/$i" ] && cp "$data_init/$i" "$data/$i"
|
|
||||||
[ -d "$data_init/$i" ] && cp -r "$data_init/$i" "$data/$i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# fix folder permissions
|
ls $data
|
||||||
chown -R wizbot:wizbot "$data"
|
# Merge data_init into data without overwrites.
|
||||||
|
# TODO: Barkranger will hopefull fix this, move for testing
|
||||||
|
cp -R -n $data_init/* $data
|
||||||
|
cp -n "$data_init/creds_example.yml" "$data/creds.yml"
|
||||||
|
|
||||||
# drop to regular user and launch command
|
ls $data
|
||||||
exec sudo -u wizbot "$@"
|
|
||||||
|
echo "Yt-dlp update"
|
||||||
|
# TODO: Update yt-dlp. It should not crash the entrypoint if ca-certificates is not installed
|
||||||
|
# yt-dlp -U
|
||||||
|
|
||||||
|
echo "Running WizBot"
|
||||||
|
exec "$@"
|
|
@ -1,31 +0,0 @@
|
||||||
# Readme for Commands List
|
|
||||||
|
|
||||||
## Bot Owner Only
|
|
||||||
|
|
||||||
- *Bot Owner Only* commands refer to the commands only the **owner** of the bot can use.
|
|
||||||
- *Bot Owner Only* commands do **not** refer to the owner of the **server**, just the owner of the **bot**.
|
|
||||||
- *Owner of the bot* is a person who is **hosting** their own bot, and their **ID** is inside of **creds.yml** file.
|
|
||||||
- You are **not** the bot **owner** if you invited the bot using our **Website** invite or other invitation links.
|
|
||||||
|
|
||||||
## Bot Owner & Bot Admin Only
|
|
||||||
|
|
||||||
- *Bot Owner & Bot Admin Only* commands refer to the commands only the **owner & admin** of the bot can use.
|
|
||||||
- *Bot Owner & Bot Admin Only* commands do **not** refer to the owner or admins of the **server**, just the owner & admin of the **bot**.
|
|
||||||
- *Admin of the bot* is a person who is has been given permission by the Bot Owner, to use certain commands a regular user can't. Bot Admins have the power to blacklist a user or unblacklist a user from using the bot. Bot Admin can be added by having their **ID** inside of **creds.yml** file.
|
|
||||||
|
|
||||||
## Music on the public WizBot
|
|
||||||
|
|
||||||
- In case you got WizBot in your server by the invitation from **GitHub**, **GitLab**, or our **Website** invite or **help (.h)**, music is disabled.
|
|
||||||
- Music is **disabled** due to large maintenance expenses
|
|
||||||
- If you want to have music module on your server, you will have to **host** the bot on your PC, or any of the external servers.
|
|
||||||
- How to **host** the bot, check the **guides** on the left side.
|
|
||||||
|
|
||||||
## Cherry Blossoms
|
|
||||||
|
|
||||||
- Cherry Blossoms is the **currency** of the public WizBot.
|
|
||||||
- Cherry Blossoms can be `.pick`ed after WizBot plants a flower randomly after `.gc` has been enabled on a channel
|
|
||||||
- You can give Cherry Blossoms to other users, using the command `.give X @person`.
|
|
||||||
- You can only give flowers you **own**.
|
|
||||||
- If you want to have **unlimited** number of flowers, you will have to **host** the bot.
|
|
||||||
- Commands `.award X @person` and `.take X @person` can only be used by the *bot owner*.
|
|
||||||
- If you `.plant` the flower, flower will be avaliable for everyone to `.pick` it. In that case you will **lose** the flower.
|
|
|
@ -1,66 +0,0 @@
|
||||||
# Config
|
|
||||||
`.config` is the new `.bce`, it gives you a fast and easy way to edit most bot settings/values. Use `.h .config` for explanation.
|
|
||||||
|
|
||||||
Use `.config` to see the list of editable config files
|
|
||||||
Use `.config <config-name>` to see the list of settable properties on that config
|
|
||||||
Use `.config <config-name> <setting>` to see the current value and description
|
|
||||||
Use `.config <config-name> <setting> value` to set a new value
|
|
||||||
|
|
||||||
All settings are only available if you edit `data/[config-name].yml` files manually.
|
|
||||||
If you edit the files manually, you can reload configuration with `.configreload <config-name>`
|
|
||||||
|
|
||||||
The list below is not complete. Use commands above to see up-to-date list for your version.
|
|
||||||
|
|
||||||
## XP
|
|
||||||
|
|
||||||
`txt.cooldown` - Sets a timeout value in which a user cannot gain any more xp from sent messages. ( Value is in minutes )
|
|
||||||
`txt.per_msg` - Sets a value for the amount of xp a user will receive from sending a message.
|
|
||||||
`voice.per_minute` - Sets how much xp a user will receive from being active in a voice channel.
|
|
||||||
`voice.max_minutes` - Restricts a users xp gain to a certain amount of time spent in a voice channel.
|
|
||||||
|
|
||||||
*more settings may be available in `data/xp.yml` file*
|
|
||||||
|
|
||||||
## Games
|
|
||||||
|
|
||||||
`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.
|
|
||||||
|
|
||||||
*more settings may be available in `data/games.yml` file*
|
|
||||||
|
|
||||||
## Bot
|
|
||||||
|
|
||||||
`color.ok` - Sets a hex color that will be shown on the side bar of a successful command.
|
|
||||||
`color.error` - Sets a hex color that will be shown on the side bar of an unsuccessful command.
|
|
||||||
`color.pending` - Sets a hex color that will be shown on the side bar of a command that is currently in progress.
|
|
||||||
`help.text` - The text a user is DM'd when they invoke the `.h` command.
|
|
||||||
`help.dmtext` - The text a user will receive when they DM the bot directly.
|
|
||||||
`console.type` - Sets the style in which commands will show up in your console, values: `Simple`, `Normal`, `None`.
|
|
||||||
`locale` - Sets your native bot language, run the `.langli` command in a Discord channel for a full list of language options.
|
|
||||||
`prefix` - Sets default prefix for your bot.
|
|
||||||
|
|
||||||
*more settings may be available in `data/bot.yml` file*
|
|
||||||
|
|
||||||
## Gambling
|
|
||||||
|
|
||||||
`currency.name` - Sets the name for your bot's currency.
|
|
||||||
`currency.sign` - Sets the icon for your currency.
|
|
||||||
`minbet` - Minimum amount users can bet
|
|
||||||
`maxbet` - Maximum amount users can bet. Set 0 for unlimited
|
|
||||||
`gen.min` - Sets the minimum amount that can be spawned with `.gc` active.
|
|
||||||
`gen.max` - Sets the maximum amount that can be spawned with `.gc` active.
|
|
||||||
`gen.cd` - Sets a cooldown on how often a flower can spawn with `.gc` active ( Value is in seconds ).
|
|
||||||
`gen.chance` - Sets the likelihood that flowers will spawn with `.gc`. Value: ( 0.02 = 2% | 1 + 100% ).
|
|
||||||
`gen.has_pw` - Toggles wether the generated flowers will have a password at the top left of the image. Value: `true` or `false`
|
|
||||||
`bf.multi` - Sets the amount fo currency a user will win off of a winning a bet flip.
|
|
||||||
`waifu.min_price` - Sets the minimum price a user must pay to claim a user as their waifu.
|
|
||||||
`waifu.multi.reset` - Sets a multiplier for the `.waifureset` command.
|
|
||||||
`waifu.multi.crush_claim` - Sets a discount for a user that is claiming another user that has their affinity set to them.
|
|
||||||
`waifu.multi.normal_claim` - Amount a user would have to spend to claim a waifu with no affinity set.
|
|
||||||
`waifu.multi.divorce_value` - Sets how much a user would get if they divorce a waifu.
|
|
||||||
`waifu.multi.all_gifts` - Sets how much of a gifts value will be added to the value of the gifted waifu.
|
|
||||||
`waifu.multi.gift_effect` - Sets a bonus amount that a waifu will receive if they have their affinity set to the gifter.
|
|
||||||
`decay.percent` - Sets the percentage to decay all users currency daily.
|
|
||||||
`decay.maxdecay` - Sets the maximum a amount that a user's currency can decay in a day.
|
|
||||||
`decay.threshold` - Sets the minimum amount that a user must have to be eligible to receive a decay.
|
|
||||||
|
|
||||||
*more settings may be available in `data/gambling.yml` file*
|
|
|
@ -1,7 +0,0 @@
|
||||||
# How to contribute
|
|
||||||
|
|
||||||
1. Make Merge Requests to the [**v3 branch**](https://github.com/Wizkiller96/WizBot/tree/v3)
|
|
||||||
2. Keep a single Merge Request to a single feature
|
|
||||||
3. Fill out the MR template
|
|
||||||
|
|
||||||
Thanks for all your help ^\_^
|
|
|
@ -1,59 +0,0 @@
|
||||||
## Creds Guide
|
|
||||||
|
|
||||||
This document aims to guide you through the process of creating a Discord account for your bot
|
|
||||||
(the Discord Bot application), and inviting that account into your Discord server.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- Go to [the Discord developer application page][DiscordApp].
|
|
||||||
- Log in with your Discord account.
|
|
||||||
- Click **New Application**.
|
|
||||||
- Fill out the `Name` field however you like.
|
|
||||||
- Go to the **Bot** tab on the left sidebar.
|
|
||||||
- Click on the `Add a Bot` button and confirm that you do want to add a bot to this app.
|
|
||||||
- **Optional:** Add bot's avatar and description.
|
|
||||||
- Copy your Token to `creds.yml` as shown above.
|
|
||||||
- Scroll down to the `Privileged Gateway Intents` section and enable both intents.
|
|
||||||
These are required for a number of features to function properly, and should both be on.
|
|
||||||
|
|
||||||
##### Getting Owner ID*(s)*:
|
|
||||||
|
|
||||||
- Go to your Discord server and attempt to mention yourself, but put a backslash at the start
|
|
||||||
*(to make it slightly easier, add the backslash after the mention has been typed)*.
|
|
||||||
- For example, the message `\@fearnlj01#3535` will appear as `<@145521851676884992>` after you send the message.
|
|
||||||
- The message will appear as a mention if done correctly. Copy the numbers from it **`145521851676884992`** and replace the big number on the `OwnerIds` section with your user ID.
|
|
||||||
- Save the `creds.yml` file.
|
|
||||||
- If done correctly, you should now be the bot owner. You can add multiple owners by adding them below the first one. Indentation matters.
|
|
||||||
|
|
||||||
For a single owner, it should look like this:
|
|
||||||
|
|
||||||
```yml
|
|
||||||
OwnerIds:
|
|
||||||
- 105635576866156544
|
|
||||||
```
|
|
||||||
|
|
||||||
For multiple owners, it should look like this (pay attention to the commas, the last ID should **never** have a comma next to it):
|
|
||||||
|
|
||||||
```yml
|
|
||||||
OwnerIds:
|
|
||||||
- 105635123466156544
|
|
||||||
- 145521851676884992
|
|
||||||
- 341420590009417729
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Inviting your bot to your server
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- On the **General Information** tab, copy your `Application ID` from your [applications page][DiscordApp].
|
|
||||||
- Replace the `YOUR_CLIENT_ID_HERE` in this link:
|
|
||||||
`https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=66186303` with your `Client ID`
|
|
||||||
- The link should now look something like this:
|
|
||||||
`https://discordapp.com/oauth2/authorize?client_id=123123123123&scope=bot&permissions=66186303`
|
|
||||||
- Access that newly created link, pick your Discord server, click `Authorize` and confirm with the captcha at the end
|
|
||||||
- The bot should now be in your server
|
|
||||||
|
|
||||||
That's it! You may now go back to the installation guide you were following before 🎉
|
|
||||||
|
|
||||||
[DiscordApp]: https://discordapp.com/developers/applications/me
|
|
|
@ -1,44 +0,0 @@
|
||||||
## Custom Reactions / Expressions
|
|
||||||
|
|
||||||
### Important
|
|
||||||
|
|
||||||
- For modifying **global** custom reactions, the ones which will work across all the servers your bot is connected to, you **must** be a Bot Owner.
|
|
||||||
You must also use the commands for adding, deleting and listing these reactions in a direct message with the bot.
|
|
||||||
- For modifying **local** custom reactions, the ones which will only work on the server that they are added on, it is required to have the **Administrator** permission.
|
|
||||||
You must also use the commands for adding, deleting and listing these reactions in the server you want the custom reactions to work on.
|
|
||||||
|
|
||||||
### Commands and Their Use
|
|
||||||
|
|
||||||
| Command Name | Description | Example |
|
|
||||||
| :----------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- |
|
|
||||||
| `.acr` | Add a custom reaction with a trigger and a response. Running this command in a server requries the Administrator permission. Running this command in DM is Bot Owner only, and adds a new global custom reaction. | `.acr "hello" Hi there, %user%!` |
|
|
||||||
| `.lcr` | Lists a page of global or server custom reactions (15 reactions per page). Running this command in a DM will list the global custom reactions, while running it in a server will list that server's custom reactions. | `.lcr 1` |
|
|
||||||
| `.dcr` | Deletes a custom reaction based on the provided index. Running this command in a server requires the Administrator permission. Running this command in DM is Bot Owner only, and will delete a global custom reaction. | `.dcr 5` |
|
|
||||||
|
|
||||||
#### Now that we know the commands let's take a look at an example of adding a command with `.acr`,
|
|
||||||
|
|
||||||
`.acr "Nice Weather" It sure is, %user%!`
|
|
||||||
|
|
||||||
This command can be split into two different arguments:
|
|
||||||
|
|
||||||
- The trigger, `"Nice Weather"`
|
|
||||||
- And the response, `It sure is, %user%!`
|
|
||||||
|
|
||||||
An important thing to note about the triger is that, to be more than one word, we had to wrap it with quotation marks, `"Like this"` otherwise, only the first word would have been recognised as the trigger, and the second word would have been recognised as part of the response.
|
|
||||||
|
|
||||||
There's no special requirement for the formatting of the response, so we could just write it in exactly the same way we want it to respond, albeit with a placeholder - which will be explained in this next section.
|
|
||||||
|
|
||||||
Now, if that command was ran in a server, anyone on that server can make the bot mention them, saying `It sure is, @Username` anytime they say "Nice Weather". If the command is ran in a direct message with the bot, then the custom reaction can be used on every server the bot is connected to.
|
|
||||||
|
|
||||||
### Block global Custom Reactions
|
|
||||||
|
|
||||||
If you want to disable a global custom reaction which you do not like, and you do not want to remove it, or you are not the bot owner, you can do so by adding a new Custom Reaction with the same trigger on your server, and set the response to `-`.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
`.acr /o/ -`
|
|
||||||
|
|
||||||
Now if you try to trigger `/o/`, it won't print anything even if there is a global custom reaction with the same name.
|
|
||||||
|
|
||||||
### Placeholders!
|
|
||||||
|
|
||||||
To learn about placeholders, go [here](placeholders.md)
|
|
|
@ -1,35 +0,0 @@
|
||||||
# Setting up WizBot with Docker
|
|
||||||
|
|
||||||
# DO NOT USE YET - WORK IN PROGRESS
|
|
||||||
|
|
||||||
Upgrade from 2.x to v3 does not work because the file is mount readonly
|
|
||||||
|
|
||||||
### Docker Compose
|
|
||||||
```yml
|
|
||||||
version: "3.7"
|
|
||||||
services:
|
|
||||||
nadeko:
|
|
||||||
image: registry.gitlab.com/wiznet/wizbot:v3
|
|
||||||
depends_on:
|
|
||||||
- redis
|
|
||||||
environment:
|
|
||||||
TZ: Europe/Paris
|
|
||||||
#WizBot_RedisOptions: redis,name=wizbot
|
|
||||||
#WizBot_ShardRunCommand: dotnet
|
|
||||||
#WizBot_ShardRunArguments: /app/WizBot.dll {0} {1}
|
|
||||||
volumes:
|
|
||||||
- /srv/wizbot/conf/creds.yml:/app/creds.yml:ro
|
|
||||||
- /srv/wizbot/data:/app/data
|
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:4-alpine
|
|
||||||
sysctls:
|
|
||||||
- net.core.somaxconn=511
|
|
||||||
command: redis-server --maxmemory 32M --maxmemory-policy volatile-lru
|
|
||||||
volumes:
|
|
||||||
- /srv/wizbot/redis-data:/data
|
|
||||||
```
|
|
||||||
### Updating
|
|
||||||
- `cd /srv/wizbot`
|
|
||||||
- `docker-compose pull`
|
|
||||||
- `docker-compose up -d`
|
|
|
@ -1,246 +0,0 @@
|
||||||
## Migration from 2.x
|
|
||||||
|
|
||||||
##### ⚠ If you're already hosting WizBot, _You **MUST** update to latest version of 2.x and **run your bot at least once**_ before switching over to v3.
|
|
||||||
|
|
||||||
#### [Linux migration instructions](../migration-guide/#linux)
|
|
||||||
|
|
||||||
## Linux From Source
|
|
||||||
|
|
||||||
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 ~`)
|
|
||||||
|
|
||||||
##### Installation Instructions
|
|
||||||
|
|
||||||
1. Download and run the **new** installer script `cd ~ && wget -N https://github.com/Wizkiller96/wizbot-bash-installer/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
|
||||||
2. Install prerequisites (type `1` and press enter)
|
|
||||||
3. Download the bot (type `2` and press enter)
|
|
||||||
4. Exit the installer in order to set up your `creds.yml`
|
|
||||||
5. Copy the creds.yml template `cp wizbot/output/creds_example.yml wizbot/output/creds.yml`
|
|
||||||
6. Open `wizbot/output/creds.yml` with your favorite text editor. We will use nano here
|
|
||||||
- `nano wizbot/output/creds.yml`
|
|
||||||
7. [Enter your bot's token](../../creds-guide)
|
|
||||||
- After you're done, you can close nano (and save the file) by inputting, in order
|
|
||||||
- `CTRL` + `X`
|
|
||||||
- `Y`
|
|
||||||
- `Enter`
|
|
||||||
8. Run the bot (type `3` and press enter)
|
|
||||||
|
|
||||||
##### Update Instructions
|
|
||||||
|
|
||||||
1. ⚠ Stop the bot
|
|
||||||
2. Update and run the **new** installer script `cd ~ && wget -N https://github.com/Wizkiller96/wizbot-bash-installer/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
|
||||||
3. Update the bot (type `2` and press enter)
|
|
||||||
4. Run the bot (type `3` and press enter)
|
|
||||||
5. 🎉
|
|
||||||
|
|
||||||
## Linux Release
|
|
||||||
|
|
||||||
##### Installation Instructions
|
|
||||||
|
|
||||||
1. Download the latest release from <https://github.com/Wizkiller96/WizBot/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
|
|
||||||
2. Untar it
|
|
||||||
- ⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
|
||||||
- `tar xf X.XX.X-linux-x64-build.tar`
|
|
||||||
3. Rename the `wizbot-linux-x64` to `wizbot`
|
|
||||||
- `mv wizbot-linux-x64 wizbot`
|
|
||||||
4. Move into wizbot directory and make WizBot executable
|
|
||||||
- `cd wizbot && chmod +x WizBot`
|
|
||||||
5. Copy the creds.yml template
|
|
||||||
- `cp creds_example.yml creds.yml`
|
|
||||||
6. Open `creds.yml` with your favorite text editor. We will use nano here
|
|
||||||
- `nano wizbot/output/creds.yml`
|
|
||||||
8. [Enter your bot's token](#creds-guide)
|
|
||||||
- After you're done, you can close nano (and save the file) by inputting, in order
|
|
||||||
- `CTRL` + `X`
|
|
||||||
- `Y`
|
|
||||||
- `Enter`
|
|
||||||
9. Run the bot
|
|
||||||
- `./WizBot`
|
|
||||||
|
|
||||||
##### Update Instructions
|
|
||||||
|
|
||||||
1. Stop the bot
|
|
||||||
2. Download the latest release from <https://github.com/Wizkiller96/WizBot/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
|
|
||||||
3. Untar it
|
|
||||||
- ⚠ Make sure that you change `X.X.X` to the same series of numbers as in step 2!
|
|
||||||
- `tar xf x.x.x-linux-x64-build.tar`
|
|
||||||
4. Rename the old wizbot directory to wizbot-old (remove your old backup first if you have one, or back it up under a different name)
|
|
||||||
- `rm -rf wizbot-old 2>/dev/null`
|
|
||||||
- `mv wizbot wizbot-old`
|
|
||||||
5. Rename the new wizbot directory to wizbot
|
|
||||||
- `mv wizbot-linux-x64 wizbot`
|
|
||||||
6. Remove old strings and aliases to avoid overwriting the updated versions of those files
|
|
||||||
- ⚠ If you've modified said files, back them up instead
|
|
||||||
- `rm wizbot-old/data/aliases.yml`
|
|
||||||
- `rm -r wizbot-old/data/strings`
|
|
||||||
7. Copy old data
|
|
||||||
- `cp -RT wizbot-old/data/ wizbot/data`
|
|
||||||
8. Copy creds.yml
|
|
||||||
- `cp wizbot-old/creds.yml wizbot/`
|
|
||||||
9. Move into wizbot directory and make the WizBot executable
|
|
||||||
- `cd wizbot && chmod +x WizBot`
|
|
||||||
10. Run the bot
|
|
||||||
- `./WizBot`
|
|
||||||
|
|
||||||
🎉 Enjoy
|
|
||||||
|
|
||||||
##### Steps 3 - 9 as a single command
|
|
||||||
|
|
||||||
Don't forget to change X.XX.X to match step 2.
|
|
||||||
```sh
|
|
||||||
tar xf X.XX.X-linux-x64-build.tar && \
|
|
||||||
rm -rf wizbot-old 2>/dev/null && \
|
|
||||||
mv wizbot wizbot-old && \
|
|
||||||
mv wizbot-linux-x64 wizbot && \
|
|
||||||
rm wizbot-old/data/aliases.yml && \
|
|
||||||
rm -r wizbot-old/data/strings && \
|
|
||||||
cp -RT wizbot-old/data/ wizbot/data && \
|
|
||||||
cp wizbot-old/creds.yml wizbot/ && \
|
|
||||||
cd wizbot && chmod +x WizBot
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running WizBot
|
|
||||||
|
|
||||||
While there are two run modes built into the installer, these options only run WizBot within the current session. Below are 3 methods of running WizBot as a background process.
|
|
||||||
|
|
||||||
### Tmux (Preferred Method)
|
|
||||||
|
|
||||||
Using `tmux` is the simplest method, and is therefore recommended for most users.
|
|
||||||
|
|
||||||
1. Start a tmux session:
|
|
||||||
- `tmux`
|
|
||||||
2. Navigate to the project's root directory
|
|
||||||
- Project root directory location example: `/home/user/wizbot/`
|
|
||||||
3. Enter the `output` directory:
|
|
||||||
- `cd output`
|
|
||||||
4. Run the bot using:
|
|
||||||
- `dotnet WizBot.dll`
|
|
||||||
5. Detatch the tmux session:
|
|
||||||
- Press `Ctrl` + `B`
|
|
||||||
- Then press `D`
|
|
||||||
|
|
||||||
WizBot 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`.
|
|
||||||
|
|
||||||
### Systemd
|
|
||||||
|
|
||||||
Compared to using tmux, this method requires a little bit more work to set up, but has the benefit of allowing WizBot to automatically start back up after a system reboot or the execution of the `.die` command.
|
|
||||||
|
|
||||||
1. Navigate to the project's root directory
|
|
||||||
- Project root directory location example: `/home/user/wizbot/`
|
|
||||||
2. Use the following command to create a service that will be used to start WizBot:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
echo "[Unit]
|
|
||||||
Description=WizBot service
|
|
||||||
After=network.target
|
|
||||||
StartLimitIntervalSec=60
|
|
||||||
StartLimitBurst=2
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=$USER
|
|
||||||
WorkingDirectory=$PWD/output
|
|
||||||
# If you want WizBot to be compiled prior to every startup, uncomment the lines
|
|
||||||
# below. Note that it's not neccessary unless you are personally modifying the
|
|
||||||
# source code.
|
|
||||||
#ExecStartPre=/usr/bin/dotnet build ../src/WizBot/WizBot.csproj -c Release -o output/
|
|
||||||
ExecStart=/usr/bin/dotnet WizBot.dll
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=5
|
|
||||||
StandardOutput=syslog
|
|
||||||
StandardError=syslog
|
|
||||||
SyslogIdentifier=WizBot
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/wizbot.service
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Make the new service available:
|
|
||||||
- `sudo systemctl daemon-reload`
|
|
||||||
4. Start WizBot:
|
|
||||||
- `sudo systemctl start wizbot.service && sudo systemctl enable wizbot.service`
|
|
||||||
|
|
||||||
|
|
||||||
### Systemd + Script
|
|
||||||
|
|
||||||
This method is similar to the one above, but requires one extra step, with the added benefit of better error logging and control over what happens before and after the startup of WizBot.
|
|
||||||
|
|
||||||
1. Locate the project and move to its parent directory
|
|
||||||
- Project location example: `/home/user/wizbot/`
|
|
||||||
- Parent directory example: `/home/user/`
|
|
||||||
2. Use the following command to create a service that will be used to execute `WizBotRun.sh`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
echo "[Unit]
|
|
||||||
Description=WizBot service
|
|
||||||
After=network.target
|
|
||||||
StartLimitIntervalSec=60
|
|
||||||
StartLimitBurst=2
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
User=$USER
|
|
||||||
WorkingDirectory=$_WORKING_DIR
|
|
||||||
ExecStart=/bin/bash WizBotRun.sh
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=5
|
|
||||||
StandardOutput=syslog
|
|
||||||
StandardError=syslog
|
|
||||||
SyslogIdentifier=WizBot
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/wizbot.service
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Make the new service available:
|
|
||||||
- `sudo systemctl daemon-reload`
|
|
||||||
4. Use the following command to create a script that will be used to start WizBot:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
{
|
|
||||||
echo '#!/bin/bash'
|
|
||||||
echo ""
|
|
||||||
echo "echo \"Running WizBot in the background with auto restart\"
|
|
||||||
youtube-dl -U
|
|
||||||
|
|
||||||
# If you want WizBot to be compiled prior to every startup, uncomment the lines
|
|
||||||
# below. Note that it's not necessary unless you are personally modifying the
|
|
||||||
# source code.
|
|
||||||
#echo \"Compiling WizBot...\"
|
|
||||||
#cd \"$PWD\"/wizbot
|
|
||||||
#dotnet build src/WizBot/WizBot.csproj -c Release -o output/
|
|
||||||
|
|
||||||
echo \"Starting WizBot...\"
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
if [[ -d $PWD/wizbot/output ]]; then
|
|
||||||
cd $PWD/wizbot/output || {
|
|
||||||
echo \"Failed to change working directory to $PWD/wizbot/output\" >&2
|
|
||||||
echo \"Ensure that the working directory inside of '/etc/systemd/system/wizbot.service' is correct\"
|
|
||||||
echo \"Exiting...\"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo \"$PWD/wizbot/output doesn't exist\"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotnet WizBot.dll || {
|
|
||||||
echo \"An error occurred when trying to start WizBot\"
|
|
||||||
echo \"Exiting...\"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo \"Waiting for 5 seconds...\"
|
|
||||||
sleep 5
|
|
||||||
youtube-dl -U
|
|
||||||
echo \"Restarting WizBot...\"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo \"Stopping WizBot...\""
|
|
||||||
} > WizBotRun.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Start WizBot:
|
|
||||||
- `sudo systemctl start wizbot.service && sudo systemctl enable wizbot.service`
|
|
|
@ -1,66 +0,0 @@
|
||||||
# Migration instructions (2.x to v3)
|
|
||||||
|
|
||||||
## Windows
|
|
||||||
|
|
||||||
1. Run your WizBot Updater first, and **make sure your bot is updated to at least 2.46.5**
|
|
||||||
- **Run your 2.46.5 Bot** and make sure it works, and then **stop it**
|
|
||||||
- Close your old WizBot Updater
|
|
||||||
2. Get the new WizBot v3 Updater [here](https://wizbot.cc/downloads/v3) **Currently not available**
|
|
||||||
3. Click on the + icon to add a new bot
|
|
||||||
4. Next to the path, click on the folder icon and select the folder where your 2.46.5 bot is
|
|
||||||
- ℹ In case you're not sure where it's located, you can open your old updater and see it
|
|
||||||
5. If you've selected the correct path, you should have an **Update** button available, click it
|
|
||||||
6. You're done; you can now run your bot, and you can uninstall your old updater if you no longer have 2.x bots
|
|
||||||
7. 🎉
|
|
||||||
|
|
||||||
## Linux
|
|
||||||
|
|
||||||
1. In order to migrate a bot hosted on **Linux**, first update your current version to the latest 2.x version using the 2.x installer, run the bot, and make sure it works. Then:
|
|
||||||
- Run the **old** installer with `cd ~ && wget -N https://github.com/Wizkiller96/WizBot-BashScript/raw/1.9/linuxAIO.sh && bash linuxAIO.sh`
|
|
||||||
- Run option **1** again
|
|
||||||
- You **MUST** Run the bot now to ensure database is ready for migration
|
|
||||||
- Type `.stats` and ensure the version is `2.46.5` or later
|
|
||||||
- Stop the bot
|
|
||||||
2. Make sure your bot's folder is called `WizBot`
|
|
||||||
- Run `cd ~ && ls`
|
|
||||||
- Confirm there is a folder called WizBot (not wizbot, in all lowercase)
|
|
||||||
3. Migrate your bot's data using the new installer:
|
|
||||||
- Run the **new** installer `cd ~ && wget -N https://github.com/Wizkiller96/wizbot-bash-installer/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
|
||||||
- The installer should notify you that your data is ready for migration in a message above the menu.
|
|
||||||
- Install prerequisites (type `1` and press enter), and make sure it is successful
|
|
||||||
- Download WizBot v3 (type `2` and press enter)
|
|
||||||
- Run the bot (type `3` and press enter)
|
|
||||||
4. Make sure your permissions, custom reactions, credentials, and other data is preserved
|
|
||||||
- `.stats` to ensure owner id (credentials) is correct
|
|
||||||
- `.lcr` to see custom reactions
|
|
||||||
- `.lp` to list permissions
|
|
||||||
5. 🎉 Enjoy. If you want to learn how to update the bot, click [here](../linux-guide/#update-instructions)
|
|
||||||
|
|
||||||
## Manual
|
|
||||||
|
|
||||||
⚠ NOT RECOMMENDED
|
|
||||||
⚠ WizBot v3 requires [.net 5](https://dotnet.microsoft.com/download/dotnet/5.0)
|
|
||||||
|
|
||||||
1. In order to migrate a bot hosted **on Linux or from source on Windows**
|
|
||||||
- First update your current version to the latest 2.x version using the 2.x installer
|
|
||||||
- Then you **must** run the bot to prepare the database for the migration, and make sure the bot works prior to upgrade.
|
|
||||||
Then:
|
|
||||||
2. Rename your old wizbot bot folder to `wizbot_2x`
|
|
||||||
- `mv WizBot wizbot_2x`
|
|
||||||
3. Build the new version and move old data to the output folder
|
|
||||||
1. Clone the v3 branch to a separate folder
|
|
||||||
- `git clone https://github.com/Wizkiller96/WizBot -b v3 --depth 1`
|
|
||||||
2. Build the bot
|
|
||||||
- `dotnet publish -c Release -o output/ src/WizBot/`
|
|
||||||
3. Copy old data
|
|
||||||
- ⚠ Be sure you copy the correct command for your system!
|
|
||||||
- **Windows:** `cp -r -fo wizbot_2x/src/WizBot/data wizbot/src/WizBot/data`
|
|
||||||
- **Linux:** `cp -rf wizbot_2x/src/WizBot/data wizbot/src/WizBot/data`
|
|
||||||
4. Copy the database
|
|
||||||
- `cp wizbot_2x/src/WizBot/bin/Release/netcoreapp2.1/data/WizBot.db wizbot/output/data`
|
|
||||||
5. Copy your credentials
|
|
||||||
- `cp wizbot_2x/src/WizBot/credentials.json wizbot/output/`
|
|
||||||
4. Run the bot
|
|
||||||
- `cd wizbot/output`
|
|
||||||
- `dotnet WizBot.dll`
|
|
||||||
5. That's it. Just make sure that when you're updating the bot, you're properly backing up your old data.
|
|
|
@ -1,104 +0,0 @@
|
||||||
## MacOS From Source
|
|
||||||
|
|
||||||
Open Terminal (if you don't know how to, click on the magnifying glass on the top right corner of your screen and type **Terminal** on the window that pops up) and navigate to the location where you want to install the bot (for example `cd ~`)
|
|
||||||
|
|
||||||
##### Installing Homebrew and wget
|
|
||||||
|
|
||||||
*Skip this step if you already have homebrew installed*
|
|
||||||
- Copy and paste this command, then press Enter:
|
|
||||||
- `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
|
|
||||||
- Install wget
|
|
||||||
- `brew install wget`
|
|
||||||
|
|
||||||
##### Installation Instructions
|
|
||||||
|
|
||||||
1. Download and run the **new** installer script `cd ~ && wget -N https://github.com/Wizkiller96/wizbot-bash-installer/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
|
||||||
2. Install prerequisites (type `1` and press enter)
|
|
||||||
3. Download the bot (type `2` and press enter)
|
|
||||||
4. Exit the installer in order to set up your `creds.yml`
|
|
||||||
5. Copy the creds.yml template
|
|
||||||
`cp wizbot/output/creds_example.yml wizbot/output/creds.yml`
|
|
||||||
6. Open `wizbot/output/creds.yml` with your favorite text editor. We will use nano here
|
|
||||||
- `nano wizbot/output/creds.yml`
|
|
||||||
7. [Enter your bot's token](#creds-guide)
|
|
||||||
- After you're done, you can close nano (and save the file) by inputting, in order
|
|
||||||
- `CTRL`+`X`
|
|
||||||
- `Y`
|
|
||||||
- `Enter`
|
|
||||||
8. Run the bot (type `3` and press enter)
|
|
||||||
|
|
||||||
##### Update Instructions
|
|
||||||
|
|
||||||
1. ⚠ Stop the bot
|
|
||||||
2. Update and run the **new** installer script `cd ~ && wget -N https://github.com/Wizkiller96/wizbot-bash-installer/raw/master/linuxAIO.sh && bash linuxAIO.sh`
|
|
||||||
3. Update the bot (type `2` and press enter)
|
|
||||||
4. Run the bot (type `3` and press enter)
|
|
||||||
5. 🎉
|
|
||||||
|
|
||||||
## MacOS Manual Release installation instructions
|
|
||||||
|
|
||||||
##### Installation Instructions
|
|
||||||
|
|
||||||
1. Download the latest release from <https://github.com/Wizkiller96/WizBot/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
|
|
||||||
2. Untar it
|
|
||||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 1!
|
|
||||||
- `tar xf X.XX.X-linux-x64-build.tar`
|
|
||||||
3. Rename the `wizbot-linux-x64` to `wizbot`
|
|
||||||
- `mv wizbot-linux-x64 wizbot`
|
|
||||||
4. Move into wizbot directory and make WizBot executable
|
|
||||||
- `cd wizbot && chmod +x WizBot`
|
|
||||||
5. Copy the creds.yml template
|
|
||||||
- `cp creds_example.yml creds.yml`
|
|
||||||
6. Open `creds.yml` with your favorite text editor. We will use nano here
|
|
||||||
- `nano wizbot/output/creds.yml`
|
|
||||||
8. [Enter your bot's token](#creds-guide)
|
|
||||||
- After you're done, you can close nano (and save the file) by inputting, in order
|
|
||||||
- `CTRL`+`X`
|
|
||||||
- `Y`
|
|
||||||
- `Enter`
|
|
||||||
9. Run the bot
|
|
||||||
- `./WizBot`
|
|
||||||
|
|
||||||
##### Update Instructions
|
|
||||||
|
|
||||||
1. Stop the bot
|
|
||||||
2. Download the latest release from <https://github.com/Wizkiller96/WizBot/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
|
|
||||||
3. Untar it
|
|
||||||
⚠ Make sure that you change X.XX.X to the same series of numbers as in step 2!
|
|
||||||
- `tar xf 2.99.8-linux-x64-build.tar`
|
|
||||||
4. Rename the old wizbot directory to wizbot-old (remove your old backup first if you have one, or back it up under a different name)
|
|
||||||
- `rm -rf wizbot-old 2>/dev/null`
|
|
||||||
- `mv wizbot wizbot-old`
|
|
||||||
5. Rename the new wizbot directory to wizbot
|
|
||||||
- `mv wizbot-linux-x64 wizbot`
|
|
||||||
6. Remove old strings and aliases to avoid overwriting the updated versions of those files
|
|
||||||
⚠ If you've modified said files, back them up instead
|
|
||||||
- `rm wizbot-old/data/aliases.yml`
|
|
||||||
- `rm -r wizbot-old/data/strings`
|
|
||||||
7. Copy old data
|
|
||||||
- `cp -RT wizbot-old/data/ wizbot/data/`
|
|
||||||
8. Copy creds.yml
|
|
||||||
- `cp wizbot-old/creds.yml wizbot/`
|
|
||||||
9. Move into wizbot directory and make the wizBot executable
|
|
||||||
- `cd wizbot && chmod +x wizBot`
|
|
||||||
10. Run the bot
|
|
||||||
- `./WizBot`
|
|
||||||
|
|
||||||
🎉 Enjoy
|
|
||||||
|
|
||||||
##### Steps 3 - 9 as a single command
|
|
||||||
|
|
||||||
Don't forget to change X.XX.X to match step 2.
|
|
||||||
```sh
|
|
||||||
tar xf X.XX.X-linux-x64-build.tar && \
|
|
||||||
rm -rf wizbot-old 2>/dev/null && \
|
|
||||||
mv wizbot wizbot-old && \
|
|
||||||
mv wizbot-linux-x64 wizbot && \
|
|
||||||
rm wizbot-old/data/aliases.yml && \
|
|
||||||
rm -r wizbot-old/data/strings && \
|
|
||||||
cp -RT wizbot-old/data/ wizbot/data/ && \
|
|
||||||
cp wizbot-old/creds.yml wizbot/ && \
|
|
||||||
cd wizbot && chmod +x WizBot
|
|
||||||
```
|
|
|
@ -1,132 +0,0 @@
|
||||||
## Migration from 2.x
|
|
||||||
|
|
||||||
⚠ If you're already hosting WizBot, You **MUST** update to latest version of 2.x and **run your bot at least once** before switching over to v3.
|
|
||||||
|
|
||||||
#### [Windows migration instructions](../migration-guide#windows)
|
|
||||||
|
|
||||||
## Setting Up WizBot on Windows With the Updater
|
|
||||||
|
|
||||||
| Table of Contents|
|
|
||||||
| :---------------------------------------------------------------------------------------------------------------------------|
|
|
||||||
| [Prerequisites](#prerequisites) |
|
|
||||||
| [Setup](#setup) |
|
|
||||||
| [Starting the Bot](#starting-the-bot) |
|
|
||||||
| [Updating WizBot](#updating-wizbot) |
|
|
||||||
| [Manually Installing the Prerequisites from the Updater](#if-the-updater-fails-to-install-the-prerequisites-for-any-reason) |
|
|
||||||
|
|
||||||
*Note: If you want to make changes to WizBot's source code, please follow the [From Source][SourceGuide] guide instead.*
|
|
||||||
|
|
||||||
*If you have Windows 7 or a 32-bit system, please refer to the [From Source][SourceGuide] guide.*
|
|
||||||
|
|
||||||
#### Prerequisites
|
|
||||||
|
|
||||||
- Windows 8 or later (64-bit)
|
|
||||||
- [Create a Discord Bot application and invite the bot to your server](../creds-guide.md)
|
|
||||||
|
|
||||||
**Optional**
|
|
||||||
|
|
||||||
- [Notepad++] (makes it easier to edit your credentials)
|
|
||||||
- [Visual C++ 2010 (x86)] and [Visual C++ 2017 (x64)] (both are required if you want WizBot to play music - restart Windows after installation)
|
|
||||||
|
|
||||||
#### Setup
|
|
||||||
|
|
||||||
- Download and run the [WizBot v3 Updater][Updater] **(Currently not available)**.
|
|
||||||
- Click on the + at the top left to create a new bot.
|
|
||||||
- Give your bot a name and then click **`Go to setup`** at the lower right.
|
|
||||||
- Click on **`DOWNLOAD`** at the lower right
|
|
||||||
- Click on **`Install`** next to **`Redis`**.
|
|
||||||
- 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).
|
|
||||||
- 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.
|
|
||||||
|
|
||||||
#### Starting the bot
|
|
||||||
|
|
||||||
- Either click on **`RUN`** button in the updater or run the bot via its desktop shortcut.
|
|
||||||
|
|
||||||
#### Updating WizBot
|
|
||||||
|
|
||||||
- Make sure WizBot is closed and not running
|
|
||||||
(Run `.die` in a connected server to ensure it's not running).
|
|
||||||
- Open WizBot Updater
|
|
||||||
- Click on your bot at the upper left (looks like a spy).
|
|
||||||
- Click on **`Check for updates`**.
|
|
||||||
- If updates are available, you will be able to click on the Update button.
|
|
||||||
- Launch the bot
|
|
||||||
- You've updated and are running again, easy as that!
|
|
||||||
|
|
||||||
#### Manual Prerequisite Installation
|
|
||||||
|
|
||||||
You can still install them manually:
|
|
||||||
|
|
||||||
- [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 WizBot/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 WizBot/system
|
|
||||||
|
|
||||||
### Windows From Source
|
|
||||||
|
|
||||||
##### Prerequisites
|
|
||||||
|
|
||||||
**Install these before proceeding or your bot will not work!**
|
|
||||||
- [.net 5](https://dotnet.microsoft.com/download/dotnet/5.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)
|
|
||||||
- [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
|
|
||||||
|
|
||||||
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://github.com/Wizkiller96/WizBot -b v3 --depth 1`
|
|
||||||
2. `cd wizbot`
|
|
||||||
3. `dotnet publish -c Release -o output/ src/WizBot/`
|
|
||||||
4. `cd output && cp creds_example.yml creds.yml`
|
|
||||||
5. Open `creds.yml` with your favorite text editor (Please don't use Notepad or WordPad. You can use Notepad++, VSCode, Atom, Sublime, or something similar)
|
|
||||||
6. [Enter your bot's token](#creds-guide)
|
|
||||||
7. Run the bot `dotnet WizBot.dll`
|
|
||||||
8. 🎉
|
|
||||||
|
|
||||||
##### Update Instructions
|
|
||||||
|
|
||||||
Open PowerShell as described above and run the following commands:
|
|
||||||
|
|
||||||
1. Stop the bot
|
|
||||||
- ⚠️ Make sure you don't have your database, credentials or any other wizbot folder open in some application, this might prevent some of the steps from executing succesfully
|
|
||||||
2. Navigate to your bot's folder, example:
|
|
||||||
- `cd ~/Desktop/wizbot`
|
|
||||||
3. Pull the new version
|
|
||||||
- `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
|
|
||||||
4. **Backup** old output in case your data is overwritten
|
|
||||||
- `cp -r -fo output/ output-old`
|
|
||||||
5. Build the bot again
|
|
||||||
- `dotnet publish -c Release -o output/ src/WizBot/`
|
|
||||||
6. Remove old strings and aliases to avoid overwriting the updated versions of those files
|
|
||||||
- ⚠ If you've modified said files, back them up instead
|
|
||||||
- `rm output-old/data/aliases.yml`
|
|
||||||
- `rm -r output-old/data/strings`
|
|
||||||
7. Copy old data
|
|
||||||
- `cp -Recurse .\output-old\data\ .\output\ -Force`
|
|
||||||
8. Copy creds.yml
|
|
||||||
- `cp output-old/creds.yml output/`
|
|
||||||
9. Run the bot
|
|
||||||
- `cd output`
|
|
||||||
- `dotnet WizBot.dll`
|
|
||||||
|
|
||||||
🎉 Enjoy
|
|
||||||
|
|
||||||
#### Music prerequisites
|
|
||||||
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 `WizBot/output`.
|
|
||||||
- [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 `WizBot/system`.
|
|
||||||
|
|
||||||
[Updater]: https://wizbot.cc/downloads/v3
|
|
||||||
[Notepad++]: https://notepad-plus-plus.org/
|
|
||||||
[.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
|
|
||||||
[Visual C++ 2010 (x86)]: https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exe
|
|
||||||
[Visual C++ 2017 (x64)]: https://aka.ms/vs/15/release/vc_redist.x64.exe
|
|
||||||
[SourceGuide]: ../from-source
|
|
||||||
[ffmpeg-32bit]: https://wizbot.cc/downloads/ffmpeg-32.zip
|
|
||||||
[ffmpeg-64bit]: https://wizbot.cc/downloads/ffmpeg-64.zip
|
|
||||||
[youtube-dl]: https://yt-dl.org/downloads/latest/youtube-dl.exe
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
hljs.initHighlighting()
|
|
|
@ -1,219 +0,0 @@
|
||||||
## Setting up your API keys
|
|
||||||
|
|
||||||
This part is completely optional, **however it's necessary for music and a few other features to work properly**.
|
|
||||||
|
|
||||||
- **GoogleAPIKey**
|
|
||||||
- Required for Youtube Song Search, Playlist queuing, and a few more things.
|
|
||||||
- Follow these steps on how to setup Google API keys:
|
|
||||||
- Go to [Google Console][Google Console] and log in.
|
|
||||||
- Create a new project (name does not matter).
|
|
||||||
- Once the project is created, go into `Library`
|
|
||||||
- Under the `YouTube APIs` section, enable `YouTube Data API`
|
|
||||||
- On the left tab, access `Credentials`,
|
|
||||||
- Click `Create Credentials` button,
|
|
||||||
- Click on `API Key`
|
|
||||||
- A new window will appear with your `Google API key`
|
|
||||||
*NOTE: You don't really need to click on `RESTRICT KEY`, just click on `CLOSE` when you are done.*
|
|
||||||
- Copy the key.
|
|
||||||
- Open up `creds.yml` and look for `GoogleAPIKey`, paste your API key after the `:`.
|
|
||||||
- It should look like this:
|
|
||||||
```yml
|
|
||||||
GoogleApiKey: "AIzaSyDSci1sdlWQOWNVj1vlXxxxxxbk0oWMEzM"
|
|
||||||
```
|
|
||||||
- **MashapeKey**
|
|
||||||
- Required for Hearthstone cards.
|
|
||||||
- Api key obtained on https://rapidapi.com (register -> go to MyApps -> Add New App -> Enter Name -> Application key)
|
|
||||||
- Copy the key and paste it into `creds.yml`
|
|
||||||
- **OsuApiKey**
|
|
||||||
- Required for Osu commands
|
|
||||||
- You can get this key [here](https://osu.ppy.sh/p/api).
|
|
||||||
- **CleverbotApiKey**
|
|
||||||
- Required if you want to use Cleverbot. It's currently a paid service.
|
|
||||||
- You can get this key [here](http://www.cleverbot.com/api/).
|
|
||||||
- **PatreonAccessToken**
|
|
||||||
- For Patreon creators only.
|
|
||||||
- **PatreonCampaignId**
|
|
||||||
- For Patreon creators only. Id of your campaign.
|
|
||||||
- **TwitchClientId**
|
|
||||||
- Mandatory for following twitch streams with `.twitch` (or `.stadd` with twitch link)
|
|
||||||
- Go to [apps page](https://dev.twitch.tv/console/apps/create) on twitch and register your application.
|
|
||||||
- You need 2FA enabled on twitch in order to create an application
|
|
||||||
- You can set `http://localhost` as the OAuth Redirect URL (and press Add button)
|
|
||||||
- Select `Chat Bot` from the Category dropdown
|
|
||||||
- Once created, clicking on your application will show a new Client ID field
|
|
||||||
- Copy it to your creds.yml as shown below
|
|
||||||
```yml
|
|
||||||
TwitchClientId: "516tr61tr1qweqwe86trg3g"
|
|
||||||
```
|
|
||||||
- **LocationIqApiKey**
|
|
||||||
- Optional. Used only for the `.time` command. https://locationiq.com api key (register and you will receive the token in the email).
|
|
||||||
- **TimezoneDbApiKey**
|
|
||||||
- Optional. Used only for the `.time` command. https://timezonedb.com api key (register and you will receive the token in the email **YOU HAVE TO ACTIVEATE IT AFTER YOU GET IT**).
|
|
||||||
- **CoinmarketcapApiKey**
|
|
||||||
- Optional. Used only for the `.crypto` command. You can use crypto command without it, but you might get ratelimited from time to time, as all self-hosters share the default api key. https://pro.coinmarketcap.com/
|
|
||||||
|
|
||||||
##### Additional Settings
|
|
||||||
|
|
||||||
- **TotalShards**
|
|
||||||
- Required if the bot will be connected to more than 2500 servers.
|
|
||||||
- Most likely unnecessary to change until your bot is added to more than 2500 servers.
|
|
||||||
- **RedisOptions**
|
|
||||||
- Required if the Redis instance is not on localhost or on non-default port.
|
|
||||||
- You can find all available options [here](https://stackexchange.github.io/StackExchange.Redis/Configuration.html).
|
|
||||||
- **RestartCommand**
|
|
||||||
- Required if you want to be able to use the `.restart` command
|
|
||||||
- If you're using the CLI installer or Linux/OSX, it's easier and more reliable setup WizBot with auto-restart and just use `.die`
|
|
||||||
|
|
||||||
For Windows (Updater), add this to your `creds.yml`
|
|
||||||
|
|
||||||
```yml
|
|
||||||
RestartCommand:
|
|
||||||
Cmd: "WizBot.exe"
|
|
||||||
```
|
|
||||||
|
|
||||||
For Windows (Source), Linux or OSX, add this to your `creds.yml`
|
|
||||||
|
|
||||||
```yml
|
|
||||||
RestartCommand:
|
|
||||||
Cmd: dotnet
|
|
||||||
Args: "WizBot.dll -- {0}"
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
#### End Result
|
|
||||||
|
|
||||||
**This is an example of how the `creds.yml` looks like with multiple owners, the restart command (optional) and some of the API keys (also optional):**
|
|
||||||
|
|
||||||
```yml
|
|
||||||
# DO NOT CHANGE
|
|
||||||
version: 1
|
|
||||||
# Bot token. Do not share with anyone ever -> https://discordapp.com/developers/applications/
|
|
||||||
token: 'MTE5Nzc3MDIxMzE5NTc3NjEw.VlhNCw.BuqJFyzdIUAK1PRf1eK1Cu89Jew'
|
|
||||||
# List of Ids of the users who have bot owner permissions
|
|
||||||
# **DO NOT ADD PEOPLE YOU DON'T TRUST**
|
|
||||||
ownerIds: [
|
|
||||||
105635123466156544,
|
|
||||||
145521851676884992,
|
|
||||||
341420590009417729
|
|
||||||
]
|
|
||||||
# The number of shards that the bot will running on.
|
|
||||||
# Leave at 1 if you don't know what you're doing.
|
|
||||||
totalShards: 1
|
|
||||||
# Login to https://console.cloud.google.com, create a new project, go to APIs & Services -> Library -> YouTube Data API and enable it.
|
|
||||||
# Then, go to APIs and Services -> Credentials and click Create credentials -> API key.
|
|
||||||
# Used only for Youtube Data Api (at the moment).
|
|
||||||
googleApiKey: 'AIzaSyDScfdfdfi1sdlWQOWxxxxxbk0oWMEzM'
|
|
||||||
# Settings for voting system for discordbots. Meant for use on global WizBot.
|
|
||||||
votes:
|
|
||||||
url: ''
|
|
||||||
key: ''
|
|
||||||
# Patreon auto reward system settings.
|
|
||||||
# go to https://www.patreon.com/portal -> my clients -> create client
|
|
||||||
patreon:
|
|
||||||
# Access token. You have to manually update this 1st of each month by refreshing the token on https://patreon.com/portal
|
|
||||||
accessToken: ''
|
|
||||||
# Unused atm
|
|
||||||
refreshToken: ''
|
|
||||||
# Unused atm
|
|
||||||
clientSecret: ''
|
|
||||||
# Campaign ID of your patreon page. Go to your patreon page (make sure you're logged in) and type "prompt('Campaign ID', window.patreon.bootstrap.creator.data.id);" in the console. (ctrl + shift + i)
|
|
||||||
campaignId: ''
|
|
||||||
# Api key for sending stats to DiscordBotList.
|
|
||||||
botListToken: ''
|
|
||||||
# Official cleverbot api key.
|
|
||||||
cleverbotApiKey: ''
|
|
||||||
# Redis connection string. Don't change if you don't know what you're doing.
|
|
||||||
redisOptions: localhost:6379,syncTimeout=30000,responseTimeout=30000,allowAdmin=true,password=
|
|
||||||
# Database options. Don't change if you don't know what you're doing. Leave null for default values
|
|
||||||
db:
|
|
||||||
# Database type. Only sqlite supported atm
|
|
||||||
type: sqlite
|
|
||||||
# Connection string. Will default to "Data Source=data/WizBot.db"
|
|
||||||
connectionString: Data Source=data/WizBot.db
|
|
||||||
# Address and port of the coordinator endpoint. Leave empty for default.
|
|
||||||
# Change only if you've changed the coordinator address or port.
|
|
||||||
coordinatorUrl: http://localhost:3442
|
|
||||||
# Api key obtained on https://rapidapi.com (go to MyApps -> Add New App -> Enter Name -> Application key)
|
|
||||||
rapidApiKey: 4UrKpcWXcxxxxxxxxxxxxxxp1Q8kI6jsn32xxxoVWiY7
|
|
||||||
# https://locationiq.com api key (register and you will receive the token in the email).
|
|
||||||
# Used only for .time command.
|
|
||||||
locationIqApiKey:
|
|
||||||
# https://timezonedb.com api key (register and you will receive the token in the email).
|
|
||||||
# Used only for .time command
|
|
||||||
timezoneDbApiKey:
|
|
||||||
# https://pro.coinmarketcap.com/account/ api key. There is a free plan for personal use.
|
|
||||||
# Used for cryptocurrency related commands.
|
|
||||||
coinmarketcapApiKey:
|
|
||||||
# Api key used for Osu related commands. Obtain this key at https://osu.ppy.sh/p/api
|
|
||||||
osuApiKey: 4c8c8fdffdsfdsfsdfsfa33f3f3140a7d93320d6
|
|
||||||
# Command and args which will be used to restart the bot.
|
|
||||||
# Only used if bot is executed directly (NOT through the coordinator)
|
|
||||||
# placeholders:
|
|
||||||
# {0} -> shard id
|
|
||||||
# {1} -> total shards
|
|
||||||
# Linux default
|
|
||||||
# cmd: dotnet
|
|
||||||
# args: "WizBot.dll -- {0}"
|
|
||||||
# Windows default
|
|
||||||
# cmd: WizBot.exe
|
|
||||||
# args: {0}
|
|
||||||
restartCommand:
|
|
||||||
cmd:
|
|
||||||
args:
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Database
|
|
||||||
|
|
||||||
WizBot saves all settings and data in the database file `WizBot.db`, located in:
|
|
||||||
|
|
||||||
- Windows (Updater): `system/data` (can be easily accessed through the `Data` button on the updater)
|
|
||||||
- Windows (Source), Linux and OSX: `wizbot/output/data/WizBot.db`
|
|
||||||
|
|
||||||
In order to open it you will need [SQLite Browser](http://sqlitebrowser.org/).
|
|
||||||
|
|
||||||
*NOTE: You don't have to worry if you don't have the `WizBot.db` file, it gets automatically created once you successfully run the bot for the first time.*
|
|
||||||
|
|
||||||
**To make changes to the database on windows:**
|
|
||||||
|
|
||||||
- Shut your bot down.
|
|
||||||
- Copy the `WizBot.db` file to someplace safe. (Back up)
|
|
||||||
- Open it with SQLite Browser.
|
|
||||||
- Go to the **Browse Data** tab.
|
|
||||||
- Click on the **Table** drop-down list.
|
|
||||||
- Choose the table you want to edit.
|
|
||||||
- Click on the cell you want to edit.
|
|
||||||
- Edit it on the right-hand side.
|
|
||||||
- Click on **Apply**.
|
|
||||||
- Click on **Write Changes**.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Sharding your bot
|
|
||||||
|
|
||||||
To run a sharded bot, you will want to run `src/WizBot.Coordinator` project.
|
|
||||||
Shards communicate with the coordinator using gRPC
|
|
||||||
To configure your Coordinator, you will need to edit the `src/WizBot.Coordinator/coord.yml` file
|
|
||||||
|
|
||||||
```yml
|
|
||||||
# total number of shards
|
|
||||||
TotalShards: 3
|
|
||||||
# How often do shards ping their state back to the coordinator
|
|
||||||
RecheckIntervalMs: 5000
|
|
||||||
# Command to run the shard
|
|
||||||
ShardStartCommand: dotnet
|
|
||||||
# Arguments to run the shard
|
|
||||||
# {0} = shard id
|
|
||||||
# {1} = total number of shards
|
|
||||||
ShardStartArgs: ../../output/WizBot.dll -- {0} {1}
|
|
||||||
# How long does it take for the shard to be forcefully restarted once it stops reporting its state
|
|
||||||
UnresponsiveSec: 30
|
|
||||||
```
|
|
||||||
|
|
||||||
[Google Console]: https://console.developers.google.com
|
|
||||||
[DiscordApp]: https://discordapp.com/developers/applications/me
|
|
||||||
[Invite Guide]: https://tukimoop.pw/s/guide.html
|
|
|
@ -0,0 +1 @@
|
||||||
|
docs.wizbot.cc
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.2 KiB |
|
@ -0,0 +1,32 @@
|
||||||
|
## Creating your own Discord bot
|
||||||
|
|
||||||
|
This guide will show you how to create your own discord bot, invite it to your server, and obtain the credentials needed to run it.
|
||||||
|
|
||||||
|
1. Go to [the Discord developer application page][DiscordApp].
|
||||||
|
2. Log in with your Discord account.
|
||||||
|
3. Click **New Application**.
|
||||||
|
4. Fill out the `Name` field however you like, accept the terms, and confirm.
|
||||||
|
5. Go to the **Bot** tab on the left sidebar.
|
||||||
|
6. Click on the `Add a Bot` button and confirm that you do want to add a bot to this app.
|
||||||
|
7. **Optional:** Add bot's avatar and description.
|
||||||
|
8. Copy your Token to `creds.yml` as shown above.
|
||||||
|
9. Scroll down to the **`Privileged Gateway Intents`** section
|
||||||
|
- You MUST enable the following:
|
||||||
|
- **PRESENCE INTENT**
|
||||||
|
- **SERVER MEMBERS INTENT**
|
||||||
|
- **MESSAGE CONTENT INTENT**
|
||||||
|
|
||||||
|
### Inviting your bot to your server
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- On the **General Information** tab, copy your `Application ID` from your [applications page][DiscordApp].
|
||||||
|
- Replace the `YOUR_CLIENT_ID_HERE` in this link:
|
||||||
|
`https://discordapp.com/oauth2/authorize?client_id=YOUR_CLIENT_ID_HERE&scope=bot&permissions=66186303` with your `Client ID`
|
||||||
|
- The link should now look something like this:
|
||||||
|
`https://discordapp.com/oauth2/authorize?client_id=123123123123&scope=bot&permissions=66186303`
|
||||||
|
- Access that newly created link, pick your Discord server, click `Authorize` and confirm with the captcha at the end
|
||||||
|
- The bot should now be in your server
|
||||||
|
|
||||||
|
|
||||||
|
[DiscordApp]: https://discordapp.com/developers/applications/me
|
|
@ -1,16 +1,15 @@
|
||||||
# Donate
|
# Donate
|
||||||
|
|
||||||
WizBot is an [open-source project][gitlab], and we rely on your help to develop the bot, pay hosting fees, maintain our website and more.
|
WizBot is an [open-source project][github], and we rely on your help to develop the bot, pay hosting fees, maintain our website and more.
|
||||||
Donations go a long way in helping us keep the project alive, and we appreciate every single one of them.
|
Donations go a long way in helping us keep the project alive, and we appreciate every single one of them.
|
||||||
|
|
||||||
## Perks
|
## Perks
|
||||||
|
|
||||||
Donating to us also gives you the following benefits:
|
Donating to us also gives you the following benefits:
|
||||||
|
|
||||||
- A hoisted **Donators role** in our [Discord server][discord-server]
|
- A hoisted **Patron** role in [WizNet Discord server][discord-server]
|
||||||
- Access to exclusive **#noticed** text and voice channels
|
- Access to exclusive **#noticed** text and voice channels
|
||||||
- **1000 flowers** on the public bot per dollar donated (after fees)
|
- **3000 flowers** on the public bot per dollar donated (after fees)
|
||||||
- **Custom Reactions** on the public bot for [Patreon pledges][patreon] of $5 or higher
|
|
||||||
|
|
||||||
## Patreon
|
## Patreon
|
||||||
|
|
||||||
|
@ -26,13 +25,13 @@ You can set up a monthly pledge on [Patreon][patreon] and support the project's
|
||||||
You can also donate to us through [PayPal][paypal] for one-time donations using the button below.
|
You can also donate to us through [PayPal][paypal] for one-time donations using the button below.
|
||||||
|
|
||||||
!!! Note
|
!!! Note
|
||||||
Mention your Discord tag (Username#1234) in the payment note to receive flower rewards.
|
Mention your Discord username or user id in the payment note to receive flower rewards.
|
||||||
|
|
||||||
[![img][paypal-button]][paypal]
|
[![img][paypal-button]][paypal]
|
||||||
|
|
||||||
[gitlab]: https://github.com/Wizkiller96/WizBot
|
[github]: https://github.com/Wizkiller96/WizBot
|
||||||
[discord-server]: https://wizbot.cc/discord
|
[discord-server]: https://wizbot.cc/discord
|
||||||
[patreon]: https://www.patreon.com/WizNet
|
[patreon]: https://www.patreon.com/wiznet
|
||||||
[patreon-button]: ./assets/patreon.png
|
[patreon-button]: ./assets/patreon.png
|
||||||
[paypal]: https://paypal.me/Wizkiller96Network
|
[paypal]: https://paypal.me/wizkiller96network
|
||||||
[paypal-button]: ./assets/paypal.png
|
[paypal-button]: ./assets/paypal.png
|
|
@ -0,0 +1,232 @@
|
||||||
|
# WizBot CLI Guide (via Bash Installer)
|
||||||
|
|
||||||
|
### Supported Operating Systems
|
||||||
|
|
||||||
|
--8<-- "md/snippets/supported-platforms.md:linux"
|
||||||
|
--8<-- "md/snippets/supported-platforms.md:macos"
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
macOS:
|
||||||
|
|
||||||
|
- [Homebrew](https://brew.sh/)
|
||||||
|
- [Curl](#__tabbed_1_5)
|
||||||
|
|
||||||
|
Linux:
|
||||||
|
|
||||||
|
- [Curl](#__tabbed_1_1)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
??? note "24/7 Up-time via VPS (Digital Ocean Guide)"
|
||||||
|
--8<-- "md/guides/vps-linux-guide.md"
|
||||||
|
|
||||||
|
??? note "Creating a Discord Bot & Getting Credentials"
|
||||||
|
--8<-- "md/creds-guide.md"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Installation Instructions
|
||||||
|
|
||||||
|
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. First make sure that curl is installed
|
||||||
|
|
||||||
|
/// tab | Ubuntu | Debian | Mint
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo apt install curl
|
||||||
|
```
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tab | Rocky | Alma | Fedora
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo dnf install curl
|
||||||
|
```
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tab | openSUSE
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo zypper install curl
|
||||||
|
```
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tab | Arch | Artix
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo pacman -S curl
|
||||||
|
```
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tab | macOS
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install curl
|
||||||
|
```
|
||||||
|
|
||||||
|
///
|
||||||
|
|
||||||
|
2. Download and run the **new** installer script
|
||||||
|
``` sh
|
||||||
|
cd ~
|
||||||
|
curl -L -o n-install.sh https://raw.githubusercontent.com/Wizkiller96/bash-installer/refs/heads/v6/w-install.sh
|
||||||
|
bash w-install.sh
|
||||||
|
```
|
||||||
|
3. Install the bot (type `1` and press enter)
|
||||||
|
4. Edit creds (type `3` and press enter)
|
||||||
|
- *ALTERNATIVELY*, you can exit the installer (option `6`) and edit `wizbot/creds.yml` file yourself
|
||||||
|
5. Follow the instruction [below](#creating-your-own-discord-bot) to create your own Discord bot and obtain the credentials needed to run it.
|
||||||
|
- After you're done, you can close nano (and save the file) by inputting, in order:
|
||||||
|
- `CTRL` + `X`
|
||||||
|
- `Y`
|
||||||
|
- `Enter`
|
||||||
|
6. Run the installer script again
|
||||||
|
- `bash w-install.sh`
|
||||||
|
7. Run the bot (type `3` and press enter)
|
||||||
|
8. Done!
|
||||||
|
|
||||||
|
## Update Instructions
|
||||||
|
|
||||||
|
1. ⚠ Stop the bot ⚠
|
||||||
|
2. Navigate to your bot's folder, we'll use home directory as an example
|
||||||
|
- `cd ~`
|
||||||
|
3. Simply re-install the bot with a newer version by running the installer script
|
||||||
|
- `curl -L -o w-install.sh https://raw.githubusercontent.com/Wizkiller96/bash-installer/refs/heads/v6/w-install.sh && bash w-install.sh`
|
||||||
|
4. Select option 1, and select a NEWER version
|
||||||
|
|
||||||
|
## Running WizBot
|
||||||
|
|
||||||
|
There are two main methods to run WizBot: using `tmux` (macOS and Linux) or using `systemd` with a script (Linux only).
|
||||||
|
|
||||||
|
/// tab | Tmux (Preferred Method)
|
||||||
|
|
||||||
|
Using `tmux` is the simplest method, and is therefore recommended for most users.
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
Before proceeding, make sure your bot is not currently running by either running `.die` in your Discord server or exiting the process with `Ctrl+C`.
|
||||||
|
|
||||||
|
1. Access the directory where `w-install.sh` and `wizbot` is located.
|
||||||
|
2. Create a new tmux session: `tmux new -s wizbot`
|
||||||
|
- The above command will create a new session named **wizbot**. You may replace **wizbot** with any name you prefer.
|
||||||
|
3. Run the installer: `bash w-install.sh`
|
||||||
|
4. Start the bot by typing `3` and pressing `Enter`.
|
||||||
|
5. Detach from the tmux session, allowing the bot to run in the background:
|
||||||
|
- Press `Ctrl` + `B`
|
||||||
|
- Then press `D`
|
||||||
|
|
||||||
|
Now check your Discord server, the bot should be online. WizBot 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 wizbot`. *(Make sure to replace "wizbot" with your session name. If you didn't change it, leave it as it is.)*
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tab | Systemd
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Systemd is only available on Linux. macOS utilizes Launchd, which is not covered in this guide. If you're on macOS, please use the `tmux` method, or use [WizBot Updater](desktop-guide.md) to run WizBot.
|
||||||
|
|
||||||
|
This method is a bit more complex and involved, but comes with the added benefit of better error logging and control over what happens before and after the startup of WizBot.
|
||||||
|
|
||||||
|
1. Access the directory where `w-install.sh` and `wizbot` is located.
|
||||||
|
2. Use the following command to create a service that will be used to execute `WizBotRun.bash`:
|
||||||
|
```bash
|
||||||
|
echo "[Unit]
|
||||||
|
Description=WizBot service
|
||||||
|
After=network.target
|
||||||
|
StartLimitIntervalSec=60
|
||||||
|
StartLimitBurst=2
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=$USER
|
||||||
|
WorkingDirectory=$PWD
|
||||||
|
ExecStart=/bin/bash WizBotRun.bash
|
||||||
|
#ExecStart=./wizbot/WizBot
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
SyslogIdentifier=WizBot
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/wizbot.service
|
||||||
|
```
|
||||||
|
3. Make the new service available: `sudo systemctl daemon-reload`
|
||||||
|
4. Use the following command to create a script that will be used to start WizBot:
|
||||||
|
```bash
|
||||||
|
cat <<EOF > WizBotRun.bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
|
||||||
|
is_python3_installed=\$(command -v python3 &>/dev/null && echo true || echo false)
|
||||||
|
is_yt_dlp_installed=\$(command -v yt-dlp &>/dev/null && echo true || echo false)
|
||||||
|
|
||||||
|
[[ \$is_python3_installed == true ]] \\
|
||||||
|
&& echo "[INFO] python3 path: \$(which python3)" \\
|
||||||
|
&& echo "[INFO] python3 version: \$(python3 --version)"
|
||||||
|
[[ \$is_yt_dlp_installed == true ]] \\
|
||||||
|
&& echo "[INFO] yt-dlp path: \$(which yt-dlp)"
|
||||||
|
|
||||||
|
echo "[INFO] Running WizBot in the background with auto restart"
|
||||||
|
if [[ \$is_yt_dlp_installed == true ]]; then
|
||||||
|
yt-dlp -U || echo "[ERROR] Failed to update 'yt-dlp'" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[INFO] Starting WizBot..."
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
if [[ -d $PWD/wizbot ]]; then
|
||||||
|
cd "$PWD/wizbot" || {
|
||||||
|
echo "[ERROR] Failed to change working directory to '$PWD/wizbot'" >&2
|
||||||
|
echo "[INFO] Exiting..."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "[WARN] '$PWD/wizbot' doesn't exist" >&2
|
||||||
|
echo "[INFO] Exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
./WizBot || {
|
||||||
|
echo "[ERROR] An error occurred when trying to start WizBot" >&2
|
||||||
|
echo "[INFO] Exiting..."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "[INFO] Waiting 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
if [[ \$is_yt_dlp_installed == true ]]; then
|
||||||
|
yt-dlp -U || echo "[ERROR] Failed to update 'yt-dlp'" >&2
|
||||||
|
fi
|
||||||
|
echo "[INFO] Restarting WizBot..."
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[INFO] Stopping WizBot..."
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
With everything set up, you can run WizBot in one of three modes:
|
||||||
|
|
||||||
|
1. **Auto-Restart Mode**: WizBot will restart automatically if you restart it via the `.die` command.
|
||||||
|
- To enable this mode, start the service: `sudo systemctl start wizbot`
|
||||||
|
2. **Auto-Restart on Reboot Mode**: In addition to auto-restarting after `.die`, WizBot will also start automatically on system reboot.
|
||||||
|
- To enable this mode, run:
|
||||||
|
```bash
|
||||||
|
sudo systemctl enable wizbot
|
||||||
|
sudo systemctl start wizbot
|
||||||
|
```
|
||||||
|
3. **Standard Mode**: WizBot will stop completely when you use `.die`, without restarting automatically.
|
||||||
|
- To switch to this mode:
|
||||||
|
1. Stop the service: `sudo systemctl stop wizbot`
|
||||||
|
2. Edit the service file: `sudo <editor> /etc/systemd/system/wizbot.service`
|
||||||
|
3. Modify the `ExecStart` line:
|
||||||
|
- **Comment out**: `ExecStart=/bin/bash WizBotRun.bash`
|
||||||
|
- **Uncomment**: `#ExecStart=./wizbot/WizBot`
|
||||||
|
4. Save and exit the editor.
|
||||||
|
5. Reload systemd: `sudo systemctl daemon-reload`
|
||||||
|
6. Disable automatic startup: `sudo systemctl disable wizbot`
|
||||||
|
7. Start WizBot manually: `sudo systemctl start wizbot`
|
||||||
|
|
||||||
|
///
|
|
@ -0,0 +1,55 @@
|
||||||
|
# WizBot Desktop Guide (via Upeko)
|
||||||
|
|
||||||
|
### Supported Operating Systems
|
||||||
|
|
||||||
|
--8<-- "md/snippets/supported-platforms.md"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
??? note "Creating a Discord Bot & Getting Credentials"
|
||||||
|
--8<-- "md/creds-guide.md"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
1. Download and run the [WizBot Updater](https://github.com/Wizkiller96/wizbot-updater/releases/latest).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
2. Click the plus button to add a new bot
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
3. If you want to use the music module, click on **`Install`** next to `ffmpeg` and `yt-dlp` at the top
|
||||||
|
4. Click on the newly created bot
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
5. Click on **DOWNLOAD** at the lower right
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
6. When installation is finished, click on **`CREDS`** (`1`) above the **`RUN`** (`3`) button on the lower left
|
||||||
|
- **`2`** simply opens your bot's data folder.
|
||||||
|
7. Paste in your **BOT TOKEN** previously obtained
|
||||||
|
|
||||||
|
## Starting WizBot
|
||||||
|
|
||||||
|
- Either click on **`RUN`** button in the updater or run the bot via its desktop shortcut.
|
||||||
|
|
||||||
|
## Updating WizBot
|
||||||
|
|
||||||
|
!!! warning "IMPORTANT"
|
||||||
|
|
||||||
|
- Make sure WizBot is closed and not running
|
||||||
|
- Run `.die` in a connected server to make sure.
|
||||||
|
- Make sure you don't have `data` folder, bot folder, or any other bot file open in any program, as the updater will fail to replace your version
|
||||||
|
|
||||||
|
1. Run `upeko` if not already running
|
||||||
|
2. Click on your bot
|
||||||
|
3. Click on **`Check for updates`**
|
||||||
|
4. If updates are available, you will be able to click on the Update button
|
||||||
|
5. Click `Update`
|
||||||
|
6. Click `RUN` after it's done
|
|
@ -0,0 +1,72 @@
|
||||||
|
# Docker Guide
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
- [Docker Core Engine](https://docs.docker.com/engine/install/)
|
||||||
|
- [Docker Compose](https://docs.docker.com/compose/install/) (optional, but recommended)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
??? note "Creating a Discord Bot & Getting Credentials"
|
||||||
|
--8<-- "md/creds-guide.md"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Installing WizBot with Docker
|
||||||
|
|
||||||
|
When deploying WizBot with Docker, you have two options: using [Docker](#__tabbed_1_1) or [Docker Compose](#__tabbed_1_2). The following sections provide step-by-step instructions for both methods.
|
||||||
|
|
||||||
|
/// tab | Docker
|
||||||
|
|
||||||
|
### Deploying WizBot with Docker
|
||||||
|
|
||||||
|
1. Move to a directory where you want your WizBot's data folder to be (data folder will keep the database and config files) and create a data folder there.
|
||||||
|
``` sh
|
||||||
|
cd ~ && mkdir wizbot && cd wizbot && mkdir data
|
||||||
|
```
|
||||||
|
2. Mount the newly created empty data folder as a volume while starting your docker container. Replace YOUR_TOKEN_HERE with the bot token obtained from the creds guide above.
|
||||||
|
``` sh
|
||||||
|
docker run -d --name wizbot ghcr.io/Wizkiller96/WizBot:v6 -e bot_token=YOUR_TOKEN_HERE -v "./data:/app/data" && docker logs -f --tail 500 wizbot
|
||||||
|
```
|
||||||
|
3. Enjoy! 🎉
|
||||||
|
|
||||||
|
### Updating your bot
|
||||||
|
|
||||||
|
If you want to update WizBot to the latest version, all you have to do is pull the latest image and re-run.
|
||||||
|
|
||||||
|
1. Pull the latest image
|
||||||
|
``` sh
|
||||||
|
docker pull ghcr.io/Wizkiller96/WizBot:v6
|
||||||
|
```
|
||||||
|
2. Re-run your bot the same way you did before
|
||||||
|
``` sh
|
||||||
|
docker run -d --name wizbot ghcr.io/Wizkiller96/WizBot:v6 -e bot_token=YOUR_TOKEN_HERE -v "./data:/app/data" && docker logs -f --tail 500 wizbot
|
||||||
|
```
|
||||||
|
3. Done! 🎉
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tab | Docker Compose
|
||||||
|
|
||||||
|
1. **Choose Your Workspace:** Select a directory where you'll set up your WizBot stack. Use your terminal to navigate to this directory. For the purpose of this guide, we'll use `/opt/stacks/wizbot/` 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:
|
||||||
|
``` yml
|
||||||
|
services:
|
||||||
|
wizbot:
|
||||||
|
image: ghcr.io/Wizkiller96/WizBot:v6
|
||||||
|
container_name: wizbot
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
TZ: Europe/Rome # Modify this to your timezone
|
||||||
|
bot_token: YOUR_TOKEN_HERE
|
||||||
|
volumes:
|
||||||
|
- /opt/stacks/wizbot/data:/app/data
|
||||||
|
networks: {}
|
||||||
|
```
|
||||||
|
|
||||||
|
1. **Launch Your Bot:** Now, you're ready to run Docker Compose. Use the following command: `docker compose up -d`.
|
||||||
|
2. **Navigate to Your Directory:** Use `cd /opt/stacks/wizbot/` to go to the directory containing your Docker Compose file.
|
||||||
|
3. **Pull the Latest Images:** Use `docker compose pull` to fetch the latest images.
|
||||||
|
4. **Restart Your Containers:** Use `docker compose up -d` to restart the containers.
|
||||||
|
|
||||||
|
///
|
|
@ -0,0 +1,66 @@
|
||||||
|
# Setting Up WizBot on Windows from source
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
- Windows 10 or later (64-bit)
|
||||||
|
- [.net 8 sdk](https://dotnet.microsoft.com/download/dotnet/8.0)
|
||||||
|
- If you want wizbot to play music: [Visual C++ 2010 (x86)] and [Visual C++ 2017 (x64)] (both are required, you may install them later)
|
||||||
|
- [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)
|
||||||
|
- **Optional** Any code editor, for example [Visual Studio Code](https://code.visualstudio.com/Download)
|
||||||
|
- You'll need to at least modify creds.yml, notepad is inadequate
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
??? note "Creating a Discord Bot & Getting Credentials"
|
||||||
|
--8<-- "md/creds-guide.md"
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
1. Navigate to the location where you want to install the bot
|
||||||
|
- for example, type `cd ~/Desktop/` and press enter
|
||||||
|
2. `git clone https://github.com/Wizkiller96/WizBot -b v6 --depth 1`
|
||||||
|
3. `cd wizbot/src/WizBot`
|
||||||
|
4. `dotnet build -c Release`
|
||||||
|
5. `cp data/creds_example.yml data/creds.yml`
|
||||||
|
6. "You're done installing, you may now proceed to set up your bot's credentials by following the [#creds-guide]
|
||||||
|
- Once done, come back here and run the last command
|
||||||
|
6. Run the bot `dotnet WizBot.dll`
|
||||||
|
7. 🎉 Enjoy
|
||||||
|
|
||||||
|
## Update Instructions
|
||||||
|
|
||||||
|
Open PowerShell as described above and run the following commands:
|
||||||
|
|
||||||
|
1. Stop the bot
|
||||||
|
- ⚠️ Make sure you don't have your database, credentials or any other wizbot folder open in some application, this might prevent some of the steps from executing successfully
|
||||||
|
2. Navigate to your bot's folder, example:
|
||||||
|
- `cd ~/Desktop/wizbot`
|
||||||
|
3. Pull the new version, and make sure you're on the v6 branch
|
||||||
|
- `git pull`
|
||||||
|
- ⚠️ IF this fails, you may want to `git 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
|
||||||
|
- `cp -r -fo output/ output-old`
|
||||||
|
5. Build the bot again
|
||||||
|
- `dotnet run -c Release src/WizBot/`
|
||||||
|
6. Copy old data, and new strings
|
||||||
|
- `cp -r -fo .\output-old\data\ .\output\`
|
||||||
|
7. Run the bot
|
||||||
|
- `cd output`
|
||||||
|
- `dotnet WizBot.dll`
|
||||||
|
8. 🎉 Enjoy
|
||||||
|
|
||||||
|
## Music Prerequisites
|
||||||
|
|
||||||
|
In order to use music commands, you need ffmpeg and yt-dlp installed.
|
||||||
|
|
||||||
|
- [ffmpeg]
|
||||||
|
- [yt-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 your wizbot's output folder.
|
||||||
|
|
||||||
|
[.net]: https://dotnet.microsoft.com/download/dotnet/8.0
|
||||||
|
[ffmpeg]: https://github.com/GyanD/codexffmpeg/releases/latest
|
||||||
|
[yt-dlp]: https://github.com/yt-dlp/yt-dlp/releases/latest
|
|
@ -0,0 +1,54 @@
|
||||||
|
## Setting up WizBot on a Linux VPS (Digital Ocean Droplet)
|
||||||
|
|
||||||
|
If you want WizBot 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 WizBot on Linux Digital Ocean Droplet using the link [DigitalOcean](https://m.do.co/c/7290047d0c84) (by using this link, you will get **$10 credit** and also support WizBot)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Droplet Type: SHARED CPU | Basic
|
||||||
|
|
||||||
|
CPU options: Regular | Disk type: SSD
|
||||||
|
6$/mo
|
||||||
|
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)
|
||||||
|
Click create droplet
|
||||||
|
```
|
||||||
|
**Setting up WizBot**
|
||||||
|
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.
|
||||||
|
|
||||||
|
**This section is only relevant to those who want to host WizBot on DigitalOcean. Go through this whole section before setting the bot up.**
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
- Download [PuTTY](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)
|
||||||
|
- Download [WinSCP](https://winscp.net/eng/download.php) *(optional)*
|
||||||
|
- [Create and invite the bot](../creds-guide.md).
|
||||||
|
|
||||||
|
### Starting up
|
||||||
|
|
||||||
|
- **Open PuTTY** and paste or enter your `IP address` and then click **Open**.
|
||||||
|
If you entered your Droplets IP address correctly, it should show **login as:** in a newly opened window.
|
||||||
|
- Now for **login as:**, type `root` and press enter.
|
||||||
|
- It should then ask for a password. Type the `root password` you have received in your e-mail address, then press Enter.
|
||||||
|
|
||||||
|
If you are running your droplet for the first time, it will most likely ask you to change your root password. To do that, copy the **password you've received by e-mail** and paste it on PuTTY.
|
||||||
|
|
||||||
|
- To paste, just right-click the window (it won't show any changes on the screen), then press Enter.
|
||||||
|
- Type a **new password** somewhere, copy and paste it on PuTTY. Press Enter then paste it again.
|
||||||
|
|
||||||
|
**Save the new password somewhere safe.**
|
||||||
|
|
||||||
|
After that, your droplet should be ready for use.
|
||||||
|
|
||||||
|
[Setting up WizBot on a VPS (Digital Ocean)]: #setting-up-wizbot-on-a-linux-vps-digital-ocean-droplet
|
|
@ -13,16 +13,13 @@ To invite public WizBot to your server or to view its commands, click on the but
|
||||||
|
|
||||||
To self-host your own WizBot, use the guides below:
|
To self-host your own WizBot, use the guides below:
|
||||||
|
|
||||||
- [:material-microsoft-windows: Windows guide][windows-guide]
|
- [:material-television-guide: Desktop guide (Windows/Linux/macOS)][desktop-guide]
|
||||||
- [:material-linux: Linux guide][linux-guide]
|
- [:material-console: CLI guide (Linux/macOS)][cli-guide]
|
||||||
- [:material-apple: Mac OS guide][macos-guide]
|
- [:material-docker: Docker guide][docker-guide]
|
||||||
|
- [:material-source-branch: From source guide][from-source-guide]
|
||||||
Alternatively, you may also setup the bot [from source][from-source-guide] if you want to modify the code.
|
|
||||||
|
|
||||||
In case you need any help, join our [Discord server][discord-server] where we may provide support.
|
In case you need any help, join our [Discord server][discord-server] where we may provide support.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## About WizBot
|
## About WizBot
|
||||||
|
|
||||||
WizBot is an [open source project][github]. Any issues with the bot may be filed [here][issues].
|
WizBot is an [open source project][github]. Any issues with the bot may be filed [here][issues].
|
||||||
|
@ -32,11 +29,11 @@ If you're unsure whether something is an issue, ask in our support server first.
|
||||||
[Donations are welcome][donate], and we rely on your contributions to help keep the project alive.
|
[Donations are welcome][donate], and we rely on your contributions to help keep the project alive.
|
||||||
|
|
||||||
[invite]: https://wizbot.cc/botinvite
|
[invite]: https://wizbot.cc/botinvite
|
||||||
[commands]: https://commands.wizbot.cc/
|
[commands]: https://wizbot.cc/commands
|
||||||
[windows-guide]: ./guides/windows-guide.md
|
[desktop-guide]: ./guides/desktop-guide.md
|
||||||
[linux-guide]: ./guides/linux-guide.md
|
[cli-guide]: ./guides/cli-guide.md
|
||||||
[macos-guide]: ./guides/osx-guide.md
|
[docker-guide]: ./guides/docker-guide.md
|
||||||
[from-source-guide]: ./guides/from-source.md
|
[from-source-guide]: ./guides/source-guide.md
|
||||||
[discord-server]: https://wizbot.cc/discord
|
[discord-server]: https://wizbot.cc/discord
|
||||||
[github]: https://github.com/Wizkiller96/WizBot
|
[github]: https://github.com/Wizkiller96/WizBot
|
||||||
[issues]: https://github.com/Wizkiller96/WizBot/issues
|
[issues]: https://github.com/Wizkiller96/WizBot/issues
|
|
@ -0,0 +1,164 @@
|
||||||
|
# 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/WizNet/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 wiz-medusa template
|
||||||
|
- `dotnet new install wiz-medusa`
|
||||||
|
|
||||||
|
- Make a new Wiz Medusa project
|
||||||
|
- `dotnet new wiz-medusa`
|
||||||
|
|
||||||
|
## Build it
|
||||||
|
|
||||||
|
- Build your Medusa into a dll that Wiz 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 WizBot's `data/medusae/` folder. (WizBot 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
|
||||||
|
|
||||||
|
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 Wiz's Modules are written but mostly from never-released `Ayu.Commands` system which was designed to be used for a full WizBot v3 rewrite.
|
||||||
|
|
||||||
|
The medusa base classes used for development are open source [here](https://github.com/Wizkiller96/WizBot/tree/v6/src/Wiz.Medusa) in case you need reference, as there is no generated documentation at the moment.
|
||||||
|
|
||||||
|
## Term list
|
||||||
|
|
||||||
|
### Medusa
|
||||||
|
|
||||||
|
- The project itself which compiles to a single `.dll` (and some optional auxiliary files), it can contain multiple [Sneks](#snek), [Services](#service), and [ParamParsers](#param-parser)
|
||||||
|
|
||||||
|
### Snek
|
||||||
|
|
||||||
|
- A class which will be added as a single Module to WizBot on load. It also acts as a [lifecycle handler](snek-lifecycle.md) and as a singleton service with the support for initialize and cleanup.
|
||||||
|
- It can contain a Snek (called SubSnek) but only 1 level of nesting is supported (you can only have a snek contain a subsnek, but a subsnek can't contain any other sneks)
|
||||||
|
- Sneks can have their own prefix
|
||||||
|
- For example if you set this to 'test' then a command called 'cmd' will have to be invoked by using `.test cmd` instead of `.cmd`
|
||||||
|
|
||||||
|
### Snek Command
|
||||||
|
|
||||||
|
- Acts as a normal command
|
||||||
|
- Has context injected as a first argument which controls where the command can be executed
|
||||||
|
- `AnyContext` the command can be executed in both DMs and Servers
|
||||||
|
- `GuildContext` the command can only be executed in Servers
|
||||||
|
- `DmContext` the command can only be executed in DMs
|
||||||
|
- Support the usual features such as default values, leftover, params, etc.
|
||||||
|
- It also supports dependency injection via `[inject]` attribute. These dependencies must come after the context and before any input parameters
|
||||||
|
- Supports `ValueTask`, `Task`, `Task<T>` and `void` return types
|
||||||
|
|
||||||
|
### Param Parser
|
||||||
|
|
||||||
|
- Allows custom parsing of command arguments into your own types.
|
||||||
|
- Overriding existing parsers (for example for IGuildUser, etc...) can cause issues.
|
||||||
|
|
||||||
|
### Service
|
||||||
|
|
||||||
|
- Usually not needed.
|
||||||
|
- They are marked with a `[svc]` attribute, and offer a way to inject dependencies to different parts of your medusa.
|
||||||
|
- Transient and Singleton lifetimes are supported.
|
||||||
|
|
||||||
|
### Localization
|
||||||
|
|
||||||
|
Response and command strings can be kept in one of three different places based on whether you plan to allow support for localization
|
||||||
|
|
||||||
|
option 1) `res.yml` and `cmds.yml`
|
||||||
|
|
||||||
|
If you don't plan on having your app localized, but you just *may* in the future, you should keep your strings in the `res.yml` and `cmds.yml` file the root folder of your project, and they will be automatically copied to the output whenever you build your medusa.
|
||||||
|
|
||||||
|
**Example project folder structure:**
|
||||||
|
- uwu/
|
||||||
|
- uwu.csproj
|
||||||
|
- uwu.cs
|
||||||
|
- res.yml
|
||||||
|
- cmds.yml
|
||||||
|
|
||||||
|
**Example output folder structure:**
|
||||||
|
- medusae/uwu/
|
||||||
|
- uwu.dll
|
||||||
|
- res.yml
|
||||||
|
- cmds.yml
|
||||||
|
|
||||||
|
option 2) `strings` folder
|
||||||
|
|
||||||
|
If you plan on having your app localized (or want to allow your consumers to easily add languages themselves), you should keep your response strings in the `strings/res/en-us.yml` and your command strings in `strings/cmds/en-us.yml` file. This will be your base file, and from there you can make support for additional languages, for example `strings/res/ru-ru.yml` and `strings/cmds/ru-ru.yml`
|
||||||
|
|
||||||
|
**Example project folder structure:**
|
||||||
|
- uwu/
|
||||||
|
- uwu.csproj
|
||||||
|
- uwu.cs
|
||||||
|
- strings/
|
||||||
|
- res/
|
||||||
|
- en-us.yml
|
||||||
|
- ru-ru.yml
|
||||||
|
- cmds/
|
||||||
|
- en-us.yml
|
||||||
|
- ru-ru.yml
|
||||||
|
|
||||||
|
**Example output folder structure:**
|
||||||
|
- medusae/uwu/
|
||||||
|
- uwu.dll
|
||||||
|
- strings/
|
||||||
|
- res/
|
||||||
|
- en-us.yml
|
||||||
|
- ru-ru.yml
|
||||||
|
- cmds/
|
||||||
|
- en-us.yml
|
||||||
|
- ru-ru.yml
|
||||||
|
|
||||||
|
option 3) In the code
|
||||||
|
|
||||||
|
If you don't want any auxiliary files, and you don't want to bother making new .yml files to keep your strings in, you can specify the command strings directly in the `[cmd]` attribute itself, and use non-localized methods for message sending in your commands.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- Medusa config is kept in `data/medusae/medusa.yml` file in WizBot installation folder
|
||||||
|
- 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
|
||||||
|
|
||||||
|
### Unloadability issues
|
||||||
|
|
||||||
|
To make sure your medusa can be properly unloaded/reloaded you must:
|
||||||
|
|
||||||
|
- Make sure that none of your types and objects are referenced by the Bot or Bot's services after the DisposeAsync is called on your Snek instances.
|
||||||
|
|
||||||
|
- Make sure that all of your commands execute quickly and don't have any long running tasks, as they will hold a reference to a type from your assembly
|
||||||
|
|
||||||
|
- 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)
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Getting Started
|
||||||
|
|
||||||
|
## What is the Medusa system?
|
||||||
|
|
||||||
|
- It is a dynamic module/plugin/cog system for WizBot introduced in **WizBot 4.1.0**
|
||||||
|
|
||||||
|
- Allows developers to add custom functionality to Wiz without modifying the original code
|
||||||
|
|
||||||
|
- Allows for those custom features to be updated during bot runtime (if properly written), without the need for bot restart.
|
||||||
|
|
||||||
|
- They are added to `data/medusae` folder and are loaded, unloaded and handled through discord commands.
|
||||||
|
- `.meload` Loads the specified medusa (see `.h .meload`)
|
||||||
|
- `.meunload` Unloads the specified medusa (see `.h .meunload`)
|
||||||
|
- `.meinfo` Checks medusae information (see `.h .meinfo`)
|
||||||
|
- `.melist` Lists the available medusae (see `.h .melist`)
|
||||||
|
|
||||||
|
## How to make one?
|
||||||
|
|
||||||
|
Medusae are written in [C#](https://docs.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/) programming language, so you will need at least low-intermediate knowledge of it in order to make a useful Medusa.
|
||||||
|
|
||||||
|
Follow the [creating a medusa guide](creating-a-medusa.md)
|
||||||
|
|
||||||
|
## Where to get medusae other people made?
|
||||||
|
|
||||||
|
⚠ *It is EXTREMELY, and I repeat **EXTREMELY** dangerous to run medusae of strangers or people you don't FULLY trust.* ⚠
|
||||||
|
⚠ *It can not only lead to your bot being stolen, but it also puts your entire computer and personal files in jeopardy.* ⚠
|
||||||
|
|
||||||
|
**It is strongly recommended to run only the medusae you yourself wrote, and only on a hosted VPS or dedicated server which ONLY hosts your bot, to minimize the potential damage caused by bad actors.**
|
||||||
|
|
||||||
|
No easy way at the moment, except asking in the `#dev-and-modding` chat in [WizNet server](https://wizbot.cc/discord)
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Snek Lifecycle
|
||||||
|
|
||||||
|
*You can override several methods to hook into command handler's lifecycle.
|
||||||
|
These methods start with `Exec*`*
|
||||||
|
|
||||||
|
- `ExecOnMessageAsync` runs first right after any message was received
|
||||||
|
- `ExecInputTransformAsync` runs after ExecOnMessageAsync and allows you to transform the message content before the bot looks for the matching command
|
||||||
|
- `ExecPreCommandAsync` runs after a command was found but not executed, allowing you to potentially prevent command execution
|
||||||
|
- `ExecPostCommandAsync` runs if the command was successfully executed
|
||||||
|
- `ExecOnNoCommandAsync` runs instead of ExecPostCommandAsync if no command was found for a message
|
||||||
|
|
||||||
|
*Besides that, sneks have 2 methods with which you can initialize and cleanup your snek*
|
||||||
|
|
||||||
|
- `InitializeAsync` Runs when the medusa which contains this snek is being loaded
|
||||||
|
- `DisposeAsync` Runs when the medusa which contains this snek is being unloaded
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!-- TODO: These should potentially be reformated to be more readable... -->
|
||||||
|
--8<-- [start:windows]
|
||||||
|
- **Windows 10** or later (64-bit)
|
||||||
|
--8<-- [end:windows]
|
||||||
|
--8<-- [start:linux]
|
||||||
|
- **Ubuntu**: 20.04, 22.04, 24.04
|
||||||
|
- **Mint**: 19, 20, 21
|
||||||
|
- **Debian**: 10, 11, 12
|
||||||
|
- **RockyLinux**: 8, 9
|
||||||
|
- **AlmaLinux**: 8, 9
|
||||||
|
- **openSUSE Leap**: 15.5, 15.6
|
||||||
|
- **openSUSE Tumbleweed**
|
||||||
|
- **Fedora**: 38, 39, 40, 41, 42
|
||||||
|
- **Arch** & **Artix**
|
||||||
|
--8<-- [end:linux]
|
||||||
|
--8<-- [start:macos]
|
||||||
|
- **macOS 13 (Ventura)** or later
|
||||||
|
--8<-- [end:macos]
|
|
@ -1,4 +1,4 @@
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap');
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:ital,wght@0,200;0,300;0,400;0,600;0,700;0,900;1,200;1,300;1,400;1,600;1,700;1,900&display=swap');
|
||||||
|
|
||||||
/* general styling changes */
|
/* general styling changes */
|
|
@ -0,0 +1,85 @@
|
||||||
|
[data-md-color-scheme="wizbot-dark"] {
|
||||||
|
/* Default color shades */
|
||||||
|
--md-primary-fg-color: #590074;
|
||||||
|
--md-primary-fg-color--light: #964aad;
|
||||||
|
--md-primary-fg-color--dark: #964aad;
|
||||||
|
--md-default-bg-color: #0b0b0b;
|
||||||
|
--md-default-bg-color--light: #e8e8e8;
|
||||||
|
--md-default-fg-color: hsla(0, 75%, 95%, 1);
|
||||||
|
--md-default-fg-color--light: hsla(0, 0%, 100%, 0.849);
|
||||||
|
--md-default-fg-color--lighter: hsla(0, 0%, 100%, 0.32);
|
||||||
|
--md-default-fg-color--lightest: hsla(0, 0%, 100%, 0.12);
|
||||||
|
--md-accent-fg-color: #964aad !important;
|
||||||
|
--md-typeset-color: var(--md-default-fg-color);
|
||||||
|
--md-typeset-a-color: #964aad !important;
|
||||||
|
--md-typeset-mark-color: #448aff;
|
||||||
|
--md-typeset-kbd-color: hsla(220, 10%, 94%, 0.12);
|
||||||
|
--md-typeset-kbd-accent-color: hsla(220, 10%, 94%, 0.2);
|
||||||
|
--md-typeset-kbd-border-color: hsla(220, 10%, 14%, 1);
|
||||||
|
--md-admonition-bg-color: hsla(220, 10%, 100%, 0.025);
|
||||||
|
--md-admonition-fg-color: hsla(0, 75%, 95%, 1);
|
||||||
|
|
||||||
|
/* Code Color Shade */
|
||||||
|
--md-code-fg-color: rgb(255, 255, 255);
|
||||||
|
--md-code-bg-color: rgb(39, 39, 39);
|
||||||
|
--md-code-hl-color: rgb(255, 255, 0);
|
||||||
|
--md-code-hl-number-color: rgb(235, 88, 88);
|
||||||
|
--md-code-hl-special-color: rgb(241, 104, 150);
|
||||||
|
--md-code-hl-function-color: rgb(168, 70, 185);
|
||||||
|
--md-code-hl-constant-color: rgb(110, 89, 217);
|
||||||
|
--md-code-hl-keyword-color: rgb(63, 110, 198);
|
||||||
|
--md-code-hl-string-color: rgb(64, 168, 116);
|
||||||
|
--md-code-hl-name-color: rgb(54, 70, 78);
|
||||||
|
--md-code-hl-operator-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-punctuation-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-comment-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-generic-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-variable-color: rgba(255, 255, 255, 0.54);
|
||||||
|
|
||||||
|
/* Footer color shades */
|
||||||
|
--md-footer-bg-color: rgb(43, 44, 46) !important;
|
||||||
|
--md-footer-bg-color--dark: rgb(25, 26, 27) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-md-color-scheme="wizbot-light"] {
|
||||||
|
/* Default color shades */
|
||||||
|
--md-primary-fg-color: #590074;
|
||||||
|
--md-primary-fg-color--light: #964aad;
|
||||||
|
--md-primary-fg-color--dark: #964aad;
|
||||||
|
--md-default-bg-color: #e8e8e8;
|
||||||
|
--md-default-bg-color--light: #e8e8e8;
|
||||||
|
--md-default-fg-color: hsla(0, 0%, 0%, 1.5);
|
||||||
|
--md-default-fg-color--light: hsla(0deg, 0%, 0%, 85%);
|
||||||
|
--md-default-fg-color--lighter: hsla(0deg, 0%, 100%, 32%);
|
||||||
|
--md-default-fg-color--lightest: hsla(0deg, 0%, 100%, 12%);
|
||||||
|
--md-accent-fg-color: #964aad !important;
|
||||||
|
--md-typeset-color: var(--md-default-fg-color);
|
||||||
|
--md-typeset-a-color: #964aad !important;
|
||||||
|
--md-typeset-mark-color: #448aff;
|
||||||
|
--md-typeset-kbd-color: hsla(220, 10%, 94%, 0.12);
|
||||||
|
--md-typeset-kbd-accent-color: hsla(220, 10%, 94%, 0.2);
|
||||||
|
--md-typeset-kbd-border-color: hsla(220, 10%, 14%, 1);
|
||||||
|
--md-admonition-bg-color: hsla(220, 10%, 100%, 0.025);
|
||||||
|
--md-admonition-fg-color: rgba(0, 0, 0, 0.712);
|
||||||
|
|
||||||
|
/* Code Color Shade */
|
||||||
|
--md-code-fg-color: rgb(255, 255, 255);
|
||||||
|
--md-code-bg-color: rgb(39, 39, 39);
|
||||||
|
--md-code-hl-color: rgb(255, 255, 0);
|
||||||
|
--md-code-hl-number-color: rgb(235, 88, 88);
|
||||||
|
--md-code-hl-special-color: rgb(241, 104, 150);
|
||||||
|
--md-code-hl-function-color: rgb(168, 70, 185);
|
||||||
|
--md-code-hl-constant-color: rgb(110, 89, 217);
|
||||||
|
--md-code-hl-keyword-color: rgb(63, 110, 198);
|
||||||
|
--md-code-hl-string-color: rgb(64, 168, 116);
|
||||||
|
--md-code-hl-name-color: rgb(54, 70, 78);
|
||||||
|
--md-code-hl-operator-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-punctuation-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-comment-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-generic-color: rgba(255, 255, 255, 0.54);
|
||||||
|
--md-code-hl-variable-color: rgba(255, 255, 255, 0.54);
|
||||||
|
|
||||||
|
/* Footer color shades */
|
||||||
|
--md-footer-bg-color: rgb(43, 44, 46) !important;
|
||||||
|
--md-footer-bg-color--dark: rgb(25, 26, 27) !important;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
mkdocs-material~=9.6
|
||||||
|
mkdocs~=1.6
|
||||||
|
mkdocs-exclude~=1.0
|
|
@ -0,0 +1,86 @@
|
||||||
|
site_name: 'WizBot'
|
||||||
|
site_url: 'https://wizbot.cc'
|
||||||
|
repo_url: 'https://github.com/Wizkiller96/WizBot'
|
||||||
|
site_author: 'WizNet'
|
||||||
|
docs_dir: 'md'
|
||||||
|
|
||||||
|
copyright: © Copyright 2025 WizNet - All Rights Reserved.
|
||||||
|
|
||||||
|
theme:
|
||||||
|
name: material
|
||||||
|
palette:
|
||||||
|
- media: "(prefers-color-scheme: light)"
|
||||||
|
scheme: wizbot-light
|
||||||
|
toggle:
|
||||||
|
icon: material/weather-sunny
|
||||||
|
name: Switch to dark mode
|
||||||
|
- media: "(prefers-color-scheme: dark)"
|
||||||
|
scheme: wizbot-dark
|
||||||
|
toggle:
|
||||||
|
icon: material/weather-night
|
||||||
|
name: Switch to light mode
|
||||||
|
features:
|
||||||
|
- navigation.instant
|
||||||
|
- navigation.expand
|
||||||
|
- navigation.top
|
||||||
|
font:
|
||||||
|
text: Source Sans Pro
|
||||||
|
code: Source Code Pro
|
||||||
|
logo: https://wizbot.cc/img/wizbot-icon-887x889.png
|
||||||
|
favicon: https://wizbot.cc/img/wizbot-icon-887x889.png
|
||||||
|
icon:
|
||||||
|
repo: material/github
|
||||||
|
|
||||||
|
extra:
|
||||||
|
homepage: https://wizbot.cc
|
||||||
|
|
||||||
|
extra_javascript:
|
||||||
|
- https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js
|
||||||
|
|
||||||
|
extra_css:
|
||||||
|
- https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css
|
||||||
|
- stylesheets/styling-overrides.css
|
||||||
|
- stylesheets/theme.css
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- search
|
||||||
|
- exclude:
|
||||||
|
glob:
|
||||||
|
- 'guides/vps-linux-guide.md'
|
||||||
|
- 'snippets/supported-platforms.md'
|
||||||
|
|
||||||
|
markdown_extensions:
|
||||||
|
- attr_list
|
||||||
|
- codehilite:
|
||||||
|
guess_lang: false
|
||||||
|
- toc:
|
||||||
|
permalink: true
|
||||||
|
- pymdownx.betterem:
|
||||||
|
smart_enable: all
|
||||||
|
- admonition
|
||||||
|
- pymdownx.inlinehilite
|
||||||
|
- pymdownx.superfences
|
||||||
|
- pymdownx.blocks.tab:
|
||||||
|
alternate_style: true
|
||||||
|
- pymdownx.snippets
|
||||||
|
- pymdownx.details
|
||||||
|
- pymdownx.emoji:
|
||||||
|
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||||
|
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||||
|
|
||||||
|
nav:
|
||||||
|
- Home: index.md
|
||||||
|
- Guides:
|
||||||
|
- Desktop Guide: guides/desktop-guide.md
|
||||||
|
- CLI Guide: guides/cli-guide.md
|
||||||
|
- Docker Guide: guides/docker-guide.md
|
||||||
|
- Source Guide: guides/source-guide.md
|
||||||
|
- Commands:
|
||||||
|
- Commands List: https://wizbot.cc/commands
|
||||||
|
- Features Explained:
|
||||||
|
- Basic Creds: creds-guide.md
|
||||||
|
- Medusa System:
|
||||||
|
- medusa/getting-started.md
|
||||||
|
- medusa/creating-a-medusa.md
|
||||||
|
- medusa/snek-lifecycle.md
|
||||||
|
- Donate: donate.md
|
|
@ -1,9 +0,0 @@
|
||||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.0071 23.007L16.4231 9.41602H7.59106L12.0071 23.007Z" fill="white"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.007 23.007L7.59101 9.41602H1.4021L12.007 23.007Z" fill="white" fill-opacity="0.66"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.40214 9.41602L0.0601964 13.5462C-0.0622036 13.9229 0.0718535 14.3356 0.39231 14.5684L12.007 23.007L1.40214 9.41602Z" fill="white" fill-opacity="0.33"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M1.4021 9.41592H7.59101L4.93124 1.23021C4.79444 0.80895 4.19856 0.809064 4.06176 1.23021L1.4021 9.41592Z" fill="white"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.0071 23.007L16.4231 9.41602H22.612L12.0071 23.007Z" fill="white" fill-opacity="0.66"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.612 9.41602L23.9539 13.5462C24.0763 13.9229 23.9423 14.3356 23.6218 14.5684L12.0071 23.007L22.612 9.41602Z" fill="white" fill-opacity="0.33"/>
|
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M22.612 9.41592H16.4231L19.0829 1.23021C19.2197 0.80895 19.8156 0.809064 19.9524 1.23021L22.612 9.41592Z" fill="white"/>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1.2 KiB |
|
@ -1,94 +0,0 @@
|
||||||
# Permissions Overview
|
|
||||||
|
|
||||||
Have you ever felt confused or even overwhelmed when trying to set WizBot's permissions? In this guide we will be explaining **how to use the permission commands correctly** and even **cover a few common questions**! Every command we discuss here can be found in the [Commands List].
|
|
||||||
|
|
||||||
## Why do we use the Permissions Commands?
|
|
||||||
|
|
||||||
Permissions are very handy at setting who can use what commands in a server. All commands and modules are enabled by default. If something is a bot owner only command, it can only be ran by the bot owner, the person who is running the bot, or has their ID in the [creds.yml](creds-guide.md) file.
|
|
||||||
|
|
||||||
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, pick Cherry Blossoms or use the NSFW module.
|
|
||||||
|
|
||||||
## First Time Setup
|
|
||||||
|
|
||||||
To change permissions you **must** meet the following requirements:
|
|
||||||
|
|
||||||
**Have Administrator Server Permission.**
|
|
||||||
|
|
||||||
**If you are NOT the server owner or an admin, get the role set to `.permrole` (there is no permission role by default).**
|
|
||||||
|
|
||||||
## Basics & Hierarchy
|
|
||||||
|
|
||||||
The [Commands List] is a great tool which lists **all** available commands, however we'll go over a few of them here.
|
|
||||||
|
|
||||||
First, let's explain how the permissions system works - It's simple once you figure out how each command works!
|
|
||||||
The permissions system works as a chain. Everytime a command is used, the permissions chain is checked. Starting from the top of it, the command is compared to a rule, if it isn't either allowed or disallowed by that rule it proceeds to check the next rule all the way till it reaches the bottom rule, which allows all commands.
|
|
||||||
|
|
||||||
To view this permissions chain, do `.lp`. The rule at the top of the chain takes priority over all rules below it.
|
|
||||||
|
|
||||||
If you want to remove a permission from the chain of permissions, do `.rp X` to remove rule number X and similarly, do `.mp X Y` to move rule number X to number Y (moving, not swapping!).
|
|
||||||
|
|
||||||
If you want the bot to notify users why they can't use a command or module, use `.verbose true` and WizBot will tell you what rule is preventing the command from being used.
|
|
||||||
|
|
||||||
## Commonly Asked Questions
|
|
||||||
|
|
||||||
#### How do I restrict all commands to a single channel?
|
|
||||||
|
|
||||||
To allow users to only use commands in a specific text channel, follow these steps:
|
|
||||||
|
|
||||||
1. `.asm disable`
|
|
||||||
- Disables all modules on the entire server
|
|
||||||
2. `.acm enable #bot-spammerino`
|
|
||||||
- Enables all modules in the #bot-spammerino channel
|
|
||||||
|
|
||||||
#### How do I allow only one module to be used in a specific channel?
|
|
||||||
|
|
||||||
To allow users to only use commands from a certain module, let's say **gambling**, in a specific text channel, follow these steps:
|
|
||||||
|
|
||||||
1. `.acm disable #gamblers-den`
|
|
||||||
- Disables all modules in the #gamblers-den channel
|
|
||||||
2. `.cm Gambling enable #gamblers-den`
|
|
||||||
- Enables usage of the Gambling module in the #gamblers-den channel
|
|
||||||
|
|
||||||
#### How do I create a music DJ?
|
|
||||||
|
|
||||||
To allow users to only see the current song and have a DJ role for queuing follow these steps:
|
|
||||||
|
|
||||||
1. `.sm Music disable`
|
|
||||||
- Disables music commands for everybody
|
|
||||||
2. `.sc .nowplaying enable`
|
|
||||||
- Enables the "nowplaying" command for everyone
|
|
||||||
3. `.sc .listqueue enable`
|
|
||||||
- Enables the "listqueue" command for everyone
|
|
||||||
4. `.rm Music enable DJ`
|
|
||||||
- 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 custom reactions from triggering?
|
|
||||||
|
|
||||||
If you don't want server or global custom reactions, just block the module that controls their usage:
|
|
||||||
|
|
||||||
1. `.sm ActualCustomReactions disable`
|
|
||||||
- Disables the ActualCustomReactions module from being used
|
|
||||||
|
|
||||||
**Note**: The `ActualCustomReactions` module controls the usage of custom reactions. The `CustomReactions` module controls commands related to custom reactions (such as `.acr`, `.lcr`, `.crca`, etc).
|
|
||||||
|
|
||||||
#### I've broken permissions and am stuck, can I reset permissions?
|
|
||||||
|
|
||||||
Yes, there is a way, in one easy command!
|
|
||||||
|
|
||||||
1. `.resetperms`
|
|
||||||
- This resets the permission chain back to default
|
|
||||||
|
|
||||||
*-- Thanks to @applemac for providing the template for this guide*
|
|
||||||
|
|
||||||
[Commands List]: https://commands.wizbot.cc/
|
|
|
@ -1,94 +0,0 @@
|
||||||
# Placeholders
|
|
||||||
|
|
||||||
Placeholders are used in Quotes, Custom Reactions, Greet/Bye messages, playing statuses, and a few other places.
|
|
||||||
|
|
||||||
They can be used to make the message more user friendly, generate random numbers or pictures, etc.
|
|
||||||
|
|
||||||
Some features have their own specific placeholders which are noted in that feature's command help. Some placeholders are not available in certain features because they don't make sense there.
|
|
||||||
|
|
||||||
## Usual placeholders
|
|
||||||
|
|
||||||
!!! Note
|
|
||||||
If you're using placeholders in embeds, don't use %user.mention% and %bot.mention% in titles, footers and field names. They will not show properly.
|
|
||||||
|
|
||||||
### Bot placeholders
|
|
||||||
|
|
||||||
- `%bot.status%` - Bot's status (Online, Idle, DoNotDisturb, Invisible)
|
|
||||||
- `%bot.latency%` - Bot latency
|
|
||||||
- `%bot.name%` - Bot username
|
|
||||||
- `%bot.mention%` - Bot mention (clickable)
|
|
||||||
- `%bot.fullname%` - Bot username#discriminator
|
|
||||||
- `%bot.time%` - Bot time (usually the time of the server it's hosted on)
|
|
||||||
- `%bot.discrim%` - Bot's discriminator
|
|
||||||
- `%bot.id%` - Bot's user ID
|
|
||||||
- `%bot.avatar%` - Bot's avatar url
|
|
||||||
|
|
||||||
### Server placeholders
|
|
||||||
|
|
||||||
- `%server.id%` - Server ID
|
|
||||||
- `%server.name%` - Server name
|
|
||||||
- `%server.members%` - Member count
|
|
||||||
- `%server.time%` - Server time (requires `.timezone` to be set)
|
|
||||||
|
|
||||||
### Channel placeholders
|
|
||||||
|
|
||||||
- `%channel.mention%` - Channel mention (clickable)
|
|
||||||
- `%channel.name%` - Channel name
|
|
||||||
- `%channel.id%` - Channel ID
|
|
||||||
- `%channel.created%` - Channel creation date
|
|
||||||
- `%channel.nsfw%` - Returns either `True` or `False`, depending on if the channel is designated as NSFW using discord
|
|
||||||
- `%channel.topic%` - Channel topic
|
|
||||||
|
|
||||||
### User placeholders
|
|
||||||
|
|
||||||
- `%user.mention%` - User mention
|
|
||||||
- `%user.fullname%` - Username#discriminator
|
|
||||||
- `%user.name%` - Username
|
|
||||||
- `%user.discrim%` - Discriminator
|
|
||||||
- `%user.avatar%` - User's avatar url
|
|
||||||
- `%user.id%` - User ID
|
|
||||||
- `%user.created_time%` - Account creation time (local time)
|
|
||||||
- `%user.created_date%` - Account creation date
|
|
||||||
- `%user.joined_time%` - Account join time (local time)
|
|
||||||
- `%user.joined_date%` - Account join date
|
|
||||||
|
|
||||||
### Ban message placeholders
|
|
||||||
|
|
||||||
- `%ban.mod%` - Full name of the moderator who performed the ban
|
|
||||||
- `%ban.mod.fullname%` - Full name of the moderator who performed the ban
|
|
||||||
- `%ban.mod.mention%` - Moderator's mention
|
|
||||||
- `%ban.mod.name%` - Name of the moderator - Admin
|
|
||||||
- `%ban.mod.discrim%` - Discriminator of the moderator - 1234
|
|
||||||
- `%ban.user%` - Full name of the banned user
|
|
||||||
- `%ban.user.fullname%` - Full name of the banned user
|
|
||||||
- `%ban.user.name%` - Name of the banned user
|
|
||||||
- `%ban.user.discrim%` - Discriminator of the banned user
|
|
||||||
- `%ban.reason%` - Reason for the ban, if provided
|
|
||||||
- `%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.servercount%` - Server count on current shard
|
|
||||||
- `%shard.usercount%` - Combined user count on current shard
|
|
||||||
- `%shard.id%` - Shard ID
|
|
||||||
|
|
||||||
### Music placeholders
|
|
||||||
|
|
||||||
!!! Note
|
|
||||||
These placeholders will only work in rotating playing statuses.
|
|
||||||
|
|
||||||
- `%music.queued%` - Amount of songs currently queued
|
|
||||||
- `%music.playing%` - Current song name
|
|
||||||
|
|
||||||
### Miscellaneous placeholders
|
|
||||||
|
|
||||||
- `%rngX-Y%` - Returns a random number between X and Y
|
|
||||||
- `%target%` - Returns anything the user has written after the trigger (only works on custom reactions)
|
|
||||||
- `%img:stuff%` - Returns an `imgur.com` search for "stuff" (only works on custom reactions)
|
|
||||||
|
|
||||||

|
|
|
@ -1,90 +0,0 @@
|
||||||
[data-md-color-scheme="wizbot"] {
|
|
||||||
/* Default color shades */
|
|
||||||
--md-primary-fg-color: #590074;
|
|
||||||
--md-primary-fg-color--light: #590074;
|
|
||||||
--md-primary-fg-color--dark: #590074;
|
|
||||||
--md-default-bg-color: #0b0b0b;
|
|
||||||
--md-default-fg-color: hsla(0, 75%, 95%, 1);
|
|
||||||
--md-default-fg-color--light: hsla(0, 0%, 100%, 0.849);
|
|
||||||
--md-default-fg-color--lighter: hsla(0, 0%, 100%, 0.32);
|
|
||||||
--md-default-fg-color--lightest: hsla(0, 0%, 100%, 0.12);
|
|
||||||
--md-accent-fg-color: #590074 !important;
|
|
||||||
--md-typeset-a-color: #964aad !important;
|
|
||||||
|
|
||||||
/* Code Color Shade */
|
|
||||||
--md-code-fg-color: rgb(255, 255, 255);
|
|
||||||
--md-code-bg-color: rgb(39, 39, 39);
|
|
||||||
/*
|
|
||||||
--md-code-hl-color: rgb(255, 255, 0);
|
|
||||||
--md-code-hl-number-color: rgb(235, 88, 88);
|
|
||||||
--md-code-hl-special-color: rgb(241, 104, 150);
|
|
||||||
--md-code-hl-function-color: rgb(168, 70, 185);
|
|
||||||
--md-code-hl-constant-color: rgb(110, 89, 217);
|
|
||||||
--md-code-hl-keyword-color: rgb(63, 110, 198);
|
|
||||||
--md-code-hl-string-color: rgb(64, 168, 116);
|
|
||||||
--md-code-hl-name-color: rgb(54, 70, 78);
|
|
||||||
--md-code-hl-operator-color: rgba(0, 0, 0, 0.54);
|
|
||||||
--md-code-hl-punctuation-color: rgba(0, 0, 0, 0.54);
|
|
||||||
--md-code-hl-comment-color: rgba(0, 0, 0, 0.54);
|
|
||||||
--md-code-hl-generic-color: rgba(0, 0, 0, 0.54);
|
|
||||||
--md-code-hl-variable-color: rgba(0, 0, 0, 0.54); */
|
|
||||||
|
|
||||||
/* Footer color shades */
|
|
||||||
--md-footer-bg-color: rgb(43, 44, 46) !important;
|
|
||||||
--md-footer-bg-color--dark: rgb(25, 26, 27) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-md-color-scheme="dark"] {
|
|
||||||
--md-default-fg-color: hsl(220, 10%, 100%);
|
|
||||||
--md-default-fg-color--light: hsl(220, 10%, 87%);
|
|
||||||
--md-default-fg-color--lighter: hsl(220, 10%, 54%);
|
|
||||||
--md-default-fg-color--lightest: hsl(220, 10%, 32%);
|
|
||||||
--md-default-bg-color: hsl(220, 10%, 20%);
|
|
||||||
--md-default-bg-color--light: hsl(220, 10%, 16%);
|
|
||||||
--md-default-bg-color--lighter: hsl(220, 10%, 12%);
|
|
||||||
--md-default-bg-color--lightest: hsl(220, 10%, 8%);
|
|
||||||
--md-code-fg-color: hsla(220, 10%, 86%, 1);
|
|
||||||
--md-code-bg-color: hsla(220, 10%, 15%, 1);
|
|
||||||
--md-code-hl-color: #448aff;
|
|
||||||
--md-code-hl-number-color: #e6695b;
|
|
||||||
--md-code-hl-special-color: #f06090;
|
|
||||||
--md-code-hl-function-color: #c973d9;
|
|
||||||
--md-code-hl-constant-color: #9383e2;
|
|
||||||
--md-code-hl-keyword-color: #6791e0;
|
|
||||||
--md-code-hl-string-color: #2fb170;
|
|
||||||
--md-code-hl-name-color: var(--md-code-fg-color);
|
|
||||||
--md-code-hl-operator-color: var(--md-default-fg-color--light);
|
|
||||||
--md-code-hl-punctuation-color: var(--md-default-fg-color--light);
|
|
||||||
--md-code-hl-comment-color: var(--md-default-fg-color--light);
|
|
||||||
--md-code-hl-generic-color: var(--md-default-fg-color--light);
|
|
||||||
--md-code-hl-variable-color: var(--md-default-fg-color--light);
|
|
||||||
--md-typeset-color: var(--md-default-fg-color);
|
|
||||||
--md-typeset-a-color: var(--md-primary-fg-color);
|
|
||||||
--md-typeset-mark-color: #448aff;
|
|
||||||
--md-typeset-kbd-color: hsla(220, 10%, 94%, 0.12);
|
|
||||||
--md-typeset-kbd-accent-color: hsla(220, 10%, 94%, 0.2);
|
|
||||||
--md-typeset-kbd-border-color: hsla(220, 10%, 14%, 1);
|
|
||||||
--md-admonition-bg-color: hsla(220, 10%, 100%, 0.025);
|
|
||||||
--md-footer-bg-color: hsl(220, 10%, 16%);
|
|
||||||
--md-footer-bg-color--dark: hsl(220, 10%, 12%);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-md-color-scheme="dark"] .md-typeset {
|
|
||||||
color: var(--md-default-fg-color--light);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-md-color-scheme="dark"][data-md-color-primary="black"], [data-md-color-scheme="dark"][data-md-color-primary="white"] {
|
|
||||||
--md-typeset-a-color: var(--md-accent-fg-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-md-color-scheme="dark"] .md-header {
|
|
||||||
background: var(--md-default-bg-color--light);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-md-color-scheme="dark"] .md-nav__item :not(.md-nav__link--active) {
|
|
||||||
color: var(--md-default-fg-color--light);
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-md-color-scheme="dark"] .md-nav__item .md-nav__link:hover {
|
|
||||||
color: var(--md-primary-fg-color);
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
#define sysfolder "system"
|
|
||||||
#define version GetEnv("WIZBOT_INSTALL_VERSION")
|
|
||||||
#define target "win7-x64"
|
|
||||||
#define platform "net5.0"
|
|
||||||
|
|
||||||
[Setup]
|
|
||||||
AppName = {param:botname|WizBot}
|
|
||||||
AppVersion={#version}
|
|
||||||
AppPublisher=WizNet
|
|
||||||
DefaultDirName={param:installpath|{commonpf}\WizBot}
|
|
||||||
DefaultGroupName=WizBot
|
|
||||||
UninstallDisplayIcon={app}\{#sysfolder}\wizbot_icon.ico
|
|
||||||
Compression=lzma2
|
|
||||||
SolidCompression=yes
|
|
||||||
UsePreviousLanguage=no
|
|
||||||
UsePreviousSetupType=no
|
|
||||||
UsePreviousAppDir=no
|
|
||||||
OutputDir=wizbot-installers/{#version}/
|
|
||||||
OutputBaseFilename=wizbot-setup-{#version}
|
|
||||||
AppReadmeFile=https://commands.wizbot.cc/
|
|
||||||
ArchitecturesInstallIn64BitMode=x64
|
|
||||||
DisableWelcomePage=yes
|
|
||||||
DisableDirPage=yes
|
|
||||||
DisableFinishedPage=yes
|
|
||||||
DisableReadyMemo=yes
|
|
||||||
DisableProgramGroupPage=yes
|
|
||||||
WizardStyle=modern
|
|
||||||
UpdateUninstallLogAppName=no
|
|
||||||
CreateUninstallRegKey=no
|
|
||||||
Uninstallable=no
|
|
||||||
|
|
||||||
[Files]
|
|
||||||
;install
|
|
||||||
Source: "src\WizBot\bin\Release\{#platform}\{#target}\publish\*"; DestDir: "{app}\{#sysfolder}"; Permissions: users-full; Flags: recursesubdirs onlyifdoesntexist ignoreversion createallsubdirs; Excludes: "*.pdb, *.db"
|
|
||||||
|
|
||||||
;reinstall - i want to copy all files, but i don't want to overwrite any data files because users will lose their customization if they don't have a backup,
|
|
||||||
; and i don't want them to have to backup and then copy-merge into data folder themselves, or lose their currency images due to overwrite.
|
|
||||||
Source: "src\WizBot\bin\Release\{#platform}\{#target}\publish\*"; DestDir: "{app}\{#sysfolder}"; Permissions: users-full; Flags: recursesubdirs ignoreversion onlyifdestfileexists createallsubdirs; Excludes: "*.pdb, *.db, data\*, credentials.json, creds.yml";
|
|
||||||
Source: "src\WizBot\bin\Release\{#platform}\{#target}\publish\data\*"; DestDir: "{app}\{#sysfolder}\data"; Permissions: users-full; Flags: recursesubdirs onlyifdoesntexist createallsubdirs;
|
|
||||||
; overwrite strings and aliases
|
|
||||||
Source: "src\WizBot\bin\Release\{#platform}\{#target}\publish\data\aliases.yml"; DestDir: "{app}\{#sysfolder}\data\"; Permissions: users-full; Flags: recursesubdirs ignoreversion onlyifdestfileexists createallsubdirs;
|
|
||||||
Source: "src\WizBot\bin\Release\{#platform}\{#target}\publish\data\strings\*"; DestDir: "{app}\{#sysfolder}\data\strings"; Permissions: users-full; Flags: recursesubdirs ignoreversion onlyifdestfileexists createallsubdirs;
|
|
||||||
|
|
||||||
[Dirs]
|
|
||||||
Name:"{app}\{#sysfolder}\data"; Permissions: everyone-modify
|
|
||||||
Name:"{app}\{#sysfolder}\config"; Permissions: everyone-modify
|
|
||||||
Name:"{app}\{#sysfolder}"; Permissions: everyone-modify
|
|
||||||
|
|
||||||
; [Run]
|
|
||||||
; Filename: "http://wizbot.readthedocs.io/en/latest/jsons-explained/"; Flags: postinstall shellexec runasoriginaluser; Description: "Open setup guide"
|
|
||||||
; Filename: "{app}\{#sysfolder}\creds.yml"; Flags: postinstall shellexec runasoriginaluser; Description: "Open creds file"
|
|
||||||
|
|
||||||
[Icons]
|
|
||||||
; for pretty install directory
|
|
||||||
Name: "{app}\WizBot"; Filename: "{app}\{#sysfolder}\WizBot.exe"; IconFilename: "{app}\{#sysfolder}\wizbot_icon.ico"
|
|
||||||
Name: "{app}\creds"; Filename: "{app}\{#sysfolder}\creds.yml"
|
|
||||||
Name: "{app}\data"; Filename: "{app}\{#sysfolder}\data"
|
|
||||||
|
|
||||||
; desktop shortcut
|
|
||||||
Name: "{commondesktop}\{#SetupSetting("AppName")}"; Filename: "{app}\WizBot";
|
|
||||||
|
|
||||||
[Code]
|
|
||||||
function GetFileName(const AFileName: string): string;
|
|
||||||
begin
|
|
||||||
Result := ExpandConstant('{app}\{#sysfolder}\' + AFileName);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure CurStepChanged(CurStep: TSetupStep);
|
|
||||||
begin
|
|
||||||
if (CurStep = ssPostInstall) then
|
|
||||||
begin
|
|
||||||
FileCopy(GetFileName('creds_example.yml'), GetFileName('creds.yml'), True);
|
|
||||||
end;
|
|
||||||
end;
|
|
|
@ -1,4 +0,0 @@
|
||||||
mkdocs-material>=7.1.4
|
|
||||||
mkdocs>=1.1.2
|
|
||||||
mkdocs-git-revision-date-localized-plugin>=0.9.2
|
|
||||||
mkdocs-material-extensions>=1.0.1
|
|
86
mkdocs.yml
|
@ -1,86 +0,0 @@
|
||||||
site_name: 'WizBot'
|
|
||||||
site_url: 'https://wizbot.cc'
|
|
||||||
repo_name: 'Wizkiller96/WizBot'
|
|
||||||
repo_url: 'https://github.com/Wizkiller96/WizBot'
|
|
||||||
site_author: 'Kwoth & Wizkiller96'
|
|
||||||
edit_uri: 'edit/v3/docs/'
|
|
||||||
|
|
||||||
copyright: © Copyright 2021 WizNet - All Rights Reserved.
|
|
||||||
|
|
||||||
theme:
|
|
||||||
name: material
|
|
||||||
palette:
|
|
||||||
scheme: 'wizbot'
|
|
||||||
features:
|
|
||||||
- navigation.instant
|
|
||||||
- navigation.expand
|
|
||||||
- navigation.top
|
|
||||||
font:
|
|
||||||
text: Source Sans Pro
|
|
||||||
code: Source Code Pro
|
|
||||||
logo: https://wizbot.cc/assets/img/wizbot-icon-887x889.png
|
|
||||||
favicon: https://wizbot.cc/assets/img/wizbot-icon-887x889.png
|
|
||||||
|
|
||||||
extra:
|
|
||||||
homepage: https://wizbot.cc
|
|
||||||
|
|
||||||
extra_javascript:
|
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js
|
|
||||||
- javascripts/config.js
|
|
||||||
|
|
||||||
extra_css:
|
|
||||||
- https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/atom-one-dark.min.css
|
|
||||||
- stylesheets/styling-overrides.css
|
|
||||||
- stylesheets/theme.css
|
|
||||||
|
|
||||||
plugins:
|
|
||||||
- git-revision-date-localized:
|
|
||||||
type: date
|
|
||||||
- search
|
|
||||||
|
|
||||||
markdown_extensions:
|
|
||||||
- attr_list
|
|
||||||
- codehilite:
|
|
||||||
guess_lang: false
|
|
||||||
- toc:
|
|
||||||
permalink: true
|
|
||||||
- pymdownx.tasklist:
|
|
||||||
custom_checkbox: true
|
|
||||||
- pymdownx.betterem:
|
|
||||||
smart_enable: all
|
|
||||||
- admonition
|
|
||||||
- meta
|
|
||||||
- footnotes
|
|
||||||
- pymdownx.details
|
|
||||||
- pymdownx.inlinehilite
|
|
||||||
- pymdownx.superfences
|
|
||||||
- pymdownx.tabbed
|
|
||||||
- pymdownx.emoji:
|
|
||||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
|
||||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
|
||||||
options:
|
|
||||||
custom_icons:
|
|
||||||
- docs/overrides/.icons
|
|
||||||
|
|
||||||
nav:
|
|
||||||
- Home: index.md
|
|
||||||
- Guides:
|
|
||||||
- ❗ Migration Guide: guides/migration-guide.md
|
|
||||||
- Windows Guide: guides/windows-guide.md
|
|
||||||
- Linux Guide: guides/linux-guide.md
|
|
||||||
- OSX Guide: guides/osx-guide.md
|
|
||||||
- Docker Guide (unsupported): guides/docker-guide.md
|
|
||||||
- Commands:
|
|
||||||
- Readme: commands-readme.md
|
|
||||||
- Commands List: https://commands.wizbot.cc/
|
|
||||||
- Features Explained:
|
|
||||||
- Basic Creds: creds-guide.md
|
|
||||||
- Advanced Creds: jsons-explained.md
|
|
||||||
- Permissions System: permissions-system.md
|
|
||||||
- Custom Reactions: custom-reactions.md
|
|
||||||
- Placeholders: placeholders.md
|
|
||||||
- Config: config-guide.md
|
|
||||||
- Bot Config: bce-guide.md
|
|
||||||
- Contribution Guide: contribution-guide.md
|
|
||||||
- Donate: donate.md
|
|
||||||
- License: license.md
|
|
63
release.ps1
|
@ -1,63 +0,0 @@
|
||||||
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:WIZBOT_INSTALL_VERSION = $versionNumber
|
|
||||||
|
|
||||||
dotnet clean
|
|
||||||
# rm -r -fo "src\WizBot\bin"
|
|
||||||
dotnet publish -c Release --runtime win7-x64 /p:Version=$versionNumber src/WizBot
|
|
||||||
# .\rcedit-x64.exe "src\WizBot\bin\Release\netcoreapp2.1\win7-x64\wizbot.exe" --set-icon "src\WizBot\bin\Release\netcoreapp2.1\win7-x64\wizbot_icon.ico"
|
|
||||||
|
|
||||||
& "iscc.exe" "/O+" ".\exe_builder.iss"
|
|
||||||
|
|
||||||
Write-ReleaseFile($versionNumber)
|
|
||||||
# $path = [Environment]::GetFolderPath('MyDocuments') + "\_projekti\new_installer\$versionNumber\";
|
|
||||||
# $binPath = $path + "wizbot-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://wizbot.cc/downloads/bot/wizbot-setup-$versionNumber.exe"", ""Changelog"": """"}]"
|
|
||||||
|
|
||||||
$releaseJsonOutPath = [Environment]::GetFolderPath('MyDocuments') + "\_projekti\wizbot-installers\$versionNumber\"
|
|
||||||
New-Item -Path $releaseJsonOutPath -Value $jsonReleaseFile -Name "releases.json" -Force
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
[{ "VersionName":"_VERSION_", "DownloadLink":"https://wizbot.cc/downloads/bot/_INSTALLER_FILE_NAME_" }]
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overridden to implement custom checks which commands have to pass in order to be executed.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
|
||||||
|
public abstract class FilterAttribute : Attribute
|
||||||
|
{
|
||||||
|
public abstract ValueTask<bool> CheckAsync(AnyContext ctx);
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used as a marker class for bot_perm and user_perm Attributes
|
||||||
|
/// Has no functionality.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class MedusaPermAttribute : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Method)]
|
||||||
|
public sealed class bot_owner_onlyAttribute : MedusaPermAttribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace WizBot.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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks a method as a snek command
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Method)]
|
||||||
|
public class cmdAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Command description. Avoid using, as cmds.yml is preferred
|
||||||
|
/// </summary>
|
||||||
|
public string? desc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command args examples. Avoid using, as cmds.yml is preferred
|
||||||
|
/// </summary>
|
||||||
|
public string[]? args { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command aliases
|
||||||
|
/// </summary>
|
||||||
|
public string[] Aliases { get; }
|
||||||
|
|
||||||
|
public cmdAttribute()
|
||||||
|
{
|
||||||
|
desc = null;
|
||||||
|
args = null;
|
||||||
|
Aliases = Array.Empty<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public cmdAttribute(params string[] aliases)
|
||||||
|
{
|
||||||
|
Aliases = aliases;
|
||||||
|
desc = null;
|
||||||
|
args = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks services in command arguments for injection.
|
||||||
|
/// The injected services must come after the context and before any input parameters.
|
||||||
|
/// </summary>
|
||||||
|
public class injectAttribute : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks the parameter to take
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Parameter)]
|
||||||
|
public class leftoverAttribute : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the priority of a command in case there are multiple commands with the same name but different parameters.
|
||||||
|
/// Higher value means higher priority.
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Method)]
|
||||||
|
public class prioAttribute : Attribute
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Snek command priority
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="priority">Priority value. The higher the value, the higher the priority</param>
|
||||||
|
public prioAttribute(int priority)
|
||||||
|
{
|
||||||
|
Priority = priority;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks the class as a service which can be used within the same Medusa
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public class svcAttribute : Attribute
|
||||||
|
{
|
||||||
|
public Lifetime Lifetime { get; }
|
||||||
|
public svcAttribute(Lifetime lifetime)
|
||||||
|
{
|
||||||
|
Lifetime = lifetime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lifetime for <see cref="svcAttribute"/>
|
||||||
|
/// </summary>
|
||||||
|
public enum Lifetime
|
||||||
|
{
|
||||||
|
Singleton,
|
||||||
|
Transient
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace WizBot.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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Commands which take this class as a first parameter can be executed in both DMs and Servers
|
||||||
|
/// </summary>
|
||||||
|
public abstract class AnyContext
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Channel from the which the command is invoked
|
||||||
|
/// </summary>
|
||||||
|
public abstract IMessageChannel Channel { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Message which triggered the command
|
||||||
|
/// </summary>
|
||||||
|
public abstract IUserMessage Message { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The user who invoked the command
|
||||||
|
/// </summary>
|
||||||
|
public abstract IUser User { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bot user
|
||||||
|
/// </summary>
|
||||||
|
public abstract ISelfUser Bot { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides access to strings used by this medusa
|
||||||
|
/// </summary>
|
||||||
|
public abstract IMedusaStrings Strings { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a formatted localized string using a key and arguments which should be formatted in
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The key of the string as specified in localization files</param>
|
||||||
|
/// <param name="args">Arguments (if any) to format in</param>
|
||||||
|
/// <returns>A formatted localized string</returns>
|
||||||
|
public abstract string GetText(string key, object[]? args = null);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Commands which take this type as the first parameter can only be executed in DMs
|
||||||
|
/// </summary>
|
||||||
|
public abstract class DmContext : AnyContext
|
||||||
|
{
|
||||||
|
public abstract override IDMChannel Channel { get; }
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Commands which take this type as a first parameter can only be executed in a server
|
||||||
|
/// </summary>
|
||||||
|
public abstract class GuildContext : AnyContext
|
||||||
|
{
|
||||||
|
public abstract override ITextChannel Channel { get; }
|
||||||
|
public abstract IGuild Guild { get; }
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace WizBot;
|
||||||
|
|
||||||
|
public enum EmbedColor
|
||||||
|
{
|
||||||
|
Ok,
|
||||||
|
Pending,
|
||||||
|
Error
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
public static class MedusaExtensions
|
||||||
|
{
|
||||||
|
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, EmbedBuilder embed, string msg = "")
|
||||||
|
=> ch.SendMessageAsync(msg,
|
||||||
|
embed: embed.Build(),
|
||||||
|
options: new()
|
||||||
|
{
|
||||||
|
RetryMode = RetryMode.Retry502
|
||||||
|
});
|
||||||
|
|
||||||
|
// unlocalized
|
||||||
|
public static Task<IUserMessage> SendConfirmAsync(this AnyContext ctx, string msg)
|
||||||
|
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||||
|
.WithColor(0, 200, 0)
|
||||||
|
.WithDescription(msg));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> SendPendingAsync(this AnyContext ctx, string msg)
|
||||||
|
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||||
|
.WithColor(200, 200, 0)
|
||||||
|
.WithDescription(msg));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> SendErrorAsync(this AnyContext ctx, string msg)
|
||||||
|
=> ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||||
|
.WithColor(200, 0, 0)
|
||||||
|
.WithDescription(msg));
|
||||||
|
|
||||||
|
// localized
|
||||||
|
public static Task ConfirmAsync(this AnyContext ctx)
|
||||||
|
=> ctx.Message.AddReactionAsync(new Emoji("✅"));
|
||||||
|
|
||||||
|
public static Task ErrorAsync(this AnyContext ctx)
|
||||||
|
=> ctx.Message.AddReactionAsync(new Emoji("❌"));
|
||||||
|
|
||||||
|
public static Task WarningAsync(this AnyContext ctx)
|
||||||
|
=> ctx.Message.AddReactionAsync(new Emoji("⚠️"));
|
||||||
|
|
||||||
|
public static Task WaitAsync(this AnyContext ctx)
|
||||||
|
=> ctx.Message.AddReactionAsync(new Emoji("🤔"));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> ErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||||
|
=> ctx.SendErrorAsync(ctx.GetText(key, args));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> PendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||||
|
=> ctx.SendPendingAsync(ctx.GetText(key, args));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> ConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||||
|
=> ctx.SendConfirmAsync(ctx.GetText(key, args));
|
||||||
|
|
||||||
|
public static Task<IUserMessage> ReplyErrorLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||||
|
=> ctx.SendErrorAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||||
|
|
||||||
|
public static Task<IUserMessage> ReplyPendingLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||||
|
=> ctx.SendPendingAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||||
|
|
||||||
|
public static Task<IUserMessage> ReplyConfirmLocalizedAsync(this AnyContext ctx, string key, params object[]? args)
|
||||||
|
=> ctx.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} {ctx.GetText(key, args)}");
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overridden to implement parsers for custom types
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type into which to parse the input</typeparam>
|
||||||
|
public abstract class ParamParser<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Overridden to implement parsing logic
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ctx">Context</param>
|
||||||
|
/// <param name="input">Input to parse</param>
|
||||||
|
/// <returns>A <see cref="ParseResult{T}"/> with successful or failed status</returns>
|
||||||
|
public abstract ValueTask<ParseResult<T>> TryParseAsync(AnyContext ctx, string input);
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
public readonly struct ParseResult<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the parsing was successful
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSuccess { get; private init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parsed value. It should only have value if <see cref="IsSuccess"/> is set to true
|
||||||
|
/// </summary>
|
||||||
|
public T? Data { get; private init; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiate a **successful** parse result
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Parsed value</param>
|
||||||
|
public ParseResult(T data)
|
||||||
|
{
|
||||||
|
Data = data;
|
||||||
|
IsSuccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new <see cref="ParseResult{T}"/> with IsSuccess = false
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A new <see cref="ParseResult{T}"/></returns>
|
||||||
|
public static ParseResult<T> Fail()
|
||||||
|
=> new ParseResult<T>
|
||||||
|
{
|
||||||
|
IsSuccess = false,
|
||||||
|
Data = default,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new <see cref="ParseResult{T}"/> with IsSuccess = true
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">Value of the parsed object</param>
|
||||||
|
/// <returns>A new <see cref="ParseResult{T}"/></returns>
|
||||||
|
public static ParseResult<T> Success(T obj)
|
||||||
|
=> new ParseResult<T>
|
||||||
|
{
|
||||||
|
IsSuccess = true,
|
||||||
|
Data = obj,
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
This is the library which is the base of any medusa.
|
|
@ -0,0 +1,143 @@
|
||||||
|
using Discord;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The base class which will be loaded as a module into WizBot
|
||||||
|
/// Any user-defined snek has to inherit from this class.
|
||||||
|
/// Sneks get instantiated ONLY ONCE during the loading,
|
||||||
|
/// and any snek commands will be executed on the same instance.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class Snek : IAsyncDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the snek. Defaults to the lowercase class name
|
||||||
|
/// </summary>
|
||||||
|
public virtual string Name
|
||||||
|
=> GetType().Name.ToLowerInvariant();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The prefix required before the command name. For example
|
||||||
|
/// if you set this to 'test' then a command called 'cmd' will have to be invoked by using
|
||||||
|
/// '.test cmd' instead of `.cmd`
|
||||||
|
/// </summary>
|
||||||
|
public virtual string Prefix
|
||||||
|
=> string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executed once this snek has been instantiated and before any command is executed.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A <see cref="ValueTask"/> representing completion</returns>
|
||||||
|
public virtual ValueTask InitializeAsync()
|
||||||
|
=> default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Override to cleanup any resources or references which might hold this snek in memory
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual ValueTask DisposeAsync()
|
||||||
|
=> default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called right after the message was received by the bot.
|
||||||
|
/// You can use this method to make the bot conditionally ignore some messages and prevent further processing.
|
||||||
|
/// <para>Execution order:</para>
|
||||||
|
/// <para>
|
||||||
|
/// *<see cref="ExecOnMessageAsync"/>* →
|
||||||
|
/// <see cref="ExecInputTransformAsync"/> →
|
||||||
|
/// <see cref="ExecPreCommandAsync"/> →
|
||||||
|
/// <see cref="ExecPostCommandAsync"/> OR <see cref="ExecOnNoCommandAsync"/>
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="guild">Guild in which the message was sent</param>
|
||||||
|
/// <param name="msg">Message received by the bot</param>
|
||||||
|
/// <returns>A <see cref="ValueTask"/> representing whether the message should be ignored and not processed further</returns>
|
||||||
|
public virtual ValueTask<bool> ExecOnMessageAsync(IGuild? guild, IUserMessage msg)
|
||||||
|
=> default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Override this method to modify input before the bot searches for any commands matching the input
|
||||||
|
/// Executed after <see cref="ExecOnMessageAsync"/>
|
||||||
|
/// This is useful if you want to reinterpret the message under some conditions
|
||||||
|
/// <para>Execution order:</para>
|
||||||
|
/// <para>
|
||||||
|
/// <see cref="ExecOnMessageAsync"/> →
|
||||||
|
/// *<see cref="ExecInputTransformAsync"/>* →
|
||||||
|
/// <see cref="ExecPreCommandAsync"/> →
|
||||||
|
/// <see cref="ExecPostCommandAsync"/> OR <see cref="ExecOnNoCommandAsync"/>
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="guild">Guild in which the message was sent</param>
|
||||||
|
/// <param name="channel">Channel in which the message was sent</param>
|
||||||
|
/// <param name="user">User who sent the message</param>
|
||||||
|
/// <param name="input">Content of the message</param>
|
||||||
|
/// <returns>A <see cref="ValueTask"/> representing new, potentially modified content</returns>
|
||||||
|
public virtual ValueTask<string?> ExecInputTransformAsync(
|
||||||
|
IGuild? guild,
|
||||||
|
IMessageChannel channel,
|
||||||
|
IUser user,
|
||||||
|
string input
|
||||||
|
)
|
||||||
|
=> default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called after the command was found but not executed,
|
||||||
|
/// and can be used to prevent the command's execution.
|
||||||
|
/// The command information doesn't have to be from this snek as this method
|
||||||
|
/// will be called when *any* command from any module or snek was found.
|
||||||
|
/// You can choose to prevent the execution of the command by returning "true" value.
|
||||||
|
/// <para>Execution order:</para>
|
||||||
|
/// <para>
|
||||||
|
/// <see cref="ExecOnMessageAsync"/> →
|
||||||
|
/// <see cref="ExecInputTransformAsync"/> →
|
||||||
|
/// *<see cref="ExecPreCommandAsync"/>* →
|
||||||
|
/// <see cref="ExecPostCommandAsync"/> OR <see cref="ExecOnNoCommandAsync"/>
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context">Command context</param>
|
||||||
|
/// <param name="moduleName">Name of the snek or module from which the command originates</param>
|
||||||
|
/// <param name="commandName">Name of the command which is about to be executed</param>
|
||||||
|
/// <returns>A <see cref="ValueTask"/> representing whether the execution should be blocked</returns>
|
||||||
|
public virtual ValueTask<bool> ExecPreCommandAsync(
|
||||||
|
AnyContext context,
|
||||||
|
string moduleName,
|
||||||
|
string commandName
|
||||||
|
)
|
||||||
|
=> default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called after the command was succesfully executed.
|
||||||
|
/// If this method was called, then <see cref="ExecOnNoCommandAsync"/> will not be executed
|
||||||
|
/// <para>Execution order:</para>
|
||||||
|
/// <para>
|
||||||
|
/// <see cref="ExecOnMessageAsync"/> →
|
||||||
|
/// <see cref="ExecInputTransformAsync"/> →
|
||||||
|
/// <see cref="ExecPreCommandAsync"/> →
|
||||||
|
/// *<see cref="ExecPostCommandAsync"/>* OR <see cref="ExecOnNoCommandAsync"/>
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A <see cref="ValueTask"/> representing completion</returns>
|
||||||
|
public virtual ValueTask ExecPostCommandAsync(AnyContext ctx, string moduleName, string commandName)
|
||||||
|
=> default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is called if no command was found for the input.
|
||||||
|
/// Useful if you want to have games or features which take arbitrary input
|
||||||
|
/// but ignore any messages which were blocked or caused a command execution
|
||||||
|
/// If this method was called, then <see cref="ExecPostCommandAsync"/> will not be executed
|
||||||
|
/// <para>Execution order:</para>
|
||||||
|
/// <para>
|
||||||
|
/// <see cref="ExecOnMessageAsync"/> →
|
||||||
|
/// <see cref="ExecInputTransformAsync"/> →
|
||||||
|
/// <see cref="ExecPreCommandAsync"/> →
|
||||||
|
/// <see cref="ExecPostCommandAsync"/> OR *<see cref="ExecOnNoCommandAsync"/>*
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A <see cref="ValueTask"/> representing completion</returns>
|
||||||
|
public virtual ValueTask ExecOnNoCommandAsync(IGuild? guild, IUserMessage msg)
|
||||||
|
=> default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly struct ExecResponse
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
public readonly struct CommandStrings
|
||||||
|
{
|
||||||
|
public CommandStrings(string? desc, string[]? args)
|
||||||
|
{
|
||||||
|
Desc = desc;
|
||||||
|
Args = args;
|
||||||
|
}
|
||||||
|
|
||||||
|
[YamlMember(Alias = "desc")]
|
||||||
|
public string? Desc { get; init; }
|
||||||
|
|
||||||
|
[YamlMember(Alias = "args")]
|
||||||
|
public string[]? Args { get; init; }
|
||||||
|
|
||||||
|
public void Deconstruct(out string? desc, out string[]? args)
|
||||||
|
{
|
||||||
|
desc = Desc;
|
||||||
|
args = Args;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines methods to retrieve and reload medusa strings
|
||||||
|
/// </summary>
|
||||||
|
public interface IMedusaStrings
|
||||||
|
{
|
||||||
|
// string GetText(string key, ulong? guildId = null, params object[] data);
|
||||||
|
string? GetText(string key, CultureInfo locale, params object[] data);
|
||||||
|
void Reload();
|
||||||
|
CommandStrings GetCommandStrings(string commandName, CultureInfo cultureInfo);
|
||||||
|
string? GetDescription(CultureInfo? locale);
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implemented by classes which provide localized strings in their own ways
|
||||||
|
/// </summary>
|
||||||
|
public interface IMedusaStringsProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets localized string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localeName">Language name</param>
|
||||||
|
/// <param name="key">String key</param>
|
||||||
|
/// <returns>Localized string</returns>
|
||||||
|
string? GetText(string localeName, string key);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reloads string cache
|
||||||
|
/// </summary>
|
||||||
|
void Reload();
|
||||||
|
|
||||||
|
// /// <summary>
|
||||||
|
// /// Gets command arg examples and description
|
||||||
|
// /// </summary>
|
||||||
|
// /// <param name="localeName">Language name</param>
|
||||||
|
// /// <param name="commandName">Command name</param>
|
||||||
|
// CommandStrings GetCommandStrings(string localeName, string commandName);
|
||||||
|
CommandStrings? GetCommandStrings(string localeName, string commandName);
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
public class LocalMedusaStringsProvider : IMedusaStringsProvider
|
||||||
|
{
|
||||||
|
private readonly StringsLoader _source;
|
||||||
|
private IReadOnlyDictionary<string, IReadOnlyDictionary<string, string>> _responseStrings;
|
||||||
|
private IReadOnlyDictionary<string, IReadOnlyDictionary<string, CommandStrings>> _commandStrings;
|
||||||
|
|
||||||
|
public LocalMedusaStringsProvider(StringsLoader source)
|
||||||
|
{
|
||||||
|
_source = source;
|
||||||
|
_responseStrings = _source.GetResponseStrings();
|
||||||
|
_commandStrings = _source.GetCommandStrings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reload()
|
||||||
|
{
|
||||||
|
_responseStrings = _source.GetResponseStrings();
|
||||||
|
_commandStrings = _source.GetCommandStrings();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string? GetText(string localeName, string key)
|
||||||
|
{
|
||||||
|
if (_responseStrings.TryGetValue(localeName.ToLowerInvariant(), out var langStrings)
|
||||||
|
&& langStrings.TryGetValue(key.ToLowerInvariant(), out var text))
|
||||||
|
return text;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandStrings? GetCommandStrings(string localeName, string commandName)
|
||||||
|
{
|
||||||
|
if (_commandStrings.TryGetValue(localeName.ToLowerInvariant(), out var langStrings)
|
||||||
|
&& langStrings.TryGetValue(commandName.ToLowerInvariant(), out var strings))
|
||||||
|
return strings;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
using System.Globalization;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
public class MedusaStrings : IMedusaStrings
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used as failsafe in case response key doesn't exist in the selected or default language.
|
||||||
|
/// </summary>
|
||||||
|
private readonly CultureInfo _usCultureInfo = new("en-US");
|
||||||
|
|
||||||
|
private readonly IMedusaStringsProvider _stringsProvider;
|
||||||
|
|
||||||
|
public MedusaStrings(IMedusaStringsProvider stringsProvider)
|
||||||
|
{
|
||||||
|
_stringsProvider = stringsProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string? GetString(string key, CultureInfo cultureInfo)
|
||||||
|
=> _stringsProvider.GetText(cultureInfo.Name, key);
|
||||||
|
|
||||||
|
public string? GetText(string key, CultureInfo cultureInfo)
|
||||||
|
=> GetString(key, cultureInfo)
|
||||||
|
?? GetString(key, _usCultureInfo);
|
||||||
|
|
||||||
|
public string? GetText(string key, CultureInfo cultureInfo, params object[] data)
|
||||||
|
{
|
||||||
|
var text = GetText(key, cultureInfo);
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return string.Format(text, data);
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
Log.Warning(" Key '{Key}' is not properly formatted in '{LanguageName}' response strings",
|
||||||
|
key,
|
||||||
|
cultureInfo.Name);
|
||||||
|
|
||||||
|
return $"⚠️ Response string key '{key}' is not properly formatted. Please report this.\n\n{text}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandStrings GetCommandStrings(string commandName, CultureInfo cultureInfo)
|
||||||
|
{
|
||||||
|
var cmdStrings = _stringsProvider.GetCommandStrings(cultureInfo.Name, commandName);
|
||||||
|
if (cmdStrings is null)
|
||||||
|
{
|
||||||
|
if (cultureInfo.Name == _usCultureInfo.Name)
|
||||||
|
{
|
||||||
|
Log.Warning("'{CommandName}' doesn't exist in 'en-US' command strings for one of the medusae",
|
||||||
|
commandName);
|
||||||
|
|
||||||
|
return new(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Information("Missing '{CommandName}' command strings for the '{LocaleName}' locale",
|
||||||
|
commandName,
|
||||||
|
cultureInfo.Name);
|
||||||
|
|
||||||
|
return GetCommandStrings(commandName, _usCultureInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmdStrings.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? GetDescription(CultureInfo? locale = null)
|
||||||
|
=> GetText("medusa.description", locale ?? _usCultureInfo);
|
||||||
|
|
||||||
|
public static MedusaStrings CreateDefault(string basePath)
|
||||||
|
=> new MedusaStrings(new LocalMedusaStringsProvider(new(basePath)));
|
||||||
|
|
||||||
|
public void Reload()
|
||||||
|
=> _stringsProvider.Reload();
|
||||||
|
}
|
|
@ -0,0 +1,137 @@
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Serilog;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
|
namespace WizBot.Medusa;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads strings from the shortcut or localizable path
|
||||||
|
/// </summary>
|
||||||
|
public class StringsLoader
|
||||||
|
{
|
||||||
|
private readonly string _localizableResponsesPath;
|
||||||
|
private readonly string _shortcutResponsesFile;
|
||||||
|
|
||||||
|
private readonly string _localizableCommandsPath;
|
||||||
|
private readonly string _shortcutCommandsFile;
|
||||||
|
|
||||||
|
public StringsLoader(string basePath)
|
||||||
|
{
|
||||||
|
_localizableResponsesPath = Path.Join(basePath, "strings/res");
|
||||||
|
_shortcutResponsesFile = Path.Join(basePath, "res.yml");
|
||||||
|
|
||||||
|
_localizableCommandsPath = Path.Join(basePath, "strings/cmds");
|
||||||
|
_shortcutCommandsFile = Path.Join(basePath, "cmds.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
public IReadOnlyDictionary<string, IReadOnlyDictionary<string, CommandStrings>> GetCommandStrings()
|
||||||
|
{
|
||||||
|
var outputDict = new Dictionary<string, IReadOnlyDictionary<string, CommandStrings>>();
|
||||||
|
|
||||||
|
if (File.Exists(_shortcutCommandsFile))
|
||||||
|
{
|
||||||
|
if (TryLoadCommandsFromFile(_shortcutCommandsFile, out var dict, out _))
|
||||||
|
{
|
||||||
|
outputDict["en-us"] = dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(_localizableCommandsPath))
|
||||||
|
{
|
||||||
|
foreach (var cmdsFile in Directory.EnumerateFiles(_localizableCommandsPath))
|
||||||
|
{
|
||||||
|
if (TryLoadCommandsFromFile(cmdsFile, out var dict, out var locale) && locale is not null)
|
||||||
|
{
|
||||||
|
outputDict[locale.ToLowerInvariant()] = dict;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static readonly IDeserializer _deserializer = new DeserializerBuilder().Build();
|
||||||
|
private static bool TryLoadCommandsFromFile(string file,
|
||||||
|
[NotNullWhen(true)] out IReadOnlyDictionary<string, CommandStrings>? strings,
|
||||||
|
out string? localeName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var text = File.ReadAllText(file);
|
||||||
|
strings = _deserializer.Deserialize<Dictionary<string, CommandStrings>?>(text)
|
||||||
|
?? new();
|
||||||
|
localeName = GetLocaleName(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Error loading {FileName} command strings: {ErrorMessage}", file, ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
strings = null;
|
||||||
|
localeName = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public IReadOnlyDictionary<string, IReadOnlyDictionary<string, string>> GetResponseStrings()
|
||||||
|
{
|
||||||
|
var outputDict = new Dictionary<string, IReadOnlyDictionary<string, string>>();
|
||||||
|
|
||||||
|
// try to load a shortcut file
|
||||||
|
if (File.Exists(_shortcutResponsesFile))
|
||||||
|
{
|
||||||
|
if (TryLoadResponsesFromFile(_shortcutResponsesFile, out var dict, out _))
|
||||||
|
{
|
||||||
|
outputDict["en-us"] = dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(_localizableResponsesPath))
|
||||||
|
return outputDict;
|
||||||
|
|
||||||
|
// if shortcut file doesn't exist, try to load localizable files
|
||||||
|
foreach (var file in Directory.GetFiles(_localizableResponsesPath))
|
||||||
|
{
|
||||||
|
if (TryLoadResponsesFromFile(file, out var strings, out var localeName) && localeName is not null)
|
||||||
|
{
|
||||||
|
outputDict[localeName.ToLowerInvariant()] = strings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return outputDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryLoadResponsesFromFile(string file,
|
||||||
|
[NotNullWhen(true)] out IReadOnlyDictionary<string, string>? strings,
|
||||||
|
out string? localeName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
strings = _deserializer.Deserialize<Dictionary<string, string>?>(File.ReadAllText(file));
|
||||||
|
if (strings is null)
|
||||||
|
{
|
||||||
|
localeName = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
localeName = GetLocaleName(file).ToLowerInvariant();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Error loading {FileName} response strings: {ErrorMessage}", file, ex.Message);
|
||||||
|
strings = null;
|
||||||
|
localeName = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetLocaleName(string fileName)
|
||||||
|
=> Path.GetFileNameWithoutExtension(fileName);
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<Authors>WizNet</Authors>
|
||||||
|
|
||||||
|
<RootNamespace>Wiz.Medusa</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Discord.Net.Core" Version="3.17.2" />
|
||||||
|
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||||
|
<PackageReference Include="YamlDotNet" Version="15.1.6" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||||
|
<Version>9.0.0</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,2 @@
|
||||||
|
dotnet pack -o bin/Release/packed
|
||||||
|
dotnet nuget push bin/Release/packed/ --api-key $env:wizbot_myget_api_key --source https://www.myget.org/F/wizbot/api/v2/package
|
|
@ -12,9 +12,7 @@ namespace WizBot.Coordinator
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
public CoordStartup(IConfiguration config)
|
public CoordStartup(IConfiguration config)
|
||||||
{
|
=> Configuration = config;
|
||||||
Configuration = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,13 +15,16 @@ namespace WizBot.Services
|
||||||
.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()
|
||||||
|
.WriteTo.File("coord.log", LogEventLevel.Information,
|
||||||
|
rollOnFileSizeLimit: true,
|
||||||
|
fileSizeLimitBytes: 10_000_000)
|
||||||
.WriteTo.Console(LogEventLevel.Information,
|
.WriteTo.Console(LogEventLevel.Information,
|
||||||
theme: GetTheme(),
|
theme: GetTheme(),
|
||||||
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] | #{LogSource} | {Message:lj}{NewLine}{Exception}")
|
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] | #{LogSource} | {Message:lj}{NewLine}{Exception}")
|
||||||
.Enrich.WithProperty("LogSource", source)
|
.Enrich.WithProperty("LogSource", source)
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
|
|
||||||
System.Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ConsoleTheme GetTheme()
|
private static ConsoleTheme GetTheme()
|
||||||
|
|
|
@ -6,7 +6,6 @@ using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
@ -30,7 +29,7 @@ namespace WizBot.Coordinator
|
||||||
private readonly Random _rng;
|
private readonly Random _rng;
|
||||||
private bool _gracefulImminent;
|
private bool _gracefulImminent;
|
||||||
|
|
||||||
public CoordinatorRunner(IConfiguration configuration)
|
public CoordinatorRunner()
|
||||||
{
|
{
|
||||||
_serializer = new();
|
_serializer = new();
|
||||||
_deserializer = new();
|
_deserializer = new();
|
||||||
|
@ -89,9 +88,9 @@ namespace WizBot.Coordinator
|
||||||
lock (locker)
|
lock (locker)
|
||||||
{
|
{
|
||||||
var shardIds = Enumerable.Range(0, 1) // shard 0 is always first
|
var shardIds = Enumerable.Range(0, 1) // shard 0 is always first
|
||||||
.Append((int)((117523346618318850 >> 22) % _config.TotalShards)) // then wizbot server shard
|
.Append((int)((117523346618318850 >> 22) % _config.TotalShards)) // then Wiz server shard
|
||||||
.Concat(Enumerable.Range(1, _config.TotalShards - 1)
|
.Concat(Enumerable.Range(1, _config.TotalShards - 1)
|
||||||
.OrderBy(x => _rng.Next())) // then all other shards in a random order
|
.OrderBy(_ => _rng.Next())) // then all other shards in a random order
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
@ -116,14 +115,6 @@ namespace WizBot.Coordinator
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status.Process is null or {HasExited: true})
|
|
||||||
{
|
|
||||||
Log.Warning("Shard {ShardId} is starting (process)...", shardId);
|
|
||||||
hadAction = true;
|
|
||||||
StartShard(shardId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DateTime.UtcNow - status.LastUpdate >
|
if (DateTime.UtcNow - status.LastUpdate >
|
||||||
TimeSpan.FromSeconds(_config.UnresponsiveSec))
|
TimeSpan.FromSeconds(_config.UnresponsiveSec))
|
||||||
{
|
{
|
||||||
|
@ -140,6 +131,24 @@ namespace WizBot.Coordinator
|
||||||
StartShard(shardId);
|
StartShard(shardId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (status.Process is null or { HasExited: true })
|
||||||
|
{
|
||||||
|
Log.Warning("Shard {ShardId} is starting (process)...", shardId);
|
||||||
|
hadAction = true;
|
||||||
|
StartShard(shardId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
Log.Warning("Process for shard {ShardId} is bugged... ", shardId);
|
||||||
|
hadAction = true;
|
||||||
|
StartShard(shardId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,18 +169,20 @@ namespace WizBot.Coordinator
|
||||||
private void StartShard(int shardId)
|
private void StartShard(int shardId)
|
||||||
{
|
{
|
||||||
var status = _shardStatuses[shardId];
|
var status = _shardStatuses[shardId];
|
||||||
if (status.Process is {HasExited: false} p)
|
try
|
||||||
|
{
|
||||||
|
status.Process?.Kill(true);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
status.Process?.Dispose();
|
||||||
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
p.Kill(true);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
status.Process?.Dispose();
|
|
||||||
|
|
||||||
var proc = StartShardProcess(shardId);
|
var proc = StartShardProcess(shardId);
|
||||||
_shardStatuses[shardId] = status with
|
_shardStatuses[shardId] = status with
|
||||||
|
@ -185,8 +196,7 @@ namespace WizBot.Coordinator
|
||||||
}
|
}
|
||||||
|
|
||||||
private Process StartShardProcess(int shardId)
|
private Process StartShardProcess(int shardId)
|
||||||
{
|
=> Process.Start(new ProcessStartInfo()
|
||||||
return Process.Start(new ProcessStartInfo()
|
|
||||||
{
|
{
|
||||||
FileName = _config.ShardStartCommand,
|
FileName = _config.ShardStartCommand,
|
||||||
Arguments = string.Format(_config.ShardStartArgs,
|
Arguments = string.Format(_config.ShardStartArgs,
|
||||||
|
@ -199,7 +209,6 @@ namespace WizBot.Coordinator
|
||||||
// CreateNoWindow = true,
|
// CreateNoWindow = true,
|
||||||
// UseShellExecute = false,
|
// UseShellExecute = false,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
public bool Heartbeat(int shardId, int guildCount, ConnState state)
|
public bool Heartbeat(int shardId, int guildCount, ConnState state)
|
||||||
{
|
{
|
||||||
|
@ -233,7 +242,6 @@ namespace WizBot.Coordinator
|
||||||
{
|
{
|
||||||
lock (locker)
|
lock (locker)
|
||||||
{
|
{
|
||||||
ref var toSave = ref _config;
|
|
||||||
SaveConfig(new Config(
|
SaveConfig(new Config(
|
||||||
totalShards,
|
totalShards,
|
||||||
_config.RecheckIntervalMs,
|
_config.RecheckIntervalMs,
|
||||||
|
@ -280,8 +288,8 @@ namespace WizBot.Coordinator
|
||||||
var status = _shardStatuses[shardId];
|
var status = _shardStatuses[shardId];
|
||||||
if (status.Process is Process p)
|
if (status.Process is Process p)
|
||||||
{
|
{
|
||||||
p.Kill();
|
try{p.Kill();} catch {}
|
||||||
p.Dispose();
|
try{p.Dispose();} catch {}
|
||||||
_shardStatuses[shardId] = status with
|
_shardStatuses[shardId] = status with
|
||||||
{
|
{
|
||||||
Process = null,
|
Process = null,
|
||||||
|
@ -308,7 +316,7 @@ namespace WizBot.Coordinator
|
||||||
})
|
})
|
||||||
.ToList()
|
.ToList()
|
||||||
};
|
};
|
||||||
var jsonState = JsonSerializer.Serialize(coordState, new ()
|
var jsonState = JsonSerializer.Serialize(coordState, new JsonSerializerOptions()
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
});
|
});
|
||||||
|
@ -340,7 +348,7 @@ namespace WizBot.Coordinator
|
||||||
|
|
||||||
if (savedState.StatusObjects.Count != _config.TotalShards)
|
if (savedState.StatusObjects.Count != _config.TotalShards)
|
||||||
{
|
{
|
||||||
Log.Error("Unable to restore old state because shard count doesn't match.");
|
Log.Error("Unable to restore old state because shard count doesn't match");
|
||||||
File.Move(GRACEFUL_STATE_PATH, GRACEFUL_STATE_BACKUP_PATH, overwrite: true);
|
File.Move(GRACEFUL_STATE_PATH, GRACEFUL_STATE_BACKUP_PATH, overwrite: true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -351,7 +359,7 @@ namespace WizBot.Coordinator
|
||||||
{
|
{
|
||||||
var statusObj = savedState.StatusObjects[shardId];
|
var statusObj = savedState.StatusObjects[shardId];
|
||||||
Process p = null;
|
Process p = null;
|
||||||
if (statusObj.Pid is int pid)
|
if (statusObj.Pid is { } pid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -359,7 +367,7 @@ namespace WizBot.Coordinator
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Warning(ex, $"Process for shard {shardId} is not runnning.");
|
Log.Warning(ex, "Process for shard {ShardId} is not runnning", shardId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,8 +417,7 @@ namespace WizBot.Coordinator
|
||||||
{
|
{
|
||||||
lock (locker)
|
lock (locker)
|
||||||
{
|
{
|
||||||
if (shardId >= _shardStatuses.Length)
|
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(shardId, _shardStatuses.Length);
|
||||||
throw new ArgumentOutOfRangeException(nameof(shardId));
|
|
||||||
|
|
||||||
return _shardStatuses[shardId];
|
return _shardStatuses[shardId];
|
||||||
}
|
}
|
||||||
|
@ -435,9 +442,7 @@ namespace WizBot.Coordinator
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetConfigText()
|
public string GetConfigText()
|
||||||
{
|
=> File.ReadAllText(CONFIG_PATH);
|
||||||
return File.ReadAllText(CONFIG_PATH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetConfigText(string text)
|
public void SetConfigText(string text)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,14 +5,12 @@ using Grpc.Core;
|
||||||
|
|
||||||
namespace WizBot.Coordinator
|
namespace WizBot.Coordinator
|
||||||
{
|
{
|
||||||
public sealed class CoordinatorService : WizBot.Coordinator.Coordinator.CoordinatorBase
|
public sealed class CoordinatorService : Coordinator.CoordinatorBase
|
||||||
{
|
{
|
||||||
private readonly CoordinatorRunner _runner;
|
private readonly CoordinatorRunner _runner;
|
||||||
|
|
||||||
public CoordinatorService(CoordinatorRunner runner)
|
public CoordinatorService(CoordinatorRunner runner)
|
||||||
{
|
=> _runner = runner;
|
||||||
_runner = runner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task<HeartbeatReply> Heartbeat(HeartbeatRequest request, ServerCallContext context)
|
public override Task<HeartbeatReply> Heartbeat(HeartbeatRequest request, ServerCallContext context)
|
||||||
{
|
{
|
||||||
|
@ -113,11 +111,10 @@ namespace WizBot.Coordinator
|
||||||
return new DieReply();
|
return new DieReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<SetConfigTextReply> SetConfigText(SetConfigTextRequest request, ServerCallContext context)
|
public override Task<SetConfigTextReply> SetConfigText(SetConfigTextRequest request, ServerCallContext context)
|
||||||
{
|
{
|
||||||
await Task.Yield();
|
var error = string.Empty;
|
||||||
string error = string.Empty;
|
var success = true;
|
||||||
bool success = true;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_runner.SetConfigText(request.ConfigYml);
|
_runner.SetConfigText(request.ConfigYml);
|
||||||
|
@ -128,11 +125,11 @@ namespace WizBot.Coordinator
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new(new()
|
return Task.FromResult<SetConfigTextReply>(new(new()
|
||||||
{
|
{
|
||||||
Success = success,
|
Success = success,
|
||||||
Error = error
|
Error = error
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<GetConfigTextReply> GetConfigText(GetConfigTextRequest request, ServerCallContext context)
|
public override Task<GetConfigTextReply> GetConfigText(GetConfigTextRequest request, ServerCallContext context)
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
namespace WizBot.Coordinator
|
||||||
|
|
||||||
namespace WizBot.Coordinator
|
|
||||||
{
|
{
|
||||||
public class JsonStatusObject
|
public class JsonStatusObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<NoWarn>CS8981</NoWarn>
|
||||||
|
<RootNamespace>WizBot.Coordinator</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -9,10 +11,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Grpc.AspNetCore" Version="2.38.0" />
|
<PackageReference Include="Grpc.AspNetCore" Version="2.67.0" />
|
||||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
<PackageReference Include="YamlDotNet" Version="11.2.1" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
|
<PackageReference Include="YamlDotNet" Version="15.1.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -0,0 +1,258 @@
|
||||||
|
// Code temporarily yeeted from
|
||||||
|
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||||
|
// because of NRT issue
|
||||||
|
#nullable enable
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using Microsoft.CodeAnalysis.Text;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Cloneable
|
||||||
|
{
|
||||||
|
[Generator]
|
||||||
|
public class CloneableGenerator : ISourceGenerator
|
||||||
|
{
|
||||||
|
private const string PREVENT_DEEP_COPY_KEY_STRING = "PreventDeepCopy";
|
||||||
|
private const string EXPLICIT_DECLARATION_KEY_STRING = "ExplicitDeclaration";
|
||||||
|
|
||||||
|
private const string CLONEABLE_NAMESPACE = "Cloneable";
|
||||||
|
private const string CLONEABLE_ATTRIBUTE_STRING = "CloneableAttribute";
|
||||||
|
private const string CLONE_ATTRIBUTE_STRING = "CloneAttribute";
|
||||||
|
private const string IGNORE_CLONE_ATTRIBUTE_STRING = "IgnoreCloneAttribute";
|
||||||
|
|
||||||
|
private const string CLONEABLE_ATTRIBUTE_TEXT = $$"""
|
||||||
|
// <AutoGenerated/>
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace {{CLONEABLE_NAMESPACE}}
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = true, AllowMultiple = false)]
|
||||||
|
internal sealed class {{CLONEABLE_ATTRIBUTE_STRING}} : Attribute
|
||||||
|
{
|
||||||
|
public {{CLONEABLE_ATTRIBUTE_STRING}}()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool {{EXPLICIT_DECLARATION_KEY_STRING}} { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
private const string CLONE_PROPERTY_ATTRIBUTE_TEXT = $$"""
|
||||||
|
// <AutoGenerated/>
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace {{CLONEABLE_NAMESPACE}}
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||||
|
internal sealed class {{CLONE_ATTRIBUTE_STRING}} : Attribute
|
||||||
|
{
|
||||||
|
public {{CLONE_ATTRIBUTE_STRING}}()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool {{PREVENT_DEEP_COPY_KEY_STRING}} { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
private const string IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT = $$"""
|
||||||
|
// <AutoGenerated/>
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace {{CLONEABLE_NAMESPACE}}
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)]
|
||||||
|
internal sealed class {{IGNORE_CLONE_ATTRIBUTE_STRING}} : Attribute
|
||||||
|
{
|
||||||
|
public {{IGNORE_CLONE_ATTRIBUTE_STRING}}()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
""";
|
||||||
|
|
||||||
|
private INamedTypeSymbol? _cloneableAttribute;
|
||||||
|
private INamedTypeSymbol? _ignoreCloneAttribute;
|
||||||
|
private INamedTypeSymbol? _cloneAttribute;
|
||||||
|
|
||||||
|
public void Initialize(GeneratorInitializationContext context)
|
||||||
|
=> context.RegisterForSyntaxNotifications(() => new SyntaxReceiver());
|
||||||
|
|
||||||
|
public void Execute(GeneratorExecutionContext context)
|
||||||
|
{
|
||||||
|
InjectCloneableAttributes(context);
|
||||||
|
GenerateCloneMethods(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GenerateCloneMethods(GeneratorExecutionContext context)
|
||||||
|
{
|
||||||
|
if (context.SyntaxReceiver is not SyntaxReceiver receiver)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Compilation compilation = GetCompilation(context);
|
||||||
|
|
||||||
|
InitAttributes(compilation);
|
||||||
|
|
||||||
|
var classSymbols = GetClassSymbols(compilation, receiver);
|
||||||
|
foreach (var classSymbol in classSymbols)
|
||||||
|
{
|
||||||
|
if (!classSymbol.TryGetAttribute(_cloneableAttribute!, out var attributes))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var attribute = attributes.Single();
|
||||||
|
var isExplicit = (bool?)attribute.NamedArguments.FirstOrDefault(e => e.Key.Equals(EXPLICIT_DECLARATION_KEY_STRING)).Value.Value ?? false;
|
||||||
|
context.AddSource($"{classSymbol.Name}_cloneable.g.cs", SourceText.From(CreateCloneableCode(classSymbol, isExplicit), Encoding.UTF8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitAttributes(Compilation compilation)
|
||||||
|
{
|
||||||
|
_cloneableAttribute = compilation.GetTypeByMetadataName($"{CLONEABLE_NAMESPACE}.{CLONEABLE_ATTRIBUTE_STRING}")!;
|
||||||
|
_cloneAttribute = compilation.GetTypeByMetadataName($"{CLONEABLE_NAMESPACE}.{CLONE_ATTRIBUTE_STRING}")!;
|
||||||
|
_ignoreCloneAttribute = compilation.GetTypeByMetadataName($"{CLONEABLE_NAMESPACE}.{IGNORE_CLONE_ATTRIBUTE_STRING}")!;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Compilation GetCompilation(GeneratorExecutionContext context)
|
||||||
|
{
|
||||||
|
var options = context.Compilation.SyntaxTrees.First().Options as CSharpParseOptions;
|
||||||
|
|
||||||
|
var compilation = context.Compilation.AddSyntaxTrees(CSharpSyntaxTree.ParseText(SourceText.From(CLONEABLE_ATTRIBUTE_TEXT, Encoding.UTF8), options)).
|
||||||
|
AddSyntaxTrees(CSharpSyntaxTree.ParseText(SourceText.From(CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8), options)).
|
||||||
|
AddSyntaxTrees(CSharpSyntaxTree.ParseText(SourceText.From(IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8), options));
|
||||||
|
return compilation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string CreateCloneableCode(INamedTypeSymbol classSymbol, bool isExplicit)
|
||||||
|
{
|
||||||
|
string namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
|
||||||
|
var fieldAssignmentsCode = GenerateFieldAssignmentsCode(classSymbol, isExplicit).ToList();
|
||||||
|
var fieldAssignmentsCodeSafe = fieldAssignmentsCode.Select(x =>
|
||||||
|
{
|
||||||
|
if (x.isCloneable)
|
||||||
|
return x.line + "Safe(referenceChain)";
|
||||||
|
return x.line;
|
||||||
|
});
|
||||||
|
var fieldAssignmentsCodeFast = fieldAssignmentsCode.Select(x =>
|
||||||
|
{
|
||||||
|
if (x.isCloneable)
|
||||||
|
return x.line + "()";
|
||||||
|
return x.line;
|
||||||
|
});
|
||||||
|
|
||||||
|
return $@"using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace {namespaceName}
|
||||||
|
{{
|
||||||
|
{GetAccessModifier(classSymbol)} partial class {classSymbol.Name}
|
||||||
|
{{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a copy of {classSymbol.Name} with NO circular reference checking. This method should be used if performance matters.
|
||||||
|
///
|
||||||
|
/// <exception cref=""StackOverflowException"">Will occur on any object that has circular references in the hierarchy.</exception>
|
||||||
|
/// </summary>
|
||||||
|
public {classSymbol.Name} Clone()
|
||||||
|
{{
|
||||||
|
return new {classSymbol.Name}
|
||||||
|
{{
|
||||||
|
{string.Join(",\n", fieldAssignmentsCodeFast)}
|
||||||
|
}};
|
||||||
|
}}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a copy of {classSymbol.Name} with circular reference checking. If a circular reference was detected, only a reference of the leaf object is passed instead of cloning it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""referenceChain"">Should only be provided if specific objects should not be cloned but passed by reference instead.</param>
|
||||||
|
public {classSymbol.Name} CloneSafe(Stack<object> referenceChain = null)
|
||||||
|
{{
|
||||||
|
if(referenceChain?.Contains(this) == true)
|
||||||
|
return this;
|
||||||
|
referenceChain ??= new Stack<object>();
|
||||||
|
referenceChain.Push(this);
|
||||||
|
var result = new {classSymbol.Name}
|
||||||
|
{{
|
||||||
|
{string.Join($",\n", fieldAssignmentsCodeSafe)}
|
||||||
|
}};
|
||||||
|
referenceChain.Pop();
|
||||||
|
return result;
|
||||||
|
}}
|
||||||
|
}}
|
||||||
|
}}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<(string line, bool isCloneable)> GenerateFieldAssignmentsCode(INamedTypeSymbol classSymbol, bool isExplicit )
|
||||||
|
{
|
||||||
|
var fieldNames = GetCloneableProperties(classSymbol, isExplicit);
|
||||||
|
|
||||||
|
var fieldAssignments = fieldNames.Select(field => IsFieldCloneable(field, classSymbol))
|
||||||
|
.OrderBy(x => x.isCloneable)
|
||||||
|
.Select(x => (GenerateAssignmentCode(x.item.Name, x.isCloneable), x.isCloneable));
|
||||||
|
return fieldAssignments;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GenerateAssignmentCode(string name, bool isCloneable)
|
||||||
|
{
|
||||||
|
if (isCloneable)
|
||||||
|
{
|
||||||
|
return $@" {name} = this.{name}?.Clone";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $@" {name} = this.{name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private (IPropertySymbol item, bool isCloneable) IsFieldCloneable(IPropertySymbol x, INamedTypeSymbol classSymbol)
|
||||||
|
{
|
||||||
|
if (SymbolEqualityComparer.Default.Equals(x.Type, classSymbol))
|
||||||
|
{
|
||||||
|
return (x, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!x.Type.TryGetAttribute(_cloneableAttribute!, out var attributes))
|
||||||
|
{
|
||||||
|
return (x, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var preventDeepCopy = (bool?)attributes.Single().NamedArguments.FirstOrDefault(e => e.Key.Equals(PREVENT_DEEP_COPY_KEY_STRING)).Value.Value ?? false;
|
||||||
|
return (item: x, !preventDeepCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetAccessModifier(INamedTypeSymbol classSymbol)
|
||||||
|
=> classSymbol.DeclaredAccessibility.ToString().ToLowerInvariant();
|
||||||
|
|
||||||
|
private IEnumerable<IPropertySymbol> GetCloneableProperties(ITypeSymbol classSymbol, bool isExplicit)
|
||||||
|
{
|
||||||
|
var targetSymbolMembers = classSymbol.GetMembers().OfType<IPropertySymbol>()
|
||||||
|
.Where(x => x.SetMethod is not null &&
|
||||||
|
x.CanBeReferencedByName);
|
||||||
|
if (isExplicit)
|
||||||
|
{
|
||||||
|
return targetSymbolMembers.Where(x => x.HasAttribute(_cloneAttribute!));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return targetSymbolMembers.Where(x => !x.HasAttribute(_ignoreCloneAttribute!));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<INamedTypeSymbol> GetClassSymbols(Compilation compilation, SyntaxReceiver receiver)
|
||||||
|
=> receiver.CandidateClasses.Select(clazz => GetClassSymbol(compilation, clazz));
|
||||||
|
|
||||||
|
private static INamedTypeSymbol GetClassSymbol(Compilation compilation, ClassDeclarationSyntax clazz)
|
||||||
|
{
|
||||||
|
var model = compilation.GetSemanticModel(clazz.SyntaxTree);
|
||||||
|
var classSymbol = model.GetDeclaredSymbol(clazz)!;
|
||||||
|
return classSymbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InjectCloneableAttributes(GeneratorExecutionContext context)
|
||||||
|
{
|
||||||
|
context.AddSource(CLONEABLE_ATTRIBUTE_STRING, SourceText.From(CLONEABLE_ATTRIBUTE_TEXT, Encoding.UTF8));
|
||||||
|
context.AddSource(CLONE_ATTRIBUTE_STRING, SourceText.From(CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8));
|
||||||
|
context.AddSource(IGNORE_CLONE_ATTRIBUTE_STRING, SourceText.From(IGNORE_CLONE_PROPERTY_ATTRIBUTE_TEXT, Encoding.UTF8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
// Code temporarily yeeted from
|
||||||
|
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||||
|
// because of NRT issue
|
||||||
|
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
|
||||||
|
namespace Cloneable
|
||||||
|
{
|
||||||
|
internal static class SymbolExtensions
|
||||||
|
{
|
||||||
|
public static bool TryGetAttribute(this ISymbol symbol, INamedTypeSymbol attributeType,
|
||||||
|
out IEnumerable<AttributeData> attributes)
|
||||||
|
{
|
||||||
|
attributes = symbol.GetAttributes()
|
||||||
|
.Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, attributeType));
|
||||||
|
return attributes.Any();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasAttribute(this ISymbol symbol, INamedTypeSymbol attributeType)
|
||||||
|
=> symbol.GetAttributes()
|
||||||
|
.Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, attributeType));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
// Code temporarily yeeted from
|
||||||
|
// https://github.com/mostmand/Cloneable/blob/master/Cloneable/CloneableGenerator.cs
|
||||||
|
// because of NRT issue
|
||||||
|
|
||||||
|
using Microsoft.CodeAnalysis;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
|
||||||
|
namespace Cloneable
|
||||||
|
{
|
||||||
|
internal class SyntaxReceiver : ISyntaxReceiver
|
||||||
|
{
|
||||||
|
public IList<ClassDeclarationSyntax> CandidateClasses { get; } = new List<ClassDeclarationSyntax>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called for every syntax node in the compilation, we can inspect the nodes and save any information useful for generation
|
||||||
|
/// </summary>
|
||||||
|
public void OnVisitSyntaxNode(SyntaxNode syntaxNode)
|
||||||
|
{
|
||||||
|
// any field with at least one attribute is a candidate for being cloneable
|
||||||
|
if (syntaxNode is ClassDeclarationSyntax classDeclarationSyntax &&
|
||||||
|
classDeclarationSyntax.AttributeLists.Count > 0)
|
||||||
|
{
|
||||||
|
CandidateClasses.Add(classDeclarationSyntax);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,184 @@
|
||||||
|
#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 WizBot.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 WizBot.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 WizBot.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(
|
||||||
|
"WizBot.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(
|
||||||
|
"WizBot.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 WizBot.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|