Compare commits
No commits in common. "v6" and "v5" have entirely different histories.
569 changed files with 266065 additions and 24135 deletions
.dockerignore.editorconfigmkdocs-requirements.txtmkdocs.ymlexe_builder.iss
.github/workflows
.gitignoreCHANGELOG.mdDockerfileLICENSEREADME.mddocker-entrypoint.shdocs
md
assets
elliehub-1.pngelliehub-2.pngelliehub-3.pngelliehub-4.pngelliehub-5.pngelliehub-6.pngfavicon.pngpatreon.pngpaypal.png
creds-guide.mddonate.mdguides
index.mdmarmalade
snippets
src
Ellie.Marmalade
EllieBot.Coordinator
EllieBot.Generators
EllieBot.GrpcApiBase
EllieBot.Tests
BotStringsTests.csConcurrentHashSetTests.csEllieBot.Tests.csprojFishTests.csIndexedCollectionTests.csKwumTests.csNewDeckTests.csPubSubTests.csRandom.cs
EllieBot.Voice
EllieBot.VotesApi
Common
Controllers
DockerfileEllieBot.VotesApi.csprojProgram.csProtos
Services
Startup.csappsettings.jsonEllieBot
.editorconfigBot.cs
Db
EllieContext.csEllieDbService.cs
Extensions
CurrencyTransactionExtensions.csDbExtensions.csDiscordUserExtensions.csGuildConfigExtensions.csUserXpExtensions.cs
Models
|
@ -10,5 +10,4 @@
|
|||
|
||||
# ignore bin and obj folders in projects
|
||||
src/**/bin/*
|
||||
src/**/obj/*
|
||||
src/EllieBot/data/creds.yml
|
||||
src/**/obj/*
|
208
.editorconfig
208
.editorconfig
|
@ -1,208 +0,0 @@
|
|||
|
||||
[*]
|
||||
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
|
36
.github/workflows/mkdocs-deploy.yml
vendored
36
.github/workflows/mkdocs-deploy.yml
vendored
|
@ -1,36 +0,0 @@
|
|||
name: Deploy EllieBot 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
|
19
.gitignore
vendored
19
.gitignore
vendored
|
@ -7,12 +7,19 @@ src/EllieBot/data/marmalades/
|
|||
|
||||
# other
|
||||
|
||||
command_errors*.txt
|
||||
output/
|
||||
src/EllieBot/output
|
||||
src/EllieBot/creds.yml
|
||||
src/EllieBot/data/creds.yml
|
||||
|
||||
src/EllieBot/Command Errors*.txt
|
||||
src/EllieBot/data/EllieBot.db.*
|
||||
|
||||
src/EllieBot/creds.yml
|
||||
# credentials file before and after v3
|
||||
src/EllieBot/credentials.json
|
||||
src/EllieBot/old_credentials.json
|
||||
src/EllieBot/credentials.json.bak
|
||||
src/EllieBot/data/EllieBot.db
|
||||
# scripts
|
||||
ellie-menu.ps1
|
||||
package.sh
|
||||
|
@ -370,10 +377,4 @@ site/
|
|||
## AI
|
||||
|
||||
.aider.*
|
||||
PROMPT.md
|
||||
.*rules
|
||||
|
||||
## Python pip/env files
|
||||
Pipfile
|
||||
Pipfile.lock
|
||||
.venv
|
||||
PROMPT.md
|
377
CHANGELOG.md
377
CHANGELOG.md
|
@ -1,356 +1,102 @@
|
|||
# Changelog
|
||||
|
||||
*a,c,f,r,o*
|
||||
|
||||
## [6.1.7] - 16.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.streamrole` fixed
|
||||
- fixed `.ura` hierarchy check (it will let owners assign roles too)
|
||||
|
||||
## [6.1.6] - 13.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- QuestCommands no longer appear as a separate module
|
||||
|
||||
## [6.1.5] - 07.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.xpadd` will finally apply rewards and trigger notifications
|
||||
- Fixed `.hangman` dislocation
|
||||
|
||||
## [6.1.4] - 05.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed .timely awarding multiple times
|
||||
- Fixed .plant password - moved it down and right to avoid cutoff on phones
|
||||
|
||||
## [6.1.3] - 05.04.2025
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bot will no longer fail to startup if ownerids are wrong
|
||||
|
||||
## [6.1.2] - 03.04.2025
|
||||
|
||||
### Fixed
|
||||
- Fixed `.feed` not adding new feeds to the database
|
||||
|
||||
## [6.1.1] - 03.04.2025
|
||||
|
||||
### Added
|
||||
- Added some config options for .conf fish
|
||||
|
||||
### Fixed
|
||||
- Fixed a typo in fish shop
|
||||
- .fishlb will now compare unique fish caught, instead of total catches
|
||||
- hangman category now appears in .hangman output
|
||||
|
||||
## [6.1.0] - 30.03.2025
|
||||
|
||||
### Added
|
||||
- Added Quest System!
|
||||
- Each user gets a couple of daily quests to complete
|
||||
- There are 10-15 different quests, each day you'll get 3
|
||||
- Upon completion of all dailies, the user will get a boost to timely and vote
|
||||
- `.quests` to see your quests
|
||||
- Added Fishing Items!
|
||||
- `.fishop` to see a list of all available items for sale
|
||||
- `.fibuy` to buy an item
|
||||
- `.finv` to see your inventory
|
||||
- `.fiuse` to use an item. You can equip one of each item, except potions
|
||||
- You can equip one of each item
|
||||
- You can equip any number of potions, but they have limited duration and cant be unequiped
|
||||
- `.fili` will show your equipped item names, nad `.fish` will show bonuses
|
||||
- Added `.fishlb` to see the top anglers
|
||||
- Added `.notify <channel> nicecatch <message>` event
|
||||
- It will show all rare fish/trash and all max star fish caught on any server
|
||||
- You can use `.notifyphs nicecatch` to see the list of placeholders you can use while setting a message
|
||||
- Example: `.notify #fishfeed nicecatch %user% just caught a %event.fish.stars% %event.fish.name% %event.fish.emoji%`
|
||||
- Added prices to `.nczoom`
|
||||
- Voting re-added, `.votefeed` to see all votes. Non-trivial setup required, check commits
|
||||
- owner only `.massping` command for special situations
|
||||
|
||||
### Changed
|
||||
- .notify commands now require Manage Messages permission
|
||||
- .notify will now let you know if you can't set a notify message due to a missing channel
|
||||
- `.say` will no longer reply
|
||||
- `.vote` and `.timely` will now show active bonuses
|
||||
- `.lcha` (live channel) limit increased to 5
|
||||
- `.nc` will now show instructions
|
||||
|
||||
### Fixed
|
||||
- Fixed `.antispamignore` restart persistence
|
||||
- Fixed `.notify` events. Only levelup used to work
|
||||
- Fixed `.hangman` misalignment
|
||||
- Fixed bank quest
|
||||
|
||||
## [6.0.13] - 23.03.2025
|
||||
|
||||
### Added
|
||||
- Added `.linkfix <old> <new>` command
|
||||
- If bot sees a message with the old link, it will reply to the message with a fixed (new) link
|
||||
- ex: `.linkfix twitter.com vxtwitter.com`
|
||||
- Added `.roleicon role <icon_url / server_emoji>` command to set the icon of a role
|
||||
- Added a captcha option for `.fish`
|
||||
|
||||
### Fixed
|
||||
- Fixed youtube stream notifications in case invalid channel was provided
|
||||
- `.lcha` (live channel) will now let you override an existing channel template even if you're at the limit
|
||||
- Fixed `.shop` commands
|
||||
|
||||
### Removed
|
||||
- removed `.xpglb` as it is no longer used
|
||||
|
||||
## [6.0.12] - 20.03.2025
|
||||
|
||||
### Fixed
|
||||
- `.antispamignore` fixed for the last time hopefully
|
||||
- protection commands are some of the oldest commands, and they might get overhauled in future updates
|
||||
- please report if you find any other weird issue with them
|
||||
|
||||
## [6.0.11] - 20.03.2025
|
||||
|
||||
### Changed
|
||||
- wordfilter, invitefilter and linkfilter will now properly detect forwarded messages, as forwards were used to circumvent filtering.
|
||||
|
||||
### Fixed
|
||||
- `.dmc` fixed
|
||||
- Fixed .streamremove - now showing proper youtube name when removing instead of channel id
|
||||
|
||||
## [6.0.10] - 20.03.2025
|
||||
|
||||
### Changed
|
||||
|
||||
- Live channels `.lcha` is limited to 1 for now. It will be reverted back to 5 in a couple of days at most as some things need to be implemented.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.antispam` won't break if you have thread channels in the server anymore
|
||||
- `.ve` now works properly
|
||||
- selfhosters: `.yml` parsing errors will now tell you which .yml file is causing the issue and why.
|
||||
|
||||
## [6.0.9] - 19.03.2025
|
||||
|
||||
### Changed
|
||||
|
||||
- `.cinfo` now also has a member list
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.antispamignore` will now properly persist through restarts
|
||||
- livechannels and scheduled commands will now be inside utility module as they should
|
||||
|
||||
## [6.0.8] - 19.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Live channel commands
|
||||
- `.lcha` adds a channel with a template message (supports placeholders, and works on category channels too!)
|
||||
- Every 10 minutes, channel name will be updated
|
||||
- example: `.lcha #my-channel --> Members: %server.members% <--` will display the number of members in the server as a channel name, updating once every 10 minutes
|
||||
- `.lchl` lists all live channels (Up to 5)
|
||||
- `.lchd <channel or channelId>` removed a live channel
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.antispamignore` fixed
|
||||
|
||||
## [6.0.7] - 19.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Schedule commands!
|
||||
- `.scha <time> <text>` adds the command to be excuted after the specified amount of time
|
||||
- `.schd <id>` deletes the command with the specified id
|
||||
- `.schl` lists your scheduled commands
|
||||
- `.masskick` added as massban and masskill already exist
|
||||
- `.xpex` and `.xpexl` are back, as there was no way to exclude specific users or roles with .xprate
|
||||
|
||||
### Fix
|
||||
|
||||
- `.xprate` will now (as exclusion did) respect parent channel xp rates in threads
|
||||
- the xprate system will first check if a thread channel has a rate set
|
||||
- if it doesn't it will try to use the parent channel's rate
|
||||
|
||||
## [6.0.6] - 16.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Added youtube live stream notification support for `.streamadd`
|
||||
- it only works by using an invidious instance (with a working api) from data/searches.yml
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.hangman` not receiving input sometimes
|
||||
- Fixed `.sfl` and similar toggles not working
|
||||
- Fixed `.antialt` and other protection commands not properly turning on
|
||||
- Fixed `%bot.time%` and `%bot.date%` placeholders showing wrong date.
|
||||
- No longer a timestamp
|
||||
|
||||
## [6.0.5] - 15.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- Aded a title in `.whosplaying`
|
||||
- Added a crown emoji next to commands if -v 1 or -v2 option is specified
|
||||
|
||||
### Changed
|
||||
|
||||
- `.remind` looks better
|
||||
- `.savechat` no longer owner only, up to 1000 messages - unlimited if ran by the bot owner
|
||||
|
||||
### Fixed
|
||||
|
||||
- `.ropl` fixed
|
||||
|
||||
## [6.0.4] - 14.03.2025
|
||||
|
||||
### Added
|
||||
|
||||
- `.xp` system reworked
|
||||
- Global XP has been removed in favor of server XP
|
||||
- You can now set `.xprate` for each channel in your server!
|
||||
- You can set voice, image, and text rates
|
||||
- Use `.xpratereset` to reset it back to default
|
||||
- This feature makes `.xpexclude` obsolete
|
||||
- Requirement to create a club removed
|
||||
- `.xp` card should generate faster
|
||||
- Fixed countless possible issues with xp where some users didn't gain xp, or froze, etc
|
||||
- user-role commands added!
|
||||
- `.ura <user> <role>` - assign a role to a user
|
||||
- `.url <user?>` - list assigned roles for all users or a specific user
|
||||
- `.urm` - show 'my' (your) assigned roles
|
||||
- `.urn <role> <new_name>` - set a name for your role
|
||||
- `.urc <role> <hex_color>` - set a color for your role
|
||||
- `.uri <role> <url/server_emoji>` - set an icon for your role (accepts either a server emoji or a link to an image)
|
||||
- `.notify` improved
|
||||
- Lets you specify source channel (for some events) as the message output
|
||||
- `.pload <id> --shuffle` lets you load a saved playlist in random order
|
||||
- `.lyrics <song_name>` added - find lyrics for a song (it's not always accurate)
|
||||
|
||||
- For Selfhosters
|
||||
- you have to update to latest v5 before updating to v6, otherwise migrations will fail
|
||||
- migration system was reworked
|
||||
- Xp card is now 500x245
|
||||
- xp_template.json backed up to old_xp_template.json
|
||||
- check pinned message in #dev channel to see full selfhoster announcement
|
||||
- Get bot version via --version
|
||||
|
||||
### Changed
|
||||
|
||||
- `.lopl` will queue subdirectories too now
|
||||
- Some music playlist commands have been renamed to fit with other commands
|
||||
- Removed gold/silver frames from xp card
|
||||
- `.inrole` is now showing users in alphabetical order
|
||||
- `.curtrs` are now paginated
|
||||
- pagination now lasts for 10+ minutes
|
||||
- selfhosters: Restart command default now assumes binary installation
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed several fonts
|
||||
- Xp Exclusion commands (superseded by `.xprate`)
|
||||
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o
|
||||
|
||||
## [5.3.9] - 31.01.2025
|
||||
|
||||
### Added
|
||||
## Added
|
||||
|
||||
- Added `.todo archive done <name>`
|
||||
- Creates an archive of only currently completed todos
|
||||
- Added `.todo archive done <name>`
|
||||
- Creates an archive of only currently completed todos
|
||||
- An alternative to ".todo archive add <name>" which moves all todos to an archive
|
||||
|
||||
### Changed
|
||||
## Changed
|
||||
|
||||
- Increased todo and archive limits slightly
|
||||
- Global ellie captcha patron ad will show 12.5% of the time now, down from 20%, and be smaller
|
||||
- Global ellie captcha patron ad will show 12.5% of the time now, down from 20%, and be smaller
|
||||
- `.remind` now has a 1 year max timeout, up from 2 months
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- Captcha is now slightly bigger, with larger margin, to mitigate phone edge issues
|
||||
- Fixed `.stock` command, unless there is some ip blocking going on
|
||||
|
||||
## [5.3.8] - 29.01.2025
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- `.temprole` now correctly adds a role
|
||||
- `.h temprole` also shows the correct overload now
|
||||
- `.h temprole` also shows the correct overload now
|
||||
|
||||
## [5.3.7] - 21.01.2025
|
||||
|
||||
### Changed
|
||||
## Changed
|
||||
|
||||
- You can now run `.prune` in DMs
|
||||
- It deletes only bot messages
|
||||
- You can't specify a number of messages to delete (100 default)
|
||||
- It deletes only bot messages
|
||||
- You can't specify a number of messages to delete (100 default)
|
||||
- Updated command list
|
||||
|
||||
## [5.3.6] - 21.01.2025
|
||||
|
||||
### Added
|
||||
## Added
|
||||
|
||||
- Added player skill stat when fishing
|
||||
- Starts at 0, goes up to 100
|
||||
- Every time you fish you have a chance to get an extra skill point
|
||||
- Higher skill gives you more chance to catch fish (and therefore less chance to catch trash)
|
||||
- Starts at 0, goes up to 100
|
||||
- Every time you fish you have a chance to get an extra skill point
|
||||
- Higher skill gives you more chance to catch fish (and therefore less chance to catch trash)
|
||||
|
||||
### Changed
|
||||
## Changed
|
||||
|
||||
- Patrons no longer have `.timely` and `.fish` captcha on the public bot
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- Fixed fishing spots again (Your channels will once again change a spot, last time hopefully)
|
||||
- There was a mistake in spot calculation for each channel
|
||||
- There was a mistake in spot calculation for each channel
|
||||
|
||||
## [5.3.5] - 18.01.2025
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- .sar rm will now accept role ids in case the role was deleted
|
||||
- `.deletewaifus` should work again
|
||||
|
||||
## [5.3.4] - 14.01.2025
|
||||
|
||||
### Added
|
||||
## Added
|
||||
|
||||
- Added `.fish` commands
|
||||
- `.fish` - Attempt to catch a fish - different fish live in different places, at different times and during different times of the day
|
||||
- `.fishlist` - Look at your fish catalogue - shows how many of each fish you caught and what was the highest quality - for each caught fish, it also shows its required spot, time of day and weather
|
||||
- `.fishspot` - Shows information about the current fish spot, time of day and weather
|
||||
- `.fish` - Attempt to catch a fish - different fish live in different places, at different times and during different times of the day
|
||||
- `.fishlist` - Look at your fish catalogue - shows how many of each fish you caught and what was the highest quality - for each caught fish, it also shows its required spot, time of day and weather
|
||||
- `.fishspot` - Shows information about the current fish spot, time of day and weather
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- `.timely` fixed captcha sometimes generating only 2 characters
|
||||
|
||||
## [5.3.3] - 16.12.2024
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- `.notify` commands are no longer owner only, they now require Admin permissions
|
||||
- `.notify` messages can now mention anyone
|
||||
|
||||
## [5.3.2] - 14.12.2024
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- `.banner` should be working properly now with both server and global user banners
|
||||
|
||||
## [5.3.1] - 13.12.2024
|
||||
|
||||
### Changed
|
||||
## Changed
|
||||
|
||||
- `.translate` will now use 2 embeds, to allow for longer messages
|
||||
- Added role icon to `.inrole`, if it exists
|
||||
- `.honeypot` will now add a 'Honeypot' as a ban reason.
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- `.winlb` looks better, has a title, shows 9 entries now
|
||||
- `.sar ex` help updated
|
||||
|
@ -360,7 +106,7 @@
|
|||
|
||||
## [5.3.0] - 10.12.2024
|
||||
|
||||
### Added
|
||||
## Added
|
||||
|
||||
- Added `.minesweeper` / `.mw` command - spoiler-based minesweeper minigame. Just for fun
|
||||
- Added `.temprole` command - add a role to a user for a certain amount of time, after which the role will be removed
|
||||
|
@ -379,7 +125,7 @@
|
|||
- Added `.dmmod` and `.dmcmd` - you can now disable or enable whether commands or modules can be executed in bot's
|
||||
DMs
|
||||
|
||||
### Changed
|
||||
## Changed
|
||||
|
||||
- Giveaway improvements
|
||||
- Now mentions winners in a separate message
|
||||
|
@ -393,19 +139,19 @@
|
|||
to play)
|
||||
- `.translate` will now use 2 embeds instead of 1
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- .setstream and .setactivity will now pause .ropl (rotating statuses)
|
||||
- Fixed `.sar ex` help description
|
||||
|
||||
### Removed
|
||||
## Removed
|
||||
|
||||
- `.xpnotify` command, superseded by `.notify`, although as of right now you can't post user's level up in the same
|
||||
channel user last typed, because you have to specify a channel where the notify messages will be posted
|
||||
|
||||
## [5.2.4] - 29.11.2024
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- More fixes for .sclr
|
||||
- `.iamn` fixed
|
||||
|
@ -433,6 +179,7 @@
|
|||
- Fixed `.sclr` not updating unless bot is restarted, the changes should be immediate now for warn and error
|
||||
- Fixed group buttons exclusivity message always saying groups are exclusive
|
||||
|
||||
|
||||
## [5.2.1] - 28.11.2024
|
||||
|
||||
### Fixed
|
||||
|
@ -551,18 +298,16 @@
|
|||
language of that country
|
||||
- 5 second cooldown per user
|
||||
- The message can only be translated once per language (counter resets every 24h)
|
||||
- `.timely` now has a button. Togglable via `.conf gambling` it's called pass because previously it was a captcha, but
|
||||
captchas are too annoying
|
||||
- `.timely` now has a button. Togglable via `.conf gambling` it's called pass because previously it was a captcha, but captchas are too annoying
|
||||
|
||||
### Changed
|
||||
## Changed
|
||||
|
||||
- [public bot] Patreon reward bonus for flowers reduced. Timely bonuses stay the same
|
||||
- discriminators removed from the databases. All users who had ???? as discriminator have been renamed to ??username.
|
||||
- all new unknown users will have ??Unknown as their name
|
||||
- Flower currency generation will now have a strikeout to try combat the pickbots. This is the weakest but easiest
|
||||
protection to implement. There may be more options in the future
|
||||
- Flower currency generation will now have a strikeout to try combat the pickbots. This is the weakest but easiest protection to implement. There may be more options in the future
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- nunchi join game message is now ok color instead of error color
|
||||
|
||||
|
@ -590,16 +335,16 @@
|
|||
|
||||
## [5.1.15] - 21.10.2024
|
||||
|
||||
### Added
|
||||
## Added
|
||||
|
||||
- Added -c option for `.xpglb`
|
||||
|
||||
### Change
|
||||
## Change
|
||||
|
||||
- Leaderboards will now show 10 users per page
|
||||
- A lot of internal changes and improvements
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- Fixed a big issue which caused several features to not get loaded on bot restart
|
||||
- Alias collision fix `.qse` is now quotesearch, `.qs` will stay `.queuesearch`
|
||||
|
@ -611,11 +356,11 @@
|
|||
|
||||
## [5.1.14] - 03.10.2024
|
||||
|
||||
### Changed
|
||||
## Changed
|
||||
|
||||
- Improved `.xplb -c`, it will now correctly only show users who are still in the server with no count limit
|
||||
|
||||
### Fixed
|
||||
## Fixed
|
||||
|
||||
- Fixed marmalade load error on startup
|
||||
|
||||
|
@ -687,8 +432,7 @@
|
|||
|
||||
### Added
|
||||
|
||||
- Added `.leaveunkeptservers` which will make the bot leave all servers on all shards whose owners didn't run `.keep`
|
||||
command.
|
||||
- Added `.leaveunkeptservers` which will make the bot leave all servers on all shards whose owners didn't run `.keep` command.
|
||||
- This is a dangerous and irreversible command, don't use it. Meant for use on the public bot.
|
||||
- `.adpl` now supports custom statuses (you no longer need to specify Playing, Watching, etc...)
|
||||
|
||||
|
@ -700,8 +444,7 @@
|
|||
- `.quotesearch` / `.qse` is now paginated for easier searching
|
||||
- `.whosplaying` is now paginated
|
||||
- `.img` is now paginated
|
||||
- `.setgame` renamed to`.setactivity` and now supports custom text activity. You don't have to specify playing,
|
||||
listening etc before the activity
|
||||
- `.setgame` renamed to`.setactivity` and now supports custom text activity. You don't have to specify playing, listening etc before the activity
|
||||
- Clarified and added some embed / placeholder links to command help where needed
|
||||
- dev: A lot of code cleanup and internal improvements
|
||||
|
||||
|
@ -769,8 +512,7 @@
|
|||
- Updated some bet descriptions to include 'all' 'half' usage instructions
|
||||
- Updated some command strings
|
||||
- dev: Vastly simplified marmalade creation using dotnet templates, docs updated
|
||||
- Slight refactor of .wiki, time, .catfact, .wikia, .define, .bible and .quran commands, no significant change in
|
||||
functionality
|
||||
- Slight refactor of .wiki, time, .catfact, .wikia, .define, .bible and .quran commands, no significant change in functionality
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -787,10 +529,8 @@
|
|||
|
||||
- Added `.coins` command which lists top 10 cryptos ordered by marketcap
|
||||
- Added Clubs rank in the leaderboard to `.clubinfo`
|
||||
- Bot owners can now check other people's bank balance (Not server owners, only bot owner, the person who is hosting the
|
||||
bot)
|
||||
- You can now send multiple waifu gifts at once to waifus. For example `.waifugift 3xRose @user` will give that user 3
|
||||
roses
|
||||
- Bot owners can now check other people's bank balance (Not server owners, only bot owner, the person who is hosting the bot)
|
||||
- You can now send multiple waifu gifts at once to waifus. For example `.waifugift 3xRose @user` will give that user 3 roses
|
||||
- The format is `<NUMBER>x<ITEM>`, no spaces
|
||||
- Added `.boosttest` command
|
||||
- Added support for any openai compatible api for the chatterbot feature change:
|
||||
|
@ -816,20 +556,20 @@
|
|||
|
||||
### Changed
|
||||
|
||||
- Replying to the bot's message in the channel where chatterbot is enabled will also trigger the ai response, as if you
|
||||
pinged the bot. This only works for chatterbot, but not for ellie ai command prompts
|
||||
- Replying to the bot's message in the channel where chatterbot is enabled will also trigger the ai response, as if you pinged the bot. This only works for chatterbot, but not for ellie ai command prompts
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.stickeradd` it now properly supports 300x300 image uploads.
|
||||
- Bot should now trim the invalid characters from chatterbot usernames to avoid openai errors
|
||||
- Fixed prompt triggering chatterbot responses twice
|
||||
- Honeypot commands now actually works
|
||||
|
||||
## [5.1.2] - 29.06.2024
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed `.honeypot` not unbanning and not pruning messages
|
||||
- Compile issues by disabling honeypot submodule for the time being
|
||||
|
||||
## [5.1.1] - 29.06.2024
|
||||
|
||||
|
@ -856,20 +596,17 @@
|
|||
|
||||
- Remind will now show a timestamp tag for durations
|
||||
- Only `Gpt35Turbo` and `Gpt4o` are valid inputs in games.yml now
|
||||
- `data/patron.yml` changed. It now has limits. The entire feature limit system has been reworked. Your previous
|
||||
settings will be reset
|
||||
- `data/patron.yml` changed. It now has limits. The entire feature limit system has been reworked. Your previous settings will be reset
|
||||
- A lot of updates to bot strings
|
||||
- Improved cleanup command to delete a lot more data once cleanup is ran, not only guild configs (please don't use this
|
||||
command unless you have your database bakced up and you know 100% what you're doing)
|
||||
- Improved cleanup command to delete a lot more data once cleanup is ran, not only guild configs (please don't use this command unless you have your database bakced up and you know 100% what you're doing)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed xp bg buy button not working, and possibly some other buttons too
|
||||
- Fixed shopbuy %user% placeholders and updated help text
|
||||
- All .feed overloads should now work"
|
||||
- `.xpexclude` should will now work with forums too. If you exclude a forum you won't be able to gain xp in any of the
|
||||
threads.
|
||||
- Fixed remind not showing the correct time
|
||||
- `.xpexclude` should will now work with forums too. If you exclude a forum you won't be able to gain xp in any of the threads.
|
||||
- Fixed remind not showing correct time
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -898,4 +635,4 @@
|
|||
- `.verbose` will now be respected for expression errors
|
||||
- Using `.pick` will now correctly show the name of the user who picked the currency
|
||||
- Fixed `.h` not working on some commands
|
||||
- `.langset` and `.langsetd` should no longer allow unsupported languages and nonsense to be typed in
|
||||
- `.langset` and `.langsetd` should no longer allow unsupported languages and nonsense to be typed in
|
||||
|
|
57
Dockerfile
57
Dockerfile
|
@ -1,4 +1,4 @@
|
|||
# Build stage
|
||||
# Use the .NET 8.0 SDK as the base image for the build stage
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /source
|
||||
|
||||
|
@ -8,42 +8,53 @@ COPY src/EllieBot/*.csproj src/EllieBot/
|
|||
COPY src/EllieBot.Coordinator/*.csproj src/EllieBot.Coordinator/
|
||||
COPY src/EllieBot.Generators/*.csproj src/EllieBot.Generators/
|
||||
COPY src/EllieBot.Voice/*.csproj src/EllieBot.Voice/
|
||||
COPY src/EllieBot.GrpcApiBase/*.csproj src/EllieBot.GrpcApiBase/
|
||||
|
||||
# Restore the dependencies for the EllieBot project
|
||||
RUN dotnet restore src/EllieBot/ -r linux-musl-x64
|
||||
RUN dotnet restore src/EllieBot/
|
||||
|
||||
# Copy the rest of the source code
|
||||
COPY . .
|
||||
|
||||
# Set the working directory to the EllieBot project
|
||||
WORKDIR /source/src/EllieBot
|
||||
|
||||
# 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/EllieBot
|
||||
# Build and publish the EllieBot project, then clean up unnecessary files
|
||||
RUN set -xe; \
|
||||
dotnet --version; \
|
||||
dotnet restore; \
|
||||
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/EllieBot
|
||||
|
||||
# Final stage
|
||||
FROM alpine:3.20
|
||||
# Use the .NET 8.0 runtime as the base image for the final stage
|
||||
FROM mcr.microsoft.com/dotnet/runtime:8.0
|
||||
WORKDIR /app
|
||||
|
||||
# Music dependencies
|
||||
ADD --chmod=755 https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux /usr/local/bin/yt-dlp
|
||||
RUN apk add --no-cache ffmpeg libsodium
|
||||
|
||||
# Required dependencies
|
||||
# icu-libs is required for globalization
|
||||
RUN apk update; \
|
||||
apk add --no-cache libstdc++ libgcc icu-libs libc6-compat \
|
||||
&& rm -rf /var/cache/apk/*;
|
||||
# Create a new user, install dependencies, and set up sudoers file
|
||||
RUN set -xe; \
|
||||
useradd -m ellie; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends libopus0 libsodium23 libsqlite3-0 curl ffmpeg python3 sudo; \
|
||||
echo 'Defaults>ellie env_keep+="ASPNETCORE_* DOTNET_* EllieBot_* shard_id total_shards TZ"' > /etc/sudoers.d/ellie; \
|
||||
curl -Lo /usr/local/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp; \
|
||||
chmod a+rx /usr/local/bin/yt-dlp; \
|
||||
apt-get autoremove -y; \
|
||||
apt-get autoclean -y
|
||||
|
||||
# Copy the built application and the entrypoint script from the build stage
|
||||
COPY --from=build /app ./
|
||||
COPY docker-entrypoint.sh /usr/local/sbin/
|
||||
COPY docker-entrypoint.sh /usr/local/sbin
|
||||
|
||||
RUN rm /app/data_init/lib/libsodium.so \
|
||||
&& ln -s /usr/lib/libsodium.so.26 /app/data_init/lib/libsodium.so
|
||||
# Set environment variables
|
||||
ENV shard_id=0
|
||||
ENV total_shards=1
|
||||
ENV EllieBot__creds=/app/data/creds.yml
|
||||
|
||||
VOLUME [ "/app/data" ]
|
||||
# Define the data directory as a volume
|
||||
VOLUME [" /app/data "]
|
||||
|
||||
# Set the entrypoint and default command
|
||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||
CMD [ "./EllieBot" ]
|
||||
CMD dotnet EllieBot.dll "$shard_id" "$total_shards"
|
||||
|
|
820
LICENSE
820
LICENSE
|
@ -1,619 +1,201 @@
|
|||
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
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2025 Toastie_t0ast
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,10 +1,10 @@
|
|||
# EllieBot
|
||||
|
||||
[](https://nogithub.codeberg.page) 
|
||||
[](https://nogithub.codeberg.page)
|
||||
|
||||
## Guides
|
||||
|
||||
For hosting guides go https://docs.elliebot.net/
|
||||
For hosting guides go https://docs.elliebot.net/ellie/
|
||||
|
||||
## Support
|
||||
|
||||
|
|
|
@ -1,20 +1,28 @@
|
|||
#!/bin/sh
|
||||
set -e;
|
||||
|
||||
set -e
|
||||
data_init=/app/data_init
|
||||
data=/app/data
|
||||
|
||||
data_init="/app/data_init"
|
||||
data="/app/data"
|
||||
# populate /app/data if empty
|
||||
for i in $(ls $data_init)
|
||||
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
|
||||
|
||||
ls $data
|
||||
# Merge data_init into data without overwrites.
|
||||
cp -R -n $data_init/* $data
|
||||
cp -n "$data_init/creds_example.yml" "$data/creds.yml"
|
||||
# creds.yml migration
|
||||
if [ -f /app/creds.yml ]; then
|
||||
echo "Default location for creds.yml is now /app/data/creds.yml."
|
||||
echo "Please move your creds.yml and update your docker-compose.yml accordingly."
|
||||
|
||||
ls $data
|
||||
export Ellie_creds=/app/creds.yml
|
||||
fi
|
||||
|
||||
echo "Yt-dlp update"
|
||||
# TODO: Update yt-dlp. It should not crash the entrypoint if ca-certificates is not installed
|
||||
# yt-dlp -U
|
||||
# ensure ellie can write on /app/data
|
||||
chown -R ellie:ellie "$data"
|
||||
|
||||
echo "Running EllieBot"
|
||||
exec "$@"
|
||||
# drop to regular user and launch command
|
||||
exec sudo -u ellie "$@"
|
Binary file not shown.
Before ![]() (image error) Size: 52 KiB |
Binary file not shown.
Before ![]() (image error) Size: 58 KiB |
Binary file not shown.
Before ![]() (image error) Size: 56 KiB |
Binary file not shown.
Before ![]() (image error) Size: 15 KiB |
Binary file not shown.
Before ![]() (image error) Size: 1.2 KiB |
Binary file not shown.
Before ![]() (image error) Size: 1,014 B |
Binary file not shown.
Before ![]() (image error) Size: 273 KiB |
Binary file not shown.
Before ![]() (image error) Size: 28 KiB |
Binary file not shown.
Before ![]() (image error) Size: 27 KiB |
|
@ -1,32 +0,0 @@
|
|||
## 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][Discord].
|
||||
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][Discord].
|
||||
- Replace the `YOUR_CLIENT_ID_HERE` in this link:
|
||||
`https://discord.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://discord.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
|
||||
|
||||
|
||||
[Discord]: https://discord.com/developers/applications/me
|
|
@ -1,37 +0,0 @@
|
|||
# Donate
|
||||
|
||||
Ellie is an [open-source project][toastielab], 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.
|
||||
|
||||
## Perks
|
||||
|
||||
Donating to us also gives you the following benefits:
|
||||
|
||||
- A hoisted **Patron** role in [Ellie Discord server][discord-server]
|
||||
- Access to exclusive **#donator-general** text and voice channels
|
||||
- **3000 candy** on the public bot per dollar donated (after fees)
|
||||
|
||||
## Patreon
|
||||
|
||||
You can set up a monthly pledge on [Patreon][patreon] and support the project's growth, and also get candy rewards for every month you donate!
|
||||
|
||||
!!! Note
|
||||
Connect your Discord account on Patreon to receive your candy automatically
|
||||
|
||||
[![img][patreon-button]][patreon]
|
||||
|
||||
## PayPal
|
||||
|
||||
You can also donate to us through [PayPal][paypal] for one-time donations using the button below, or by donating to `toastie@dragonschildstudios.com`.
|
||||
|
||||
!!! Note
|
||||
Mention your Discord username or user id in the payment note to receive candy rewards.
|
||||
|
||||
[![img][paypal-button]][paypal]
|
||||
|
||||
[toastielab]: https://toastielab.dev/EllieBotDevs/elliebot
|
||||
[discord-server]: https://discord.nadeko.bot/
|
||||
[patreon]: https://www.patreon.com/elliebot
|
||||
[patreon-button]: ./assets/patreon.png
|
||||
[paypal]: https://paypal.me/toastie_t0ast
|
||||
[paypal-button]: ./assets/paypal.png
|
|
@ -1,235 +0,0 @@
|
|||
# EllieBot 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
|
||||
|
||||
!!! failure
|
||||
This script is broken and should no be used. please use [Desktop Guide](../guides/desktop-guide.md)
|
||||
|
||||
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 e-install.sh https://toastielab.dev/EllieBotDevs/ellie-bash-installer/raw/branch/v6/e-install.sh
|
||||
bash e-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 `ellie/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 e-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 e-install.sh https://toastielab.dev/EllieBotDevs/ellie-bash-installer/raw/branch/v6/e-install.sh && bash e-install.sh`
|
||||
4. Select option 1, and select a NEWER version
|
||||
|
||||
## Running Ellie
|
||||
|
||||
There are two main methods to run EllieBot: 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 `e-install.sh` and `ellie` is located.
|
||||
2. Create a new tmux session: `tmux new -s ellie`
|
||||
- The above command will create a new session named **ellie**. You may replace **ellie** with any name you prefer.
|
||||
3. Run the installer: `bash e-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. Ellie 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 ellie`. *(Make sure to replace "ellie" 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 [EllieHub](desktop-guide.md) to run EllieBot.
|
||||
|
||||
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 Ellie.
|
||||
|
||||
1. Access the directory where `e-install.sh` and `ellie` is located.
|
||||
2. Use the following command to create a service that will be used to execute `EllieRun.bash`:
|
||||
```bash
|
||||
echo "[Unit]
|
||||
Description=EllieBot service
|
||||
After=network.target
|
||||
StartLimitIntervalSec=60
|
||||
StartLimitBurst=2
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$USER
|
||||
WorkingDirectory=$PWD
|
||||
ExecStart=/bin/bash EllieRun.bash
|
||||
#ExecStart=./ellie/EllieBot
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
SyslogIdentifier=EllieBot
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/ellie.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 Ellie:
|
||||
```bash
|
||||
cat <<EOF > EllieRun.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 EllieBot 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 EllieBot..."
|
||||
|
||||
while true; do
|
||||
if [[ -d $PWD/ellie ]]; then
|
||||
cd "$PWD/ellie" || {
|
||||
echo "[ERROR] Failed to change working directory to '$PWD/ellie'" >&2
|
||||
echo "[INFO] Exiting..."
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
echo "[WARN] '$PWD/ellie' doesn't exist" >&2
|
||||
echo "[INFO] Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
./EllieBot || {
|
||||
echo "[ERROR] An error occurred when trying to start EllieBot" >&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 EllieBot..."
|
||||
done
|
||||
|
||||
echo "[INFO] Stopping EllieBot..."
|
||||
EOF
|
||||
```
|
||||
|
||||
With everything set up, you can run EllieBot in one of three modes:
|
||||
|
||||
1. **Auto-Restart Mode**: EllieBot will restart automatically if you restart it via the `.die` command.
|
||||
- To enable this mode, start the service: `sudo systemctl start ellie`
|
||||
2. **Auto-Restart on Reboot Mode**: In addition to auto-restarting after `.die`, EllieBot will also start automatically on system reboot.
|
||||
- To enable this mode, run:
|
||||
```bash
|
||||
sudo systemctl enable ellie
|
||||
sudo systemctl start ellie
|
||||
```
|
||||
3. **Standard Mode**: EllieBot will stop completely when you use `.die`, without restarting automatically.
|
||||
- To switch to this mode:
|
||||
1. Stop the service: `sudo systemctl stop ellie`
|
||||
2. Edit the service file: `sudo <editor> /etc/systemd/system/ellie.service`
|
||||
3. Modify the `ExecStart` line:
|
||||
- **Comment out**: `ExecStart=/bin/bash EllieRun.bash`
|
||||
- **Uncomment**: `#ExecStart=./ellie/EllieBot`
|
||||
4. Save and exit the editor.
|
||||
5. Reload systemd: `sudo systemctl daemon-reload`
|
||||
6. Disable automatic startup: `sudo systemctl disable ellie`
|
||||
7. Start EllieBot manually: `sudo systemctl start ellie`
|
||||
|
||||
///
|
|
@ -1,53 +0,0 @@
|
|||
# EllieBot Desktop Guide (via EllieHub)
|
||||
|
||||
### 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 [elliehub](https://toastielab.dev/EllieBotDevs/EllieHub/releases/latest).
|
||||
|
||||

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

|
||||
|
||||
3. If you want to use the music module, click on the settings icon then click **`Install`** next to `ffmpeg` and `yt-dlp` near the top of the setting tab.
|
||||
4. Click on the newly created bot
|
||||
|
||||
5. Click on **Install** located above the live console (This may take a bit)
|
||||
|
||||

|
||||

|
||||
|
||||
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 EllieBot
|
||||
|
||||
- Either click on **`RUN`** button in the updater or run the bot via its desktop shortcut.
|
||||
|
||||
## Updating EllieBot
|
||||
|
||||
!!! warning "IMPORTANT"
|
||||
|
||||
- Make sure Ellie 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 `elliehub` 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
|
|
@ -1,72 +0,0 @@
|
|||
# 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 EllieBot with Docker
|
||||
|
||||
When deploying EllieBot 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 EllieBot with Docker
|
||||
|
||||
1. Move to a directory where you want your Elliebot's data folder to be (data folder will keep the database and config files) and create a data folder there.
|
||||
``` sh
|
||||
cd ~ && mkdir ellie && cd ellie && 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 ellie toastielab.dev/elliebotdevs/elliebot:v6 -e bot_token=YOUR_TOKEN_HERE -v "./data:/app/data" && docker logs -f --tail 500 ellie
|
||||
```
|
||||
3. Enjoy! 🎉
|
||||
|
||||
### Updating your bot
|
||||
|
||||
If you want to update elliebot 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 toastielab.dev/elliebotdevs/elliebot:v6
|
||||
```
|
||||
2. Re-run your bot the same way you did before
|
||||
``` sh
|
||||
docker run -d --name ellie toastielab.dev/elliebotdevs/elliebot:v6 -e bot_token=YOUR_TOKEN_HERE -v "./data:/app/data" && docker logs -f --tail 500 ellie
|
||||
```
|
||||
3. Done! 🎉
|
||||
|
||||
///
|
||||
/// tab | Docker Compose
|
||||
|
||||
1. **Choose Your Workspace:** Select a directory where you'll set up your EllieBot stack. Use your terminal to navigate to this directory. For the purpose of this guide, we'll use `/opt/stacks/ellie/` 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:
|
||||
ellie:
|
||||
image: toastielab.dev/elliebotdevs/elliebot:v6
|
||||
container_name: ellie
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Europe/Rome # Modify this to your timezone
|
||||
bot_token: YOUR_TOKEN_HERE
|
||||
volumes:
|
||||
- /opt/stacks/ellie/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/ellie/` 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.
|
||||
|
||||
///
|
|
@ -1,66 +0,0 @@
|
|||
# Setting Up EllieBot 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 ellie 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://toastielab.dev/EllieBotDevs/elliebot -b v6 --depth 1`
|
||||
3. `cd elliebot/src/EllieBot`
|
||||
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 EllieBot.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 elliebot 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/elliebot`
|
||||
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/EllieBot/`
|
||||
6. Copy old data, and new strings
|
||||
- `cp -r -fo .\output-old\data\ .\output\`
|
||||
7. Run the bot
|
||||
- `cd output`
|
||||
- `dotnet EllieBot.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 elliebot'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
|
|
@ -1,54 +0,0 @@
|
|||
## Setting up Ellie on a Linux VPS (Digital Ocean Droplet)
|
||||
|
||||
If you want Ellie 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 Ellie on Linux Digital Ocean Droplet using the link [DigitalOcean](https://m.do.co/c/1bb1db830f41/) (by using this link, you will get **$10 credit** and also support Ellie)
|
||||
|
||||
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 EllieBot**
|
||||
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 Ellie 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 Ellie on a VPS (Digital Ocean)]: #setting-up-ellie-on-a-linux-vps-digital-ocean-droplet
|
|
@ -1,40 +0,0 @@
|
|||
# EllieBot Documentation
|
||||
|
||||
<!-- ![img][header] -->
|
||||
|
||||
## Inviting Ellie
|
||||
|
||||
There are two versions of Ellie, a public bot and a self-hostable bot.
|
||||
|
||||
To invite public Ellie to your server or to view its commands, click on the buttons below:
|
||||
|
||||
[:material-plus: Add Ellie to your server][invite]{ .md-button .md-button--primary }
|
||||
[:material-format-list-text: View commands][commands]{ .md-button }
|
||||
|
||||
To self-host your own Ellie, use the guides below:
|
||||
|
||||
- [:material-television-guide: Desktop guide (Windows/Linux/macOS)][desktop-guide]
|
||||
- [:material-console: CLI guide (Linux/macOS)][cli-guide]
|
||||
- [:material-docker: Docker guide][docker-guide]
|
||||
- [:material-source-branch: From source guide][from-source-guide]
|
||||
|
||||
In case you need any help, join our [Discord server][discord-server] where we may provide support.
|
||||
|
||||
## About Ellie
|
||||
|
||||
EllieBot is an [open source project][toastielab]. Any issues with the bot may be filed [here][issues].
|
||||
|
||||
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.
|
||||
|
||||
[invite]: https://discordapp.com/oauth2/authorize?client_id=608119997713350679&scope=bot&permissions=66186303/
|
||||
[commands]: https://commands.elliebot.net/
|
||||
[desktop-guide]: ./guides/desktop-guide.md
|
||||
[cli-guide]: ./guides/cli-guide.md
|
||||
[docker-guide]: ./guides/docker-guide.md
|
||||
[from-source-guide]: ./guides/source-guide.md
|
||||
[discord-server]: https://discord.gg/etQdZxSyEH
|
||||
[toastielab]: https://toastielab.dev/EllieBotDevs/elliebot
|
||||
[issues]: https://toastielab.dev/EllieBotDevs/elliebot/issues
|
||||
[donate]: ./donate.md
|
|
@ -1,18 +0,0 @@
|
|||
# Canary 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, canaries have 2 methods with which you can initialize and cleanup your canary*
|
||||
|
||||
|
||||
- `InitializeAsync` Runs when the marmalade which contains this canary is being loaded
|
||||
- `DisposeAsync` Runs when the marmalade which contains this canary is being unloaded
|
|
@ -1,279 +0,0 @@
|
|||
## Practice
|
||||
|
||||
This section will guide you through how to create a simple custom marmalade. You can find the entirety of this code hosted [here](https://toastielab.dev/ellie/example_marmalade)
|
||||
|
||||
#### Prerequisite
|
||||
- [.net8 sdk](https://dotnet.microsoft.com/en-us/download) installed
|
||||
- Optional: use [vscode](https://code.visualstudio.com/download) to write code
|
||||
|
||||
#### There are currently two ways of creating a marmalade and you can view both of them using the tabs below.
|
||||
|
||||
/// tab | Using our template
|
||||
|
||||
### Prerequisite
|
||||
- [git](https://git-scm.com/downloads) installed
|
||||
|
||||
### Guide
|
||||
|
||||
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
||||
|
||||
- Install the ellie-marmalade template
|
||||
- `git clone https://toastielab.dev/EllieBotDevs/ellie-marmalade`
|
||||
- `cd ellie-marmalade`
|
||||
- `dotnet new install .\`
|
||||
|
||||
- Create a new folder and move into it
|
||||
- `mkdir example_marmalade `
|
||||
- `cd example_marmalade`
|
||||
|
||||
- Make a new Ellie Marmalade project
|
||||
- `dotnet new ellie-marmalade`
|
||||
- This can be any name you want you just have to specify `-n <any name you want here>` after the first part of the command
|
||||
- Here is an example `dotnet new ellie-marmalade -n my-cool-marmalade`
|
||||
- This will create a marmalade project with the name my-cool-marmalade
|
||||
|
||||
Now follow the instructions below and you should be good to go.
|
||||
///
|
||||
|
||||
/// tab | Building from scratch
|
||||
|
||||
### Guide
|
||||
|
||||
!!! info
|
||||
This requires writing a little bit of code but we will help you through it as much as we can.
|
||||
|
||||
|
||||
### Without any further issues we shall now begin
|
||||
|
||||
- Open your favorite terminal and navigate to a folder where you will keep your project .
|
||||
|
||||
- Create a new folder
|
||||
- `mkdir example_marmalade`
|
||||
- Create a new .net class library
|
||||
- `dotnet new classlib`
|
||||
- Open the current folder with your favorite editor/IDE. In this case we'll use VsCode
|
||||
- `code .`
|
||||
- Remove the `Class1.cs` file
|
||||
- Replace the contents of the `.csproj` file with the following contents
|
||||
```xml
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<!-- Reduces some boilerplate in your .cs files -->
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
<!-- Use latest .net features -->
|
||||
<LangVersion>preview</LangVersion>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<GenerateRequiresPreviewFeaturesAttribute>true</GenerateRequiresPreviewFeaturesAttribute>
|
||||
|
||||
<!-- tell .net that this library will be used as a plugin -->
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Base marmalade package. You MUST reference this in order to have a working marmalade -->
|
||||
<!-- Also, this package comes from Toastielab, which requires you to have a NuGet.Config file next to your .csproj -->
|
||||
<PackageReference Include="Ellie.Marmalade" Version="6.*">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
|
||||
<!-- Note: If you want to use EllieBot services etc... You will have to manually clone
|
||||
the https://toastielab.dev/EllieBotDevs/elliebot repo locally and reference the EllieBot.csproj because there is no EllieBot package atm.
|
||||
It is strongly recommended that you checkout a specific tag which matches your version of ellie,
|
||||
as there could be breaking changes even between minor versions of EllieBot.
|
||||
For example if you're running EllieBot 4.1.0 locally for which you want to create a marmalade for,
|
||||
you should do "git checkout 4.1.0" in your EllieBot solution and then reference the EllieBot.csproj
|
||||
-->
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Copy shortcut and full strings to output (if they exist) -->
|
||||
<ItemGroup>
|
||||
<None Update="res.yml;cmds.yml;strings/**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
```
|
||||
- Create a `MyCanary.cs` file and add the following contents
|
||||
```cs
|
||||
using EllieBot.Marmalade;
|
||||
using Discord;
|
||||
|
||||
public sealed class MyCanary : Canary
|
||||
{
|
||||
[cmd]
|
||||
public async Task Hello(AnyContext ctx)
|
||||
{
|
||||
await ctx.Channel.SendMessageAsync($"Hello everyone!");
|
||||
}
|
||||
|
||||
[cmd]
|
||||
public async Task Hello(AnyContext ctx, IUser target)
|
||||
{
|
||||
await ctx.ConfirmLocalizedAsync("hello", target);
|
||||
}
|
||||
}
|
||||
```
|
||||
- Create `res.yml` and `cmds.yml` files with the following contents
|
||||
|
||||
`res.yml`
|
||||
```yml
|
||||
marmalade.description: "This is my marmalade's description"
|
||||
hello: "Hello {0}, from res.yml!"
|
||||
```
|
||||
|
||||
`cmds.yml`
|
||||
```yml
|
||||
hello:
|
||||
desc: "This is a basic hello command"
|
||||
args:
|
||||
- ""
|
||||
- "@Someone"
|
||||
```
|
||||
|
||||
- Add `NuGet.Config` file which will let you use the base Ellie.Marmalade package. This file should always look like this and you shouldn't change it
|
||||
|
||||
```xml
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
||||
<add key="toastielab.dev" value="https://toastielab.dev/api/packages/ellie/nuget/index.json" protocolVersion="3" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
///
|
||||
|
||||
### Build it
|
||||
|
||||
- Build your Marmalade into a dll that Ellie can load. In your terminal, type:
|
||||
- `dotnet publish -o bin/marmalades/example_marmalade /p:DebugType=embedded`
|
||||
|
||||
- Done. You can now try it out in action.
|
||||
|
||||
### Try it out
|
||||
|
||||
- Copy the `bin/marmalades/example_marmalade` folder into your EllieBot's `data/marmalades/` folder. (EllieBot version 4.1.0+)
|
||||
|
||||
- Load it with `.maload example_marmalade`
|
||||
|
||||
- In the channel your bot can see, run the following commands to try it out
|
||||
- `.hello` and
|
||||
- `.hello @<someone>`
|
||||
|
||||
- Check its information with
|
||||
- `.mainfo example_marmalade`
|
||||
|
||||
- Unload it
|
||||
- `.maunload example_marmalade`
|
||||
|
||||
- 🎉 Congrats! You've just made your first marmalade! 🎉
|
||||
|
||||
## Theory
|
||||
|
||||
Marmalade system allows you to write independent marmalades (known as "modules", "cogs" or "plugins" in other software) which you can then load, unload and update at will without restarting the bot.
|
||||
|
||||
The marmalade base classes used for development are open source [here](https://toastielab.dev/EllieBotDevs/elliebot/src/branch/v5/src/Ellie.Marmalade) in case you need reference, as there is no generated documentation at the moment.
|
||||
|
||||
### Term list
|
||||
|
||||
#### Marmalade
|
||||
|
||||
- The project itself which compiles to a single `.dll` (and some optional auxiliary files), it can contain multiple [Canaries](#canary), [Services](#service), and [ParamParsers](#param-parser)
|
||||
|
||||
#### Canary
|
||||
|
||||
- A class which will be added as a single Module to EllieBot on load. It also acts as a [lifecycle handler](canary-lifecycle.md) and as a singleton service with the support for initialize and cleanup.
|
||||
- It can contain a Canary (called SubCanary) but only 1 level of nesting is supported (you can only have a canary contain a subcanary, but a subcanary can't contain any other canaries)
|
||||
- Canaries 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`
|
||||
|
||||
#### Canary 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 marmalade.
|
||||
- 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 marmalade.
|
||||
|
||||
##### Example project folder structure:
|
||||
- uwu/
|
||||
- uwu.csproj
|
||||
- uwu.cs
|
||||
- res.yml
|
||||
- cmds.yml
|
||||
|
||||
##### Example output folder structure:
|
||||
- marmalades/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
|
||||
- cmds/
|
||||
- en-us.yml
|
||||
|
||||
##### Example output folder structure:
|
||||
- marmalades/uwu/
|
||||
- uwu.dll
|
||||
- strings/
|
||||
- res/
|
||||
- en-us.yml
|
||||
- cmds/
|
||||
- en-us.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 marmalade is loaded and running, running `.stringsreload` will reload the responses without the need to reload the marmalade or restart the bot.
|
||||
|
||||
#### Bot marmalade config file
|
||||
|
||||
- Marmalade config is kept in `marmalades/marmalade.yml` file
|
||||
- At the moment this config only keeps track of which marmalades are currently loaded (they will also be always loaded at startup)
|
||||
- If a marmalade 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 marmalade 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 Canary 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 `.maunload` followed by a bot restart, or if you want to find what is causing the marmalade unloadability issues, you can check the [microsoft's assembly unloadability debugging guide](https://docs.microsoft.com/en-us/dotnet/standard/assembly/unloadability)
|
|
@ -1,31 +0,0 @@
|
|||
## Getting Started
|
||||
|
||||
### What is the Marmalade system?
|
||||
|
||||
- It is a dynamic module/plugin/cog system for EllieBot introduced in **EllieBot 4.1.0**
|
||||
|
||||
- Allows developers to add custom functionality to Ellie 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/marmalades` folder and are loaded, unloaded and handled through discord commands.
|
||||
- `.maload` Loads the specified marmalade (see `.h .maload`)
|
||||
- `.maunload` Unloads the specified marmalade (see `.h .maunload`)
|
||||
- `.mainfo` Checks marmalades information (see `.h .mainfo`)
|
||||
- `.malist` Lists the available marmalades (see `.h .malist`)
|
||||
|
||||
### How to make one?
|
||||
|
||||
Marmalades 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 Marmalade.
|
||||
|
||||
Follow the [creating a marmalade guide](creating-a-marmalade.md)
|
||||
|
||||
### Where to get marmalades other people made?
|
||||
|
||||
⚠ *It is EXTREMELY, and I repeat **EXTREMELY** dangerous to run marmalades 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 marmalades 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 [Ellie's Home server](https://discord.gg/etQdZxSyEH)
|
|
@ -1,18 +0,0 @@
|
|||
<!-- 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,3 +0,0 @@
|
|||
mkdocs-material~=9.6
|
||||
mkdocs~=1.6
|
||||
mkdocs-exclude~=1.0
|
|
@ -1,80 +0,0 @@
|
|||
site_name: EllieBot docs
|
||||
site_url: https://docs.elliebot.net
|
||||
repo_url: 'https://toastielab.dev/EllieBotDevs/elliebot'
|
||||
site_author: Toastie_t0ast
|
||||
docs_dir: 'md'
|
||||
copyright: Copyright © 2018 - 2025 Toastie_t0ast & EllieBotDevs
|
||||
theme:
|
||||
name: material
|
||||
palette:
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: default
|
||||
primary: indigo
|
||||
accent: blue
|
||||
toggle:
|
||||
icon: material/weather-sunny
|
||||
name: Switch to dark mode
|
||||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
primary: black
|
||||
accent: blue
|
||||
toggle:
|
||||
icon: material/weather-night
|
||||
name: Switch to light mode
|
||||
features:
|
||||
- navigation.instant
|
||||
- navigation.expand
|
||||
- navigation.top
|
||||
font:
|
||||
text: Source Sans 3
|
||||
code: Source Code Pro
|
||||
logo: assets/favicon.png
|
||||
favicon: assets/favicon.png
|
||||
icon:
|
||||
repo: material/git
|
||||
extra:
|
||||
homepage: https://elliebot.net
|
||||
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
|
||||
options:
|
||||
custom_icons:
|
||||
- overrides/.icons
|
||||
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://commands.elliebot.net
|
||||
- Features Explained:
|
||||
- Basic Creds: creds-guide.md
|
||||
- Marmalade System:
|
||||
- marmalade/getting-started.md
|
||||
- marmalade/creating-a-marmalade.md
|
||||
- marmalade/canary-lifecycle.md
|
||||
- Donate: donate.md
|
|
@ -6,7 +6,7 @@
|
|||
[Setup]
|
||||
AppName = {param:botname|EllieBot}
|
||||
AppVersion={#version}
|
||||
AppPublisher=Toastie_t0ast
|
||||
AppPublisher=Toastie
|
||||
DefaultDirName={param:installpath|{commonpf}\EllieBot}
|
||||
DefaultGroupName=EllieBot
|
||||
UninstallDisplayIcon={app}\{#sysfolder}\ellie_icon.ico
|
||||
|
@ -33,25 +33,28 @@ Uninstallable=no
|
|||
;install
|
||||
Source: "src\EllieBot\bin\Release\{#platform}\{#target}\publish\*"; DestDir: "{app}\{#sysfolder}"; Permissions: users-full; Flags: recursesubdirs onlyifdoesntexist ignoreversion createallsubdirs; Excludes: "*.pdb, *.db"
|
||||
|
||||
;reinstall - Copy all files, but don't overwrite any data files because users will lose their customization if they don't have a backup
|
||||
Source: "src\EllieBot\bin\Release\{#platform}\{#target}\publish\*"; DestDir: "{app}\{#sysfolder}"; Permissions: users-full; Flags: recursesubdirs ignoreversion onlyifdestfileexists createallsubdirs; Excludes: "*.pdb, *.db, data\*, creds.yml";
|
||||
;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\EllieBot\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\EllieBot\bin\Release\{#platform}\{#target}\publish\data\*"; DestDir: "{app}\{#sysfolder}\data"; Permissions: users-full; Flags: recursesubdirs onlyifdoesntexist createallsubdirs;
|
||||
; overwrite strings
|
||||
Source: "src\EllieBot\bin\Release\{#platform}\{#target}\publish\strings\*"; DestDir: "{app}\{#sysfolder}\strings"; Permissions: users-full; Flags: recursesubdirs ignoreversion onlyifdestfileexists createallsubdirs;
|
||||
; overwrite strings and aliases
|
||||
Source: "src\EllieBot\bin\Release\{#platform}\{#target}\publish\data\aliases.yml"; DestDir: "{app}\{#sysfolder}\data\"; Permissions: users-full; Flags: recursesubdirs ignoreversion onlyifdestfileexists createallsubdirs;
|
||||
Source: "src\EllieBot\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: "https://docs.elliebot.net/ellie/features/yml-explained/"; Flags: postinstall shellexec runasoriginaluser; Description: "Open setup guide"
|
||||
; Filename: "https://docs.elliebot.net/ellie/"; 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}\EllieBot"; Filename: "{app}\{#sysfolder}\EllieBot.exe"; IconFilename: "{app}\{#sysfolder}\ellie_icon.ico"
|
||||
Name: "{app}\EllieBot"; Filename: "{app}\{#sysfolder}\EllieBot.exe"; IconFilename: "{app}\{#sysfolder}\ellie_icon.ico"
|
||||
Name: "{app}\creds"; Filename: "{app}\{#sysfolder}\creds.yml"
|
||||
Name: "{app}\data"; Filename: "{app}\{#sysfolder}\data"
|
||||
Name: "{app}\strings"; Filename: "{app}\{#sysfolder}\strings"
|
||||
|
||||
; desktop shortcut
|
||||
Name: "{commondesktop}\{#SetupSetting("AppName")}"; Filename: "{app}\EllieBot";
|
||||
|
@ -59,7 +62,7 @@ Name: "{commondesktop}\{#SetupSetting("AppName")}"; Filename: "{app}\EllieBot";
|
|||
[Code]
|
||||
function GetFileName(const AFileName: string): string;
|
||||
begin
|
||||
Result := ExpandConstant('{app}\{#sysfolder}\data\' + AFileName);
|
||||
Result := ExpandConstant('{app}\{#sysfolder}\' + AFileName);
|
||||
end;
|
||||
|
||||
procedure CurStepChanged(CurStep: TSetupStep);
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
</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" />
|
||||
<PackageReference Include="Discord.Net.Core" Version="3.16.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.67.0" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.6" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.62.0" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="15.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -11,7 +11,7 @@ Project which contains source generators required for EllieBot project
|
|||
-- How it works --
|
||||
Creates a file "strs.cs" containing a class called "strs" in "EllieBot" namespace.
|
||||
|
||||
Loads "strings/responses.en-US.json" and creates a property or a function for each key in the responses json file based on whether the value has string format placeholders or not.
|
||||
Loads "data/strings/responses.en-US.json" and creates a property or a function for each key in the responses json file based on whether the value has string format placeholders or not.
|
||||
|
||||
- If a value has no placeholders, it creates a property in the strs class which returns an instance of a LocStr struct containing only the key and no replacement parameters
|
||||
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.29.3" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.28.2" />
|
||||
<PackageReference Include="Grpc" Version="2.46.6" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.68.1" PrivateAssets="All" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.66.0" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -12,6 +12,7 @@ service GrpcOther {
|
|||
rpc GetRoles(GetRolesRequest) returns (GetRolesReply);
|
||||
|
||||
rpc GetCurrencyLb(GetLbRequest) returns (CurrencyLbReply);
|
||||
rpc GetXpLb(GetLbRequest) returns (XpLbReply);
|
||||
rpc GetWaifuLb(GetLbRequest) returns (WaifuLbReply);
|
||||
|
||||
rpc GetShardStats(google.protobuf.Empty) returns (stream ShardStatsReply);
|
||||
|
@ -77,6 +78,17 @@ message GetLbRequest {
|
|||
int32 perPage = 2;
|
||||
}
|
||||
|
||||
message XpLbReply {
|
||||
repeated XpLbEntryReply entries = 1;
|
||||
}
|
||||
|
||||
message XpLbEntryReply {
|
||||
string user = 1;
|
||||
uint64 userId = 2;
|
||||
int64 totalXp = 3;
|
||||
int64 level = 4;
|
||||
}
|
||||
|
||||
message WaifuLbReply {
|
||||
repeated WaifuLbEntry entries = 1;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,22 @@ service GrpcXp {
|
|||
|
||||
rpc GetXpSettings(GetXpSettingsRequest) returns (GetXpSettingsReply);
|
||||
|
||||
rpc AddExclusion(AddExclusionRequest) returns (AddExclusionReply);
|
||||
rpc DeleteExclusion(DeleteExclusionRequest) returns (DeleteExclusionReply);
|
||||
|
||||
rpc AddReward(AddRewardRequest) returns (AddRewardReply);
|
||||
rpc DeleteReward(DeleteRewardRequest) returns (DeleteRewardReply);
|
||||
|
||||
rpc GetUserXp(GetUserXpRequest) returns (GetUserXpReply);
|
||||
|
||||
rpc SetServerExclusion(SetServerExclusionRequest) returns (SetServerExclusionReply);
|
||||
}
|
||||
|
||||
message SetServerExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
bool serverExcluded = 2;
|
||||
}
|
||||
|
||||
message SetServerExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetXpLbRequest {
|
||||
|
@ -45,19 +57,47 @@ message ResetUserXpReply {
|
|||
}
|
||||
|
||||
message GetXpSettingsReply {
|
||||
repeated ExclItemReply exclusions = 1;
|
||||
repeated RewItemReply rewards = 2;
|
||||
bool serverExcluded = 3;
|
||||
}
|
||||
|
||||
message GetXpSettingsRequest {
|
||||
uint64 guildId = 1;
|
||||
}
|
||||
|
||||
message ExclItemReply {
|
||||
string type = 1;
|
||||
uint64 id = 2;
|
||||
string name = 3;
|
||||
}
|
||||
|
||||
message RewItemReply {
|
||||
int32 level = 1;
|
||||
string type = 2;
|
||||
string value = 3;
|
||||
}
|
||||
|
||||
message AddExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
string type = 2;
|
||||
uint64 id = 3;
|
||||
}
|
||||
|
||||
message AddExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message DeleteExclusionRequest {
|
||||
uint64 guildId = 1;
|
||||
string type = 2;
|
||||
uint64 id = 3;
|
||||
}
|
||||
|
||||
message DeleteExclusionReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message AddRewardRequest {
|
||||
uint64 guildId = 1;
|
||||
int32 level = 2;
|
||||
|
@ -77,18 +117,4 @@ message DeleteRewardRequest {
|
|||
|
||||
message DeleteRewardReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetUserXpRequest {
|
||||
uint64 guildId = 1;
|
||||
uint64 userId = 2;
|
||||
}
|
||||
|
||||
message GetUserXpReply {
|
||||
int64 xp = 1;
|
||||
int64 requiredXp = 2;
|
||||
int64 level = 3;
|
||||
string club = 4;
|
||||
string clubIcon = 5;
|
||||
int32 rank = 6;
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
option csharp_namespace = "EllieBot.GrpcApi";
|
||||
|
||||
package greet;
|
||||
|
||||
service GrpcXpShop {
|
||||
rpc AddXpShopItem (AddXpShopItemRequest) returns (AddXpShopItemReply);
|
||||
rpc GetShopItems (GetShopItemsRequest) returns (GetShopItemsReply);
|
||||
rpc UseShopItem (UseShopItemRequest) returns (UseShopItemReply);
|
||||
rpc BuyShopItem (BuyShopItemRequest) returns (BuyShopItemReply);
|
||||
}
|
||||
|
||||
message UseShopItemRequest {
|
||||
uint64 userId = 1;
|
||||
string uniqueName = 2;
|
||||
GrpcXpShopItemType itemType = 3;
|
||||
}
|
||||
|
||||
message UseShopItemReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message BuyShopItemRequest {
|
||||
uint64 userId = 1;
|
||||
string uniqueName = 2;
|
||||
GrpcXpShopItemType itemType = 3;
|
||||
}
|
||||
|
||||
message BuyShopItemReply {
|
||||
bool success = 1;
|
||||
optional BuyShopItemError Error = 2;
|
||||
}
|
||||
|
||||
enum BuyShopItemError {
|
||||
NotEnough = 0;
|
||||
AlreadyOwned = 1;
|
||||
Unknown = 2;
|
||||
}
|
||||
|
||||
message AddXpShopItemRequest {
|
||||
XpShopItem item = 1;
|
||||
string uniqueName = 2;
|
||||
GrpcXpShopItemType itemType = 3;
|
||||
}
|
||||
|
||||
message AddXpShopItemReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message GetShopItemsRequest {
|
||||
|
||||
}
|
||||
|
||||
message GetShopItemsReply {
|
||||
repeated XpShopItem bgs = 1;
|
||||
repeated XpShopItem frames = 2;
|
||||
}
|
||||
|
||||
message XpShopItem {
|
||||
string Name = 1;
|
||||
string Description = 2;
|
||||
int64 Price = 3;
|
||||
string FullUrl = 4;
|
||||
string PreviewUrl = 5;
|
||||
}
|
||||
|
||||
enum GrpcXpShopItemType {
|
||||
Bg = 0;
|
||||
Frame = 1;
|
||||
}
|
|
@ -11,9 +11,9 @@ namespace EllieBot.Tests
|
|||
{
|
||||
public class CommandStringsTests
|
||||
{
|
||||
private const string responsesPath = "../../../../EllieBot/strings/responses";
|
||||
private const string commandsPath = "../../../../EllieBot/strings/commands";
|
||||
private const string aliasesPath = "../../../../EllieBot/strings/aliases.yml";
|
||||
private const string responsesPath = "../../../../EllieBot/data/strings/responses";
|
||||
private const string commandsPath = "../../../../EllieBot/data/strings/commands";
|
||||
private const string aliasesPath = "../../../../EllieBot/data/aliases.yml";
|
||||
|
||||
[Test]
|
||||
public void AllCommandNamesHaveStrings()
|
||||
|
@ -36,7 +36,7 @@ namespace EllieBot.Tests
|
|||
}
|
||||
}
|
||||
|
||||
Assert.That(isSuccess, Is.True);
|
||||
Assert.IsTrue(isSuccess);
|
||||
}
|
||||
|
||||
private static string[] GetCommandMethodNames()
|
||||
|
@ -46,8 +46,8 @@ namespace EllieBot.Tests
|
|||
.Where(type => typeof(EllieModule).IsAssignableFrom(type) // if its a top level module
|
||||
|| !(type.GetCustomAttribute<GroupAttribute>(true) is null)) // or a submodule
|
||||
.SelectMany(x => x.GetMethods()
|
||||
.Where(mi => mi.CustomAttributes
|
||||
.Any(ca => ca.AttributeType == typeof(CmdAttribute))))
|
||||
.Where(mi => mi.CustomAttributes
|
||||
.Any(ca => ca.AttributeType == typeof(CmdAttribute))))
|
||||
.Select(x => x.Name.ToLowerInvariant())
|
||||
.ToArray();
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace EllieBot.Tests
|
|||
}
|
||||
}
|
||||
|
||||
Assert.That(isSuccess, Is.True);
|
||||
Assert.IsTrue(isSuccess);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -96,7 +96,7 @@ namespace EllieBot.Tests
|
|||
if (isSuccess)
|
||||
Assert.Pass();
|
||||
else
|
||||
Assert.Warn("There are some unused entries in aliases.yml");
|
||||
Assert.Warn("There are some unused entries in data/aliases.yml");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -107,7 +107,7 @@ namespace EllieBot.Tests
|
|||
var culture = new CultureInfo("en-US");
|
||||
|
||||
var methodNames = GetCommandMethodNames()
|
||||
.ToHashSet();
|
||||
.ToHashSet();
|
||||
|
||||
var isSuccess = true;
|
||||
// var allCommandNames = CommandNameLoadHelper.LoadCommandStrings(commandsPath));
|
||||
|
@ -117,13 +117,15 @@ namespace EllieBot.Tests
|
|||
|
||||
if (!methodNames.Contains(cmdName))
|
||||
{
|
||||
TestContext.Out.WriteLine(
|
||||
$"'{cmdName}' from commands.en-US.yml doesn't have a matching command method.");
|
||||
TestContext.Out.WriteLine($"'{cmdName}' from commands.en-US.yml doesn't have a matching command method.");
|
||||
isSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.That(isSuccess, Is.True, "There are some unused command strings in strings/commands.en-US.yml");
|
||||
if (isSuccess)
|
||||
Assert.IsTrue(isSuccess);
|
||||
else
|
||||
Assert.Warn("There are some unused command strings in data/strings/commands.en-US.yml");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,11 +18,11 @@ public class ConcurrentHashSetTests
|
|||
{
|
||||
var result = _set.Add((1, 2));
|
||||
|
||||
Assert.That(result, Is.EqualTo(true));
|
||||
Assert.AreEqual(true, result);
|
||||
|
||||
result = _set.Add((1, 2));
|
||||
|
||||
Assert.That(result, Is.EqualTo(false));
|
||||
Assert.AreEqual(false, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -31,10 +31,10 @@ public class ConcurrentHashSetTests
|
|||
_set.Add((1, 2));
|
||||
var result = _set.TryRemove((1, 2));
|
||||
|
||||
Assert.That(result, Is.EqualTo(true));
|
||||
Assert.AreEqual(true, result);
|
||||
|
||||
result = _set.TryRemove((1, 2));
|
||||
Assert.That(result, Is.EqualTo(false));
|
||||
Assert.AreEqual(false, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -48,7 +48,7 @@ public class ConcurrentHashSetTests
|
|||
_set.Add((3, 2)); // 3
|
||||
_set.Add((3, 2)); // 3
|
||||
|
||||
Assert.That(_set.Count, Is.EqualTo(3));
|
||||
Assert.AreEqual(3, _set.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -60,7 +60,7 @@ public class ConcurrentHashSetTests
|
|||
|
||||
_set.Clear();
|
||||
|
||||
Assert.That(_set.Count, Is.EqualTo(0));
|
||||
Assert.AreEqual(0, _set.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -69,10 +69,10 @@ public class ConcurrentHashSetTests
|
|||
_set.Add((1, 2));
|
||||
_set.Add((3, 2));
|
||||
|
||||
Assert.That(_set.Contains((1, 2)), Is.EqualTo(true));
|
||||
Assert.That(_set.Contains((3, 2)), Is.EqualTo(true));
|
||||
Assert.That(_set.Contains((2, 1)), Is.EqualTo(false));
|
||||
Assert.That(_set.Contains((2, 3)), Is.EqualTo(false));
|
||||
Assert.AreEqual(true, _set.Contains((1, 2)));
|
||||
Assert.AreEqual(true, _set.Contains((3, 2)));
|
||||
Assert.AreEqual(false, _set.Contains((2, 1)));
|
||||
Assert.AreEqual(false, _set.Contains((2, 3)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -86,8 +86,8 @@ public class ConcurrentHashSetTests
|
|||
// remove tuples which have even second item
|
||||
_set.RemoveWhere(static x => x.Item2 % 2 == 0);
|
||||
|
||||
Assert.That(_set.Count, Is.EqualTo(2));
|
||||
Assert.That(_set.Contains((1, 3)), Is.EqualTo(true));
|
||||
Assert.That(_set.Contains((2, 5)), Is.EqualTo(true));
|
||||
Assert.AreEqual(2, _set.Count);
|
||||
Assert.AreEqual(true, _set.Contains((1, 3)));
|
||||
Assert.AreEqual(true, _set.Contains((2, 5)));
|
||||
}
|
||||
}
|
|
@ -6,9 +6,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NUnit" Version="4.3.2" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
88
src/EllieBot.Tests/FishTests.cs
Normal file
88
src/EllieBot.Tests/FishTests.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
// using System;
|
||||
// using System.Collections.Generic;
|
||||
// using System.Diagnostics;
|
||||
// using System.IO;
|
||||
// using System.Linq;
|
||||
// using Ellie.Common;
|
||||
// using EllieBot.Modules.Games;
|
||||
// using NUnit.Framework;
|
||||
//
|
||||
// namespace EllieBot.Tests;
|
||||
//
|
||||
// public class FishTests
|
||||
// {
|
||||
// [Test]
|
||||
// public void TestWeather()
|
||||
// {
|
||||
// var fs = new FishService(null, null);
|
||||
//
|
||||
// var rng = new Random();
|
||||
//
|
||||
// // output = @"ro+dD:bN0uVqV3ZOAv6r""EFeA'A]u]uSyz2Qd'r#0Vf:5zOX\VgSsF8LgRCL/uOW";
|
||||
// while (true)
|
||||
// {
|
||||
// var output = "";
|
||||
// for (var i = 0; i < 64; i++)
|
||||
// {
|
||||
// var c = (char)rng.Next(33, 123);
|
||||
// output += c;
|
||||
// }
|
||||
//
|
||||
// output = "";
|
||||
// var weathers = new List<FishingWeather>();
|
||||
// for (var i = 0; i < 1_000_000; i++)
|
||||
// {
|
||||
// var w = fs.GetWeather(DateTime.UtcNow.AddHours(6 * i), output);
|
||||
// weathers.Add(w);
|
||||
// }
|
||||
//
|
||||
// var vals = weathers.GroupBy(x => x)
|
||||
// .ToDictionary(x => x.Key, x => x.Count());
|
||||
//
|
||||
// var str = weathers.Select(x => (int)x).Join("");
|
||||
// var maxLength = MaxLength(str);
|
||||
//
|
||||
// if (maxLength < 12)
|
||||
// {
|
||||
// foreach (var v in vals)
|
||||
// {
|
||||
// Console.WriteLine($"{v.Key}: {v.Value}");
|
||||
// }
|
||||
//
|
||||
// Console.WriteLine(output);
|
||||
// Console.WriteLine(maxLength);
|
||||
//
|
||||
// File.WriteAllText("data.txt", weathers.Select(x => (int)x).Join(""));
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // string with same characters
|
||||
// static int MaxLength(String s)
|
||||
// {
|
||||
// int ans = 1, temp = 1;
|
||||
//
|
||||
// // Traverse the string
|
||||
// for (int i = 1; i < s.Length; i++)
|
||||
// {
|
||||
// // If character is same as
|
||||
// // previous increment temp value
|
||||
// if (s[i] == s[i - 1])
|
||||
// {
|
||||
// ++temp;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ans = Math.Max(ans, temp);
|
||||
// temp = 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ans = Math.Max(ans, temp);
|
||||
//
|
||||
// // Return the required answer
|
||||
// return ans;
|
||||
// }
|
||||
// }
|
|
@ -1,4 +1,4 @@
|
|||
using Ellie.Common;
|
||||
using Ellie.Common;
|
||||
using EllieBot.Db.Models;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
@ -32,8 +32,7 @@ namespace EllieBot.Tests
|
|||
|
||||
// Evaluate the indices are ordered
|
||||
CheckIndices(collection);
|
||||
|
||||
Assert.That(collection.Count, Is.EqualTo(8));
|
||||
Assert.AreEqual(8, collection.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -46,9 +45,8 @@ namespace EllieBot.Tests
|
|||
collection.RemoveAt(6);
|
||||
|
||||
// Evaluate if the items got removed
|
||||
foreach (var item in collection){
|
||||
Assert.That(item.Id, Is.Not.EqualTo(5).Or.EqualTo(7), $"Item at index {item.Index} was not removed");
|
||||
}
|
||||
foreach (var item in collection)
|
||||
Assert.IsFalse(item.Id == 5 || item.Id == 7, $"Item at index {item.Index} was not removed");
|
||||
|
||||
CheckIndices(collection);
|
||||
|
||||
|
@ -63,7 +61,7 @@ namespace EllieBot.Tests
|
|||
var collection = GetCollectionSample<ShopEntry>();
|
||||
collection.Clear();
|
||||
|
||||
Assert.That(collection.Count, Is.EqualTo(0), "Collection has not been cleared.");
|
||||
Assert.IsTrue(collection.Count == 0, "Collection has not been cleared.");
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() =>
|
||||
{
|
||||
_ = collection[0];
|
||||
|
@ -80,7 +78,7 @@ namespace EllieBot.Tests
|
|||
|
||||
// Evaluate copy
|
||||
for (var index = 0; index < fullCopy.Length; index++)
|
||||
Assert.That(index, Is.EqualTo(fullCopy[index].Index));
|
||||
Assert.AreEqual(index, fullCopy[index].Index);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => collection.CopyTo(new ShopEntry[10], 4));
|
||||
Assert.Throws<ArgumentException>(() => collection.CopyTo(new ShopEntry[6], 0));
|
||||
|
@ -91,10 +89,10 @@ namespace EllieBot.Tests
|
|||
{
|
||||
var collection = GetCollectionSample<ShopEntry>();
|
||||
|
||||
Assert.That(collection.IndexOf(collection[4]), Is.EqualTo(4));
|
||||
Assert.That(collection.IndexOf(collection[0]), Is.EqualTo(0));
|
||||
Assert.That(collection.IndexOf(collection[7]), Is.EqualTo(7));
|
||||
Assert.That(collection.IndexOf(collection[9]), Is.EqualTo(9));
|
||||
Assert.AreEqual(4, collection.IndexOf(collection[4]));
|
||||
Assert.AreEqual(0, collection.IndexOf(collection[0]));
|
||||
Assert.AreEqual(7, collection.IndexOf(collection[7]));
|
||||
Assert.AreEqual(9, collection.IndexOf(collection[9]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -106,9 +104,9 @@ namespace EllieBot.Tests
|
|||
collection.Insert(5, new ShopEntry() { Id = 555 });
|
||||
collection.Insert(7, new ShopEntry() { Id = 777 });
|
||||
|
||||
Assert.That(collection.Count, Is.EqualTo(12));
|
||||
Assert.That(collection[5].Id, Is.EqualTo(555));
|
||||
Assert.That(collection[7].Id, Is.EqualTo(777));
|
||||
Assert.AreEqual(12, collection.Count);
|
||||
Assert.AreEqual(555, collection[5].Id);
|
||||
Assert.AreEqual(777, collection[7].Id);
|
||||
|
||||
CheckIndices(collection);
|
||||
|
||||
|
@ -136,9 +134,9 @@ namespace EllieBot.Tests
|
|||
collection.Remove(subCol[1]);
|
||||
CheckIndices(collection);
|
||||
|
||||
Assert.That(collection.Contains(subCol[0]), Is.True);
|
||||
Assert.That(collection.Contains(subCol[1]), Is.False);
|
||||
Assert.That(collection.Contains(subCol[2]), Is.True);
|
||||
Assert.IsTrue(collection.Contains(subCol[0]));
|
||||
Assert.IsFalse(collection.Contains(subCol[1]));
|
||||
Assert.IsTrue(collection.Contains(subCol[2]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -150,7 +148,7 @@ namespace EllieBot.Tests
|
|||
foreach (var item in collection)
|
||||
{
|
||||
enumerator.MoveNext();
|
||||
Assert.That(enumerator.Current, Is.EqualTo(item));
|
||||
Assert.AreEqual(item, enumerator.Current);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,8 +161,8 @@ namespace EllieBot.Tests
|
|||
collection[7] = new ShopEntry() { Id = 777 };
|
||||
CheckIndices(collection);
|
||||
|
||||
Assert.That(collection[4].Id, Is.EqualTo(444));
|
||||
Assert.That(collection[7].Id, Is.EqualTo(777));
|
||||
Assert.AreEqual(444, collection[4].Id);
|
||||
Assert.AreEqual(777, collection[7].Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -175,7 +173,7 @@ namespace EllieBot.Tests
|
|||
private void CheckIndices<T>(IndexedCollection<T> collection) where T : class, IIndexed
|
||||
{
|
||||
for (var index = 0; index < collection.Count; index++)
|
||||
Assert.That(collection[index].Index, Is.EqualTo(index));
|
||||
Assert.AreEqual(index, collection[index].Index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -187,4 +185,4 @@ namespace EllieBot.Tests
|
|||
private IndexedCollection<T> GetCollectionSample<T>(IEnumerable<T> sample = default) where T : DbEntity, IIndexed, new()
|
||||
=> new IndexedCollection<T>(sample ?? Enumerable.Range(0, 10).Select(x => new T() { Id = x }));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ namespace EllieBot.Tests
|
|||
{
|
||||
var num = default(kwum);
|
||||
|
||||
Assert.That(0, Is.EqualTo(num.GetHashCode()));
|
||||
Assert.AreEqual(0, num.GetHashCode());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -20,7 +20,7 @@ namespace EllieBot.Tests
|
|||
var num1 = new kwum("234");
|
||||
var num2 = new kwum("234");
|
||||
|
||||
Assert.That(num1.GetHashCode(), Is.EqualTo(num2.GetHashCode()));
|
||||
Assert.AreEqual(num1.GetHashCode(), num2.GetHashCode());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -29,7 +29,7 @@ namespace EllieBot.Tests
|
|||
var num1 = new kwum("234");
|
||||
var num2 = new kwum("235");
|
||||
|
||||
Assert.That(num1.GetHashCode(), Is.Not.EqualTo(num2.GetHashCode()));
|
||||
Assert.AreNotEqual(num1.GetHashCode(), num2.GetHashCode());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -38,7 +38,7 @@ namespace EllieBot.Tests
|
|||
var num1 = new kwum("hgbkhdbk");
|
||||
var num2 = new kwum("hgbkhdbk");
|
||||
|
||||
Assert.That(num1.GetHashCode(), Is.EqualTo(num2.GetHashCode()));
|
||||
Assert.AreEqual(num1.GetHashCode(), num2.GetHashCode());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -47,7 +47,7 @@ namespace EllieBot.Tests
|
|||
var num1 = new kwum("hgbkhd");
|
||||
var num2 = new kwum("hgbkhd");
|
||||
|
||||
Assert.That(num1, Is.EqualTo(num2));
|
||||
Assert.AreEqual(num1, num2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -56,22 +56,21 @@ namespace EllieBot.Tests
|
|||
var num1 = new kwum("hgbk5d");
|
||||
var num2 = new kwum("hgbk4d");
|
||||
|
||||
Assert.That(num1, Is.Not.EqualTo(num2));
|
||||
Assert.AreNotEqual(num1, num2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseValidValue()
|
||||
{
|
||||
var validValue = "234e";
|
||||
|
||||
Assert.That(kwum.TryParse(validValue, out _), Is.True);
|
||||
Assert.True(kwum.TryParse(validValue, out _));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseInvalidValue()
|
||||
{
|
||||
var invalidValue = "1234";
|
||||
Assert.That(kwum.TryParse(invalidValue, out _), Is.False);
|
||||
Assert.False(kwum.TryParse(invalidValue, out _));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -80,7 +79,7 @@ namespace EllieBot.Tests
|
|||
var validValue = "qwerf4bm";
|
||||
kwum.TryParse(validValue, out var parsedValue);
|
||||
|
||||
Assert.That(parsedValue, Is.EqualTo(new kwum(validValue)));
|
||||
Assert.AreEqual(parsedValue, new kwum(validValue));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -89,7 +88,7 @@ namespace EllieBot.Tests
|
|||
var validValue = "46g5yh";
|
||||
kwum.TryParse(validValue, out var parsedValue);
|
||||
|
||||
Assert.That(validValue, Is.EqualTo(parsedValue.ToString()));
|
||||
Assert.AreEqual(validValue, parsedValue.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -97,37 +96,37 @@ namespace EllieBot.Tests
|
|||
{
|
||||
var num = new kwum(10);
|
||||
|
||||
Assert.That(10, Is.EqualTo((int)num));
|
||||
Assert.That(num, Is.EqualTo((kwum)10));
|
||||
Assert.AreEqual(10, (int)num);
|
||||
Assert.AreEqual(num, (kwum)10);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestConverstionsToString()
|
||||
{
|
||||
var num = new kwum(10);
|
||||
Assert.That("c", Is.EqualTo(num.ToString()));
|
||||
Assert.AreEqual("c", num.ToString());
|
||||
num = new kwum(123);
|
||||
Assert.That("5v", Is.EqualTo(num.ToString()));
|
||||
Assert.AreEqual("5v", num.ToString());
|
||||
|
||||
// leading zeros have no meaning
|
||||
Assert.That(new kwum("22225v"), Is.EqualTo(num));
|
||||
Assert.AreEqual(new kwum("22225v"), num);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMaxValue()
|
||||
{
|
||||
var num = new kwum(int.MaxValue - 1);
|
||||
Assert.That("3zzzzzy", Is.EqualTo(num.ToString()));
|
||||
Assert.AreEqual("3zzzzzy", num.ToString());
|
||||
|
||||
num = new kwum(int.MaxValue);
|
||||
Assert.That("3zzzzzz", Is.EqualTo(num.ToString()));
|
||||
Assert.AreEqual("3zzzzzz", num.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPower()
|
||||
{
|
||||
var num = new kwum((int)Math.Pow(32, 2));
|
||||
Assert.That("322", Is.EqualTo(num.ToString()));
|
||||
Assert.AreEqual("322", num.ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using NUnit.Framework;
|
|||
|
||||
namespace EllieBot.Tests;
|
||||
|
||||
|
||||
public class NewDeckTests
|
||||
{
|
||||
private RegularDeck _deck;
|
||||
|
@ -16,8 +17,8 @@ public class NewDeckTests
|
|||
[Test]
|
||||
public void TestCount()
|
||||
{
|
||||
Assert.That(52, Is.EqualTo(_deck.TotalCount));
|
||||
Assert.That(52, Is.EqualTo(_deck.CurrentCount));
|
||||
Assert.AreEqual(52, _deck.TotalCount);
|
||||
Assert.AreEqual(52, _deck.CurrentCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -25,10 +26,10 @@ public class NewDeckTests
|
|||
{
|
||||
var card = _deck.Draw();
|
||||
|
||||
Assert.That(card, Is.Not.Null);
|
||||
Assert.That(card.Suit, Is.EqualTo(RegularSuit.Hearts));
|
||||
Assert.That(card.Value, Is.EqualTo(RegularValue.Ace));
|
||||
Assert.That(_deck.CurrentCount, Is.EqualTo(_deck.TotalCount - 1));
|
||||
Assert.IsNotNull(card);
|
||||
Assert.AreEqual(card.Suit, RegularSuit.Hearts);
|
||||
Assert.AreEqual(card.Value, RegularValue.Ace);
|
||||
Assert.AreEqual(_deck.CurrentCount, _deck.TotalCount - 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -41,12 +42,12 @@ public class NewDeckTests
|
|||
|
||||
var lastCard = _deck.Draw();
|
||||
|
||||
Assert.That(lastCard, Is.Not.Null);
|
||||
Assert.That(lastCard, Is.EqualTo(new RegularCard(RegularSuit.Spades, RegularValue.King)));
|
||||
Assert.IsNotNull(lastCard);
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Spades, RegularValue.King), lastCard);
|
||||
|
||||
var noCard = _deck.Draw();
|
||||
|
||||
Assert.That(noCard, Is.Null);
|
||||
Assert.IsNull(noCard);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -55,8 +56,8 @@ public class NewDeckTests
|
|||
var ace = _deck.Draw()!;
|
||||
var two = _deck.Draw()!;
|
||||
|
||||
Assert.That("Ace of Hearts", Is.EqualTo(ace.GetName()));
|
||||
Assert.That("Two of Hearts", Is.EqualTo(two.GetName()));
|
||||
Assert.AreEqual("Ace of Hearts", ace.GetName());
|
||||
Assert.AreEqual("Two of Hearts", two.GetName());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -65,8 +66,8 @@ public class NewDeckTests
|
|||
var ace = _deck.Peek()!;
|
||||
|
||||
var tenOfSpades = _deck.Peek(48);
|
||||
Assert.That(new RegularCard(RegularSuit.Hearts, RegularValue.Ace), Is.EqualTo(ace));
|
||||
Assert.That(new RegularCard(RegularSuit.Spades, RegularValue.Ten), Is.EqualTo(tenOfSpades));
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Hearts, RegularValue.Ace), ace);
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Spades, RegularValue.Ten), tenOfSpades);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -75,9 +76,9 @@ public class NewDeckTests
|
|||
var quadDeck = new MultipleRegularDeck(4);
|
||||
var count = quadDeck.TotalCount;
|
||||
|
||||
Assert.That(52 * 4, Is.EqualTo(count));
|
||||
Assert.AreEqual(52 * 4, count);
|
||||
|
||||
var card = quadDeck.Peek(54);
|
||||
Assert.That(new RegularCard(RegularSuit.Hearts, RegularValue.Three), Is.EqualTo(card));
|
||||
Assert.AreEqual(new RegularCard(RegularSuit.Hearts, RegularValue.Three), card);
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ namespace EllieBot.Tests
|
|||
var pubsub = new EventPubSub();
|
||||
await pubsub.Sub(key, data =>
|
||||
{
|
||||
Assert.That(expected, Is.EqualTo(data));
|
||||
Assert.AreEqual(expected, data);
|
||||
Assert.Pass();
|
||||
return default;
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ namespace EllieBot.Tests
|
|||
var pubsub = new EventPubSub();
|
||||
await pubsub.Sub(key, data =>
|
||||
{
|
||||
Assert.That(expected, Is.EqualTo(data));
|
||||
Assert.AreEqual(expected, data);
|
||||
Assert.Pass();
|
||||
return default;
|
||||
});
|
||||
|
@ -48,13 +48,13 @@ namespace EllieBot.Tests
|
|||
var pubsub = new EventPubSub();
|
||||
await pubsub.Sub(key, data =>
|
||||
{
|
||||
Assert.That(expected, Is.EqualTo(data));
|
||||
Assert.AreEqual(expected, data);
|
||||
Assert.Pass();
|
||||
return default;
|
||||
});
|
||||
await pubsub.Unsub(key, data =>
|
||||
{
|
||||
Assert.That(expected, Is.EqualTo(data));
|
||||
Assert.AreEqual(expected, data);
|
||||
Assert.Pass();
|
||||
return default;
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ namespace EllieBot.Tests
|
|||
|
||||
ValueTask Action(byte[] data)
|
||||
{
|
||||
Assert.That(localData, Is.EqualTo(data));
|
||||
Assert.AreEqual(localData, data);
|
||||
Assert.Pass();
|
||||
return default;
|
||||
}
|
||||
|
@ -112,14 +112,14 @@ namespace EllieBot.Tests
|
|||
|
||||
ValueTask Action1(object data)
|
||||
{
|
||||
Assert.That(localData, Is.EqualTo(data));
|
||||
Assert.AreEqual(localData, data);
|
||||
successCounter += 10;
|
||||
return default;
|
||||
}
|
||||
|
||||
ValueTask Action2(object data)
|
||||
{
|
||||
Assert.That(localData, Is.EqualTo(data));
|
||||
Assert.AreEqual(localData, data);
|
||||
successCounter++;
|
||||
return default;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ namespace EllieBot.Tests
|
|||
await pubsub.Unsub(key, Action2); // - 1/
|
||||
await pubsub.Pub(key, localData);
|
||||
|
||||
Assert.That(successCounter, Is.EqualTo(11), "Not all events are raised.");
|
||||
Assert.AreEqual(successCounter, 11, "Not all events are raised.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ namespace EllieBot.Tests
|
|||
var point = @"0001F338";
|
||||
var hopefullyEmoji = YamlHelper.UnescapeUnicodeCodePoint(point);
|
||||
|
||||
Assert.That("🌸", Is.EqualTo(hopefullyEmoji), "Yaml unescape doesn't work properly.");
|
||||
Assert.AreEqual("🌸", hopefullyEmoji, hopefullyEmoji);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="System.Threading.Channels" Version="9.0.1" />
|
||||
<PackageReference Include="Serilog" Version="3.1.1" />
|
||||
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace EllieBot.Voice
|
|||
{
|
||||
internal static unsafe class Sodium
|
||||
{
|
||||
|
||||
private const string SODIUM = "data/lib/libsodium";
|
||||
|
||||
[DllImport(SODIUM, EntryPoint = "crypto_secretbox_easy", CallingConvention = CallingConvention.Cdecl)]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
|
@ -15,7 +14,6 @@ namespace EllieBot.VotesApi
|
|||
public const string SchemeName = "AUTHORIZATION_SCHEME";
|
||||
public const string DiscordsClaim = "DISCORDS_CLAIM";
|
||||
public const string TopggClaim = "TOPGG_CLAIM";
|
||||
public const string DiscordbotlistClaim = "DISCORDBOTLIST_CLAIM";
|
||||
|
||||
private readonly IConfiguration _conf;
|
||||
|
||||
|
@ -26,60 +24,17 @@ namespace EllieBot.VotesApi
|
|||
: base(options, logger, encoder)
|
||||
=> _conf = conf;
|
||||
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
await Task.Yield();
|
||||
|
||||
if (!Request.Headers.TryGetValue("Authorization", out var authHeader))
|
||||
{
|
||||
return AuthenticateResult.Fail("Authorization header missing");
|
||||
}
|
||||
|
||||
var authToken = authHeader.ToString().Trim();
|
||||
if (string.IsNullOrWhiteSpace(authToken))
|
||||
{
|
||||
return AuthenticateResult.Fail("Authorization token empty");
|
||||
}
|
||||
|
||||
var claims = new List<Claim>();
|
||||
|
||||
var discsKey = _conf[ConfKeys.DISCORDS_KEY]?.Trim();
|
||||
var topggKey = _conf[ConfKeys.TOPGG_KEY]?.Trim();
|
||||
var dblKey = _conf[ConfKeys.DISCORDBOTLIST_KEY]?.Trim();
|
||||
if (_conf[ConfKeys.DISCORDS_KEY].Trim() == Request.Headers["Authorization"].ToString().Trim())
|
||||
claims.Add(new(DiscordsClaim, "true"));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(discsKey)
|
||||
&& System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(
|
||||
Encoding.UTF8.GetBytes(discsKey),
|
||||
Encoding.UTF8.GetBytes(authToken)))
|
||||
{
|
||||
claims.Add(new Claim(DiscordsClaim, "true"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(topggKey)
|
||||
&& System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(
|
||||
Encoding.UTF8.GetBytes(topggKey),
|
||||
Encoding.UTF8.GetBytes(authToken)))
|
||||
{
|
||||
if (_conf[ConfKeys.TOPGG_KEY] == Request.Headers["Authorization"].ToString().Trim())
|
||||
claims.Add(new Claim(TopggClaim, "true"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(dblKey)
|
||||
&& System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(
|
||||
Encoding.UTF8.GetBytes(dblKey),
|
||||
Encoding.UTF8.GetBytes(authToken)))
|
||||
{
|
||||
claims.Add(new Claim(DiscordbotlistClaim, "true"));
|
||||
}
|
||||
|
||||
if (claims.Count == 0)
|
||||
{
|
||||
return AuthenticateResult.Fail("Invalid authorization token");
|
||||
}
|
||||
|
||||
return AuthenticateResult.Success(
|
||||
new AuthenticationTicket(
|
||||
new ClaimsPrincipal(new ClaimsIdentity(claims)),
|
||||
SchemeName));
|
||||
return Task.FromResult(AuthenticateResult.Success(new(new(new ClaimsIdentity(claims)), SchemeName)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,5 @@
|
|||
{
|
||||
public const string DISCORDS_KEY = "DiscordsKey";
|
||||
public const string TOPGG_KEY = "TopGGKey";
|
||||
public const string DISCORDBOTLIST_KEY = "DiscordbotListKey";
|
||||
}
|
||||
}
|
|
@ -12,6 +12,12 @@
|
|||
/// </summary>
|
||||
public string Bot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains totalVotes, votesMonth, votes24, hasVoted - a list of IDs of users who have voted this month, and
|
||||
/// Voted24 - a list of IDs of users who have voted today
|
||||
/// </summary>
|
||||
public string Votes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of event, whether it is a vote event or test event
|
||||
/// </summary>
|
|
@ -1,20 +0,0 @@
|
|||
namespace EllieBot.VotesApi
|
||||
{
|
||||
public class DiscordbotlistVoteWebhookModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The avatar hash of the user
|
||||
/// </summary>
|
||||
public string Avatar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The username of the user who voted
|
||||
/// </summary>
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the user who voted
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
}
|
||||
}
|
|
@ -4,6 +4,5 @@
|
|||
{
|
||||
public const string DiscordsAuth = "DiscordsAuth";
|
||||
public const string TopggAuth = "TopggAuth";
|
||||
public const string DiscordbotlistAuth = "DiscordbotlistAuth";
|
||||
}
|
||||
}
|
33
src/EllieBot.VotesApi/Controllers/DiscordsController.cs
Normal file
33
src/EllieBot.VotesApi/Controllers/DiscordsController.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EllieBot.VotesApi.Services;
|
||||
|
||||
namespace EllieBot.VotesApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class DiscordsController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<DiscordsController> _logger;
|
||||
private readonly IVotesCache _cache;
|
||||
|
||||
public DiscordsController(ILogger<DiscordsController> logger, IVotesCache cache)
|
||||
{
|
||||
_logger = logger;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
[HttpGet("new")]
|
||||
[Authorize(Policy = Policies.DiscordsAuth)]
|
||||
public async Task<IEnumerable<Vote>> New()
|
||||
{
|
||||
var votes = await _cache.GetNewDiscordsVotesAsync();
|
||||
if (votes.Count > 0)
|
||||
_logger.LogInformation("Sending {NewDiscordsVotes} new discords votes", votes.Count);
|
||||
return votes;
|
||||
}
|
||||
}
|
||||
}
|
34
src/EllieBot.VotesApi/Controllers/TopGgController.cs
Normal file
34
src/EllieBot.VotesApi/Controllers/TopGgController.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EllieBot.VotesApi.Services;
|
||||
|
||||
namespace EllieBot.VotesApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class TopGgController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<TopGgController> _logger;
|
||||
private readonly IVotesCache _cache;
|
||||
|
||||
public TopGgController(ILogger<TopGgController> logger, IVotesCache cache)
|
||||
{
|
||||
_logger = logger;
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
[HttpGet("new")]
|
||||
[Authorize(Policy = Policies.TopggAuth)]
|
||||
public async Task<IEnumerable<Vote>> New()
|
||||
{
|
||||
var votes = await _cache.GetNewTopGgVotesAsync();
|
||||
if (votes.Count > 0)
|
||||
_logger.LogInformation("Sending {NewTopggVotes} new topgg votes", votes.Count);
|
||||
|
||||
return votes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,32 +2,33 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EllieBot.GrpcVotesApi;
|
||||
using EllieBot.VotesApi.Services;
|
||||
|
||||
namespace EllieBot.VotesApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
public class WebhookController(ILogger<WebhookController> logger, VoteService.VoteServiceClient client)
|
||||
: ControllerBase
|
||||
public class WebhookController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<WebhookController> _logger;
|
||||
private readonly IVotesCache _votesCache;
|
||||
|
||||
public WebhookController(ILogger<WebhookController> logger, IVotesCache votesCache)
|
||||
{
|
||||
_logger = logger;
|
||||
_votesCache = votesCache;
|
||||
}
|
||||
|
||||
[HttpPost("/discordswebhook")]
|
||||
[Authorize(Policy = Policies.DiscordsAuth)]
|
||||
public async Task<IActionResult> DiscordsWebhook([FromBody] DiscordsVoteWebhookModel data)
|
||||
{
|
||||
if ((data.Type?.Contains("vote") ?? false) == false)
|
||||
return Ok();
|
||||
|
||||
logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
|
||||
_logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
data.User,
|
||||
data.Bot,
|
||||
"discords.com");
|
||||
|
||||
await client.VoteReceivedAsync(new GrpcVoteData()
|
||||
{
|
||||
Type = VoteType.Discords,
|
||||
UserId = data.User,
|
||||
});
|
||||
|
||||
await _votesCache.AddNewDiscordsVote(data.User);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
@ -35,34 +36,12 @@ namespace EllieBot.VotesApi.Controllers
|
|||
[Authorize(Policy = Policies.TopggAuth)]
|
||||
public async Task<IActionResult> TopggWebhook([FromBody] TopggVoteWebhookModel data)
|
||||
{
|
||||
logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
_logger.LogInformation("User {UserId} has voted for Bot {BotId} on {Platform}",
|
||||
data.User,
|
||||
data.Bot,
|
||||
"top.gg");
|
||||
|
||||
await client.VoteReceivedAsync(new GrpcVoteData()
|
||||
{
|
||||
Type = VoteType.Topgg,
|
||||
UserId = data.User,
|
||||
});
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("/discordbotlistwebhook")]
|
||||
[Authorize(Policy = Policies.DiscordbotlistAuth)]
|
||||
public async Task<IActionResult> DiscordbotlistWebhook([FromBody] DiscordbotlistVoteWebhookModel data)
|
||||
{
|
||||
logger.LogInformation("User {UserId} has voted for Bot on {Platform}",
|
||||
data.Id,
|
||||
"discordbotlist.com");
|
||||
|
||||
await client.VoteReceivedAsync(new GrpcVoteData()
|
||||
{
|
||||
Type = VoteType.Discordbotlist,
|
||||
UserId = data.Id,
|
||||
});
|
||||
|
||||
await _votesCache.AddNewTopggVote(data.User);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["EllieBot.VotesApi.csproj", "EllieBot.VotesApi/"]
|
||||
RUN dotnet restore "EllieBot.VotesApi/EllieBot.VotesApi.csproj"
|
||||
COPY . "EllieBot.VotesApi/"
|
||||
COPY ["src/EllieBot.VotesApi/EllieBot.VotesApi.csproj", "EllieBot.VotesApi/"]
|
||||
RUN dotnet restore "src/EllieBot.VotesApi/EllieBot.VotesApi.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/EllieBot.VotesApi"
|
||||
RUN dotnet build "EllieBot.VotesApi.csproj" -c Release -o /app/build
|
||||
|
||||
|
|
|
@ -7,12 +7,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MorseCode.ITask" Version="2.0.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||
<PackageReference Include="Grpc.AspNetCore" Version="2.70.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="Protos/vote.proto" GrpcServices="Client" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using EllieBot.VotesApi;
|
||||
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
|
||||
static IHostBuilder CreateHostBuilder(string[] args)
|
||||
=> Host.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration(c => c.AddEnvironmentVariables())
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder
|
||||
.UseStartup<Startup>();
|
||||
});
|
||||
static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
|
|
@ -1,24 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package vote;
|
||||
|
||||
option csharp_namespace = "EllieBot.GrpcVotesApi";
|
||||
|
||||
enum VoteType {
|
||||
TOPGG = 0;
|
||||
DISCORDBOTLIST = 1;
|
||||
DISCORDS = 2;
|
||||
}
|
||||
|
||||
message GrpcVoteData {
|
||||
string userId = 1;
|
||||
VoteType type = 2;
|
||||
}
|
||||
|
||||
message GrpcVoteResult {
|
||||
|
||||
}
|
||||
|
||||
service VoteService {
|
||||
rpc VoteReceived (GrpcVoteData) returns (GrpcVoteResult);
|
||||
}
|
100
src/EllieBot.VotesApi/Services/FileVotesCache.cs
Normal file
100
src/EllieBot.VotesApi/Services/FileVotesCache.cs
Normal file
|
@ -0,0 +1,100 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using MorseCode.ITask;
|
||||
|
||||
namespace EllieBot.VotesApi.Services
|
||||
{
|
||||
public class FileVotesCache : IVotesCache
|
||||
{
|
||||
// private const string STATS_FILE = "store/stats.json";
|
||||
private const string TOPGG_FILE = "store/topgg.json";
|
||||
private const string DISCORDS_FILE = "store/discords.json";
|
||||
|
||||
private readonly SemaphoreSlim _locker = new SemaphoreSlim(1, 1);
|
||||
|
||||
public FileVotesCache()
|
||||
{
|
||||
if (!Directory.Exists("store"))
|
||||
Directory.CreateDirectory("store");
|
||||
|
||||
if (!File.Exists(TOPGG_FILE))
|
||||
File.WriteAllText(TOPGG_FILE, "[]");
|
||||
|
||||
if (!File.Exists(DISCORDS_FILE))
|
||||
File.WriteAllText(DISCORDS_FILE, "[]");
|
||||
}
|
||||
|
||||
public ITask AddNewTopggVote(string userId)
|
||||
=> AddNewVote(TOPGG_FILE, userId);
|
||||
|
||||
public ITask AddNewDiscordsVote(string userId)
|
||||
=> AddNewVote(DISCORDS_FILE, userId);
|
||||
|
||||
private async ITask AddNewVote(string file, string userId)
|
||||
{
|
||||
await _locker.WaitAsync();
|
||||
try
|
||||
{
|
||||
var votes = await GetVotesAsync(file);
|
||||
votes.Add(userId);
|
||||
await File.WriteAllTextAsync(file, JsonSerializer.Serialize(votes));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_locker.Release();
|
||||
}
|
||||
}
|
||||
|
||||
public async ITask<IList<Vote>> GetNewTopGgVotesAsync()
|
||||
{
|
||||
var votes = await EvictTopggVotes();
|
||||
return votes;
|
||||
}
|
||||
|
||||
public async ITask<IList<Vote>> GetNewDiscordsVotesAsync()
|
||||
{
|
||||
var votes = await EvictDiscordsVotes();
|
||||
return votes;
|
||||
}
|
||||
|
||||
private ITask<List<Vote>> EvictTopggVotes()
|
||||
=> EvictVotes(TOPGG_FILE);
|
||||
|
||||
private ITask<List<Vote>> EvictDiscordsVotes()
|
||||
=> EvictVotes(DISCORDS_FILE);
|
||||
|
||||
private async ITask<List<Vote>> EvictVotes(string file)
|
||||
{
|
||||
await _locker.WaitAsync();
|
||||
try
|
||||
{
|
||||
|
||||
var ids = await GetVotesAsync(file);
|
||||
await File.WriteAllTextAsync(file, "[]");
|
||||
|
||||
return ids?
|
||||
.Select(x => (Ok: ulong.TryParse(x, out var r), Id: r))
|
||||
.Where(x => x.Ok)
|
||||
.Select(x => new Vote
|
||||
{
|
||||
UserId = x.Id
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_locker.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private async ITask<IList<string>> GetVotesAsync(string file)
|
||||
{
|
||||
await using var fs = File.Open(file, FileMode.Open);
|
||||
var votes = await JsonSerializer.DeserializeAsync<List<string>>(fs);
|
||||
return votes;
|
||||
}
|
||||
}
|
||||
}
|
13
src/EllieBot.VotesApi/Services/IVotesCache.cs
Normal file
13
src/EllieBot.VotesApi/Services/IVotesCache.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using MorseCode.ITask;
|
||||
|
||||
namespace EllieBot.VotesApi.Services
|
||||
{
|
||||
public interface IVotesCache
|
||||
{
|
||||
ITask<IList<Vote>> GetNewTopGgVotesAsync();
|
||||
ITask<IList<Vote>> GetNewDiscordsVotesAsync();
|
||||
ITask AddNewTopggVote(string userId);
|
||||
ITask AddNewDiscordsVote(string userId);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
using System;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using EllieBot.GrpcVotesApi;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using EllieBot.VotesApi.Services;
|
||||
|
||||
namespace EllieBot.VotesApi
|
||||
{
|
||||
|
@ -22,16 +21,11 @@ namespace EllieBot.VotesApi
|
|||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
|
||||
services.AddGrpcClient<VoteService.VoteServiceClient>(options =>
|
||||
{
|
||||
options.Address = new Uri(Configuration["BotGrpcHost"]!);
|
||||
})
|
||||
.ConfigureChannel((sp, c) =>
|
||||
{
|
||||
c.Credentials = ChannelCredentials.Insecure;
|
||||
c.ServiceProvider = sp;
|
||||
});
|
||||
services.AddSingleton<IVotesCache, FileVotesCache>();
|
||||
services.AddSwaggerGen(static c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "EllieBot.VotesApi", Version = "v1" });
|
||||
});
|
||||
|
||||
services
|
||||
.AddAuthentication(opts =>
|
||||
|
@ -46,18 +40,9 @@ namespace EllieBot.VotesApi
|
|||
opts.DefaultPolicy = new AuthorizationPolicyBuilder(AuthHandler.SchemeName)
|
||||
.RequireAssertion(static _ => false)
|
||||
.Build();
|
||||
opts.AddPolicy(Policies.DiscordsAuth,
|
||||
static policy => policy.RequireClaim(AuthHandler.DiscordsClaim));
|
||||
opts.AddPolicy(Policies.TopggAuth,
|
||||
static policy => policy.RequireClaim(AuthHandler.TopggClaim));
|
||||
opts.AddPolicy(Policies.DiscordbotlistAuth,
|
||||
static policy => policy.RequireClaim(AuthHandler.DiscordbotlistClaim));
|
||||
opts.AddPolicy(Policies.DiscordsAuth, static policy => policy.RequireClaim(AuthHandler.DiscordsClaim));
|
||||
opts.AddPolicy(Policies.TopggAuth, static policy => policy.RequireClaim(AuthHandler.TopggClaim));
|
||||
});
|
||||
|
||||
services.AddCors(x => x.AddDefaultPolicy(cpb =>
|
||||
cpb.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyOrigin()));
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
@ -66,6 +51,8 @@ namespace EllieBot.VotesApi
|
|||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(static c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "EllieBot.VotesApi v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
|
|
@ -8,7 +8,5 @@
|
|||
},
|
||||
"DiscordsKey": "my_discords_key",
|
||||
"TopGGKey": "my_topgg_key",
|
||||
"DiscordBotListKey": "my_discordbotlist_key",
|
||||
"BotGrpcHost": "http://127.0.0.1:59384",
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
|
360
src/EllieBot/.editorconfig
Normal file
360
src/EllieBot/.editorconfig
Normal file
|
@ -0,0 +1,360 @@
|
|||
root = true
|
||||
# Remove the line below if you want to inherit .editorconfig settings from higher directories
|
||||
|
||||
[obj/**]
|
||||
generated_code = true
|
||||
|
||||
# C# files
|
||||
[*.cs]
|
||||
|
||||
|
||||
#### Core EditorConfig Options ####
|
||||
|
||||
# Indentation and spacing
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
tab_width = 4
|
||||
|
||||
# New line preferences
|
||||
end_of_line = crlf
|
||||
insert_final_newline = false
|
||||
|
||||
#### .NET Coding Conventions ####
|
||||
|
||||
# Organize usings
|
||||
dotnet_separate_import_directive_groups = false
|
||||
dotnet_sort_system_directives_first = false
|
||||
|
||||
# this. and Me. preferences
|
||||
dotnet_style_qualification_for_event = false
|
||||
dotnet_style_qualification_for_field = false
|
||||
dotnet_style_qualification_for_method = false
|
||||
dotnet_style_qualification_for_property = false
|
||||
|
||||
# Language keywords vs BCL types preferences
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
|
||||
dotnet_style_predefined_type_for_member_access = true:suggestion
|
||||
|
||||
# Parentheses preferences
|
||||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
|
||||
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
|
||||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
|
||||
|
||||
# Modifier preferences
|
||||
dotnet_style_require_accessibility_modifiers = always:error
|
||||
|
||||
# Expression-level preferences
|
||||
dotnet_style_coalesce_expression = true
|
||||
dotnet_style_collection_initializer = true
|
||||
dotnet_style_explicit_tuple_names = true
|
||||
dotnet_style_namespace_match_folder = true
|
||||
dotnet_style_null_propagation = true
|
||||
dotnet_style_object_initializer = true
|
||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||
dotnet_style_prefer_auto_properties = true:warning
|
||||
dotnet_style_prefer_compound_assignment = true
|
||||
dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion
|
||||
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
|
||||
dotnet_style_prefer_inferred_anonymous_type_member_names = true
|
||||
dotnet_style_prefer_inferred_tuple_names = true
|
||||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
|
||||
dotnet_style_prefer_simplified_boolean_expressions = true
|
||||
dotnet_style_prefer_simplified_interpolation = true
|
||||
|
||||
# Field preferences
|
||||
dotnet_style_readonly_field = true:suggestion
|
||||
|
||||
# Parameter preferences
|
||||
dotnet_code_quality_unused_parameters = all:warning
|
||||
|
||||
#### C# Coding Conventions ####
|
||||
|
||||
# var preferences
|
||||
csharp_style_var_elsewhere = true
|
||||
csharp_style_var_for_built_in_types = true:suggestion
|
||||
csharp_style_var_when_type_is_apparent = true:suggestion
|
||||
|
||||
# Expression-bodied members
|
||||
csharp_style_expression_bodied_accessors = true:suggestion
|
||||
csharp_style_expression_bodied_indexers = true:suggestion
|
||||
csharp_style_expression_bodied_lambdas = true:suggestion
|
||||
csharp_style_expression_bodied_local_functions = true:suggestion
|
||||
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_operators = when_on_single_line:suggestion
|
||||
csharp_style_expression_bodied_properties = true:suggestion
|
||||
|
||||
# Pattern matching preferences
|
||||
csharp_style_pattern_matching_over_as_with_null_check = true:error
|
||||
csharp_style_pattern_matching_over_is_with_cast_check = true:error
|
||||
csharp_style_prefer_not_pattern = true:error
|
||||
csharp_style_prefer_pattern_matching = true:suggestion
|
||||
csharp_style_prefer_switch_expression = true
|
||||
|
||||
# Null-checking preferences
|
||||
csharp_style_conditional_delegate_call = true:error
|
||||
|
||||
# Modifier preferences
|
||||
csharp_prefer_static_local_function = true
|
||||
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async
|
||||
|
||||
# Code-block preferences
|
||||
csharp_prefer_braces = when_multiline:warning
|
||||
csharp_prefer_simple_using_statement = true
|
||||
|
||||
# Expression-level preferences
|
||||
csharp_prefer_simple_default_expression = true
|
||||
csharp_style_deconstructed_variable_declaration = true
|
||||
csharp_style_implicit_object_creation_when_type_is_apparent = true:error
|
||||
csharp_style_inlined_variable_declaration = true:warning
|
||||
csharp_style_pattern_local_over_anonymous_function = true
|
||||
csharp_style_prefer_index_operator = true
|
||||
csharp_style_prefer_range_operator = true
|
||||
csharp_style_throw_expression = true:error
|
||||
csharp_style_unused_value_assignment_preference = discard_variable:warning
|
||||
csharp_style_unused_value_expression_statement_preference = discard_variable
|
||||
|
||||
# 'using' directive preferences
|
||||
csharp_using_directive_placement = outside_namespace:error
|
||||
|
||||
# Enforce file-scoped namespaces
|
||||
csharp_style_namespace_declarations = file_scoped:error
|
||||
|
||||
# New line preferences
|
||||
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
|
||||
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
|
||||
csharp_style_allow_embedded_statements_on_same_line_experimental = false
|
||||
|
||||
#### C# Formatting Rules ####
|
||||
|
||||
# New line preferences
|
||||
csharp_new_line_before_catch = true
|
||||
csharp_new_line_before_else = true
|
||||
csharp_new_line_before_finally = true
|
||||
csharp_new_line_before_members_in_anonymous_types = true
|
||||
csharp_new_line_before_members_in_object_initializers = true
|
||||
csharp_new_line_before_open_brace = all
|
||||
csharp_new_line_between_query_expression_clauses = true
|
||||
|
||||
# Indentation preferences
|
||||
csharp_indent_block_contents = true
|
||||
csharp_indent_braces = false
|
||||
csharp_indent_case_contents = true
|
||||
csharp_indent_case_contents_when_block = true
|
||||
csharp_indent_labels = one_less_than_current
|
||||
csharp_indent_switch_labels = true
|
||||
|
||||
# Space preferences
|
||||
csharp_space_after_cast = false
|
||||
csharp_space_after_colon_in_inheritance_clause = true
|
||||
csharp_space_after_comma = true
|
||||
csharp_space_after_dot = false
|
||||
csharp_space_after_keywords_in_control_flow_statements = true
|
||||
csharp_space_after_semicolon_in_for_statement = true
|
||||
csharp_space_around_binary_operators = before_and_after
|
||||
csharp_space_around_declaration_statements = false
|
||||
csharp_space_before_colon_in_inheritance_clause = true
|
||||
csharp_space_before_comma = false
|
||||
csharp_space_before_dot = false
|
||||
csharp_space_before_open_square_brackets = false
|
||||
csharp_space_before_semicolon_in_for_statement = false
|
||||
csharp_space_between_empty_square_brackets = false
|
||||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
||||
|
||||
# Wrapping preferences
|
||||
csharp_preserve_single_line_blocks = true
|
||||
csharp_preserve_single_line_statements = false
|
||||
|
||||
#### Naming styles ####
|
||||
|
||||
# Naming rules
|
||||
|
||||
dotnet_naming_rule.private_readonly_field.symbols = private_readonly_field
|
||||
dotnet_naming_rule.private_readonly_field.style = begins_with_underscore
|
||||
dotnet_naming_rule.private_readonly_field.severity = warning
|
||||
|
||||
# dotnet_naming_rule.private_field.symbols = private_field
|
||||
# dotnet_naming_rule.private_field.style = camel_case
|
||||
# dotnet_naming_rule.private_field.severity = warning
|
||||
|
||||
dotnet_naming_rule.const_fields.symbols = const_fields
|
||||
dotnet_naming_rule.const_fields.style = all_upper
|
||||
dotnet_naming_rule.const_fields.severity = warning
|
||||
|
||||
# dotnet_naming_rule.class_should_be_pascal_case.severity = error
|
||||
# dotnet_naming_rule.class_should_be_pascal_case.symbols = class
|
||||
# dotnet_naming_rule.class_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.struct_should_be_pascal_case.severity = error
|
||||
dotnet_naming_rule.struct_should_be_pascal_case.symbols = struct
|
||||
dotnet_naming_rule.struct_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = error
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
|
||||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
|
||||
|
||||
# dotnet_naming_rule.types_should_be_pascal_case.severity = error
|
||||
# dotnet_naming_rule.types_should_be_pascal_case.symbols = types
|
||||
# dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
|
||||
|
||||
# dotnet_naming_rule.enum_should_be_pascal_case.severity = error
|
||||
# dotnet_naming_rule.enum_should_be_pascal_case.symbols = enum
|
||||
# dotnet_naming_rule.enum_should_be_pascal_case.style = pascal_case
|
||||
|
||||
# dotnet_naming_rule.property_should_be_pascal_case.severity = error
|
||||
# dotnet_naming_rule.property_should_be_pascal_case.symbols = property
|
||||
# dotnet_naming_rule.property_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.method_should_be_pascal_case.severity = error
|
||||
dotnet_naming_rule.method_should_be_pascal_case.symbols = method
|
||||
dotnet_naming_rule.method_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.async_method_should_be_ends_with_async.severity = error
|
||||
dotnet_naming_rule.async_method_should_be_ends_with_async.symbols = async_method
|
||||
dotnet_naming_rule.async_method_should_be_ends_with_async.style = ends_with_async
|
||||
|
||||
# dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error
|
||||
# dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
||||
# dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
||||
|
||||
dotnet_naming_rule.local_variable_should_be_camel_case.severity = error
|
||||
dotnet_naming_rule.local_variable_should_be_camel_case.symbols = local_variable
|
||||
dotnet_naming_rule.local_variable_should_be_camel_case.style = camel_case
|
||||
|
||||
# Symbol specifications
|
||||
|
||||
dotnet_naming_symbols.const_fields.required_modifiers = const
|
||||
dotnet_naming_symbols.const_fields.applicable_kinds = field
|
||||
|
||||
dotnet_naming_symbols.class.applicable_kinds = class
|
||||
dotnet_naming_symbols.class.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.class.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.interface.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.struct.applicable_kinds = struct
|
||||
dotnet_naming_symbols.struct.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.struct.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.enum.applicable_kinds = enum
|
||||
dotnet_naming_symbols.enum.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.enum.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.method.applicable_kinds = method
|
||||
dotnet_naming_symbols.method.applicable_accessibilities = public
|
||||
dotnet_naming_symbols.method.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.property.applicable_kinds = property
|
||||
dotnet_naming_symbols.property.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.property.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
|
||||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.types.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.private_readonly_field.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_readonly_field.applicable_accessibilities = private, protected
|
||||
dotnet_naming_symbols.private_readonly_field.required_modifiers = readonly
|
||||
|
||||
dotnet_naming_symbols.private_field.applicable_kinds = field
|
||||
dotnet_naming_symbols.private_field.applicable_accessibilities = private, protected
|
||||
dotnet_naming_symbols.private_field.required_modifiers =
|
||||
|
||||
dotnet_naming_symbols.async_method.applicable_kinds = method, local_function
|
||||
dotnet_naming_symbols.async_method.applicable_accessibilities = *
|
||||
dotnet_naming_symbols.async_method.required_modifiers = async
|
||||
|
||||
dotnet_naming_symbols.local_variable.applicable_kinds = parameter, local
|
||||
dotnet_naming_symbols.local_variable.applicable_accessibilities = local
|
||||
dotnet_naming_symbols.local_variable.required_modifiers =
|
||||
|
||||
# Naming styles
|
||||
|
||||
|
||||
dotnet_naming_style.all_upper.capitalization = all_upper
|
||||
|
||||
dotnet_naming_style.pascal_case.required_prefix =
|
||||
dotnet_naming_style.pascal_case.required_suffix =
|
||||
dotnet_naming_style.pascal_case.word_separator =
|
||||
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.begins_with_i.required_prefix = I
|
||||
dotnet_naming_style.begins_with_i.required_suffix =
|
||||
dotnet_naming_style.begins_with_i.word_separator =
|
||||
dotnet_naming_style.begins_with_i.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.begins_with_underscore.required_prefix = _
|
||||
dotnet_naming_style.begins_with_underscore.required_suffix =
|
||||
dotnet_naming_style.begins_with_underscore.word_separator =
|
||||
dotnet_naming_style.begins_with_underscore.capitalization = camel_case
|
||||
|
||||
dotnet_naming_style.ends_with_async.required_prefix =
|
||||
# dotnet_naming_style.ends_with_async.required_suffix = Async
|
||||
dotnet_naming_style.ends_with_async.word_separator =
|
||||
dotnet_naming_style.ends_with_async.capitalization = pascal_case
|
||||
|
||||
dotnet_naming_style.camel_case.required_prefix =
|
||||
dotnet_naming_style.camel_case.required_suffix =
|
||||
dotnet_naming_style.camel_case.word_separator =
|
||||
dotnet_naming_style.camel_case.capitalization = camel_case
|
||||
|
||||
# CA1822: Mark members as static
|
||||
dotnet_diagnostic.ca1822.severity = suggestion
|
||||
|
||||
# IDE0004: Cast is redundant
|
||||
dotnet_diagnostic.ide0004.severity = warning
|
||||
|
||||
# IDE0058: Expression value is never used
|
||||
dotnet_diagnostic.ide0058.severity = none
|
||||
|
||||
# # IDE0011: Add braces to 'if'/'else' statement
|
||||
# dotnet_diagnostic.ide0011.severity = none
|
||||
|
||||
resharper_wrap_after_invocation_lpar = false
|
||||
resharper_wrap_before_invocation_rpar = false
|
||||
|
||||
# ReSharper properties
|
||||
resharper_align_multiline_calls_chain = true
|
||||
resharper_csharp_wrap_after_declaration_lpar = true
|
||||
resharper_csharp_wrap_after_invocation_lpar = false
|
||||
resharper_csharp_wrap_before_binary_opsign = true
|
||||
resharper_csharp_wrap_before_invocation_rpar = false
|
||||
resharper_csharp_wrap_parameters_style = chop_if_long
|
||||
resharper_force_chop_compound_if_expression = false
|
||||
resharper_keep_existing_linebreaks = true
|
||||
resharper_keep_user_linebreaks = true
|
||||
resharper_max_formal_parameters_on_line = 3
|
||||
resharper_place_simple_embedded_statement_on_same_line = false
|
||||
resharper_wrap_chained_binary_expressions = chop_if_long
|
||||
resharper_wrap_chained_binary_patterns = chop_if_long
|
||||
resharper_wrap_chained_method_calls = chop_if_long
|
||||
resharper_wrap_object_and_collection_initializer_style = chop_always
|
||||
|
||||
resharper_csharp_wrap_before_first_type_parameter_constraint = true
|
||||
resharper_csharp_place_type_constraints_on_same_line = false
|
||||
resharper_csharp_wrap_before_extends_colon = true
|
||||
resharper_csharp_place_constructor_initializer_on_same_line = false
|
||||
resharper_force_attribute_style = separate
|
||||
resharper_csharp_braces_for_ifelse = required_for_multiline_statement
|
||||
resharper_csharp_braces_for_foreach = required_for_multiline
|
||||
resharper_csharp_braces_for_while = required_for_multiline
|
||||
resharper_csharp_braces_for_for = required_for_multiline
|
||||
resharper_arrange_redundant_parentheses_highlighting = hint
|
||||
|
||||
# IDE0011: Add braces
|
||||
dotnet_diagnostic.IDE0011.severity = warning
|
||||
|
||||
resharper_arrange_type_member_modifiers_highlighting = hint
|
|
@ -1,9 +1,12 @@
|
|||
#nullable disable
|
||||
using DryIoc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using EllieBot.Common.Configs;
|
||||
using EllieBot.Common.ModuleBehaviors;
|
||||
using EllieBot.Db.Models;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using RunMode = Discord.Commands.RunMode;
|
||||
|
@ -12,11 +15,15 @@ namespace EllieBot;
|
|||
|
||||
public sealed class Bot : IBot
|
||||
{
|
||||
public event Func<GuildConfig, Task> JoinedGuild = delegate { return Task.CompletedTask; };
|
||||
|
||||
public DiscordSocketClient Client { get; }
|
||||
public IReadOnlyCollection<GuildConfig> AllGuildConfigs { get; private set; }
|
||||
|
||||
private IContainer Services { get; set; }
|
||||
|
||||
public int ShardId { get; }
|
||||
public bool IsReady { get; private set; }
|
||||
public int ShardId { get; set; }
|
||||
|
||||
private readonly IBotCreds _creds;
|
||||
private readonly CommandService _commandService;
|
||||
|
@ -27,13 +34,12 @@ public sealed class Bot : IBot
|
|||
private readonly Assembly[] _loadedAssemblies;
|
||||
// private readonly InteractionService _interactionService;
|
||||
|
||||
public Bot(int shardId, int? totalShards)
|
||||
public Bot(int shardId, int? totalShards, string credPath = null)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfLessThan(shardId, 0);
|
||||
|
||||
LogSetup.SetupLogger(shardId, null);
|
||||
ShardId = shardId;
|
||||
_credsProvider = new BotCredsProvider(totalShards);
|
||||
_credsProvider = new BotCredsProvider(totalShards, credPath);
|
||||
_creds = _credsProvider.GetCreds();
|
||||
|
||||
LogSetup.SetupLogger(shardId, _creds);
|
||||
|
@ -96,7 +102,8 @@ public sealed class Bot : IBot
|
|||
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.EnsureUserCreated(bot.Id, bot.Username, bot.AvatarId);
|
||||
AllGuildConfigs = await uow.GuildConfigs.GetAllGuildConfigs(startingGuildIdList);
|
||||
uow.EnsureUserCreated(bot.Id, bot.Username, bot.Discriminator, bot.AvatarId);
|
||||
}
|
||||
|
||||
// var svcs = new StandardKernel(new NinjectSettings()
|
||||
|
@ -107,6 +114,10 @@ public sealed class Bot : IBot
|
|||
|
||||
var svcs = new Container();
|
||||
|
||||
// this is required in order for marmalade unloading to work
|
||||
// svcs.Components.Remove<IPlanner, Planner>();
|
||||
// svcs.Components.Add<IPlanner, RemovablePlanner>();
|
||||
|
||||
svcs.AddSingleton<IBotCreds>(_ => _credsProvider.GetCreds());
|
||||
svcs.AddSingleton<DbService, DbService>(_db);
|
||||
svcs.AddSingleton<IBotCredsProvider>(_credsProvider);
|
||||
|
@ -119,6 +130,7 @@ public sealed class Bot : IBot
|
|||
svcs.AddSingleton<IConfigSeria, YamlSeria>();
|
||||
svcs.AddSingleton<IMemoryCache, MemoryCache>(new MemoryCache(new MemoryCacheOptions()));
|
||||
svcs.AddSingleton<IBehaviorHandler, BehaviorHandler>();
|
||||
svcs.AddSingleton<ILocalization, Localization>();
|
||||
|
||||
|
||||
foreach (var a in _loadedAssemblies)
|
||||
|
@ -233,6 +245,16 @@ public sealed class Bot : IBot
|
|||
private Task Client_JoinedGuild(SocketGuild arg)
|
||||
{
|
||||
Log.Information("Joined server: {GuildName} [{GuildId}]", arg.Name, arg.Id);
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
GuildConfig gc;
|
||||
await using (var uow = _db.GetDbContext())
|
||||
{
|
||||
gc = uow.GuildConfigsForId(arg.Id, null);
|
||||
}
|
||||
|
||||
await JoinedGuild.Invoke(gc);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
@ -261,20 +283,19 @@ public sealed class Bot : IBot
|
|||
Stopwatch.GetElapsedTime(startTime).TotalSeconds);
|
||||
var commandHandler = Services.GetRequiredService<CommandHandler>();
|
||||
|
||||
|
||||
// start handling messages received in commandhandler
|
||||
await commandHandler.StartHandling();
|
||||
|
||||
foreach (var a in _loadedAssemblies)
|
||||
{
|
||||
await _commandService.AddModulesAsync(a, Services);
|
||||
}
|
||||
|
||||
// await _interactionService.AddModulesAsync(typeof(Bot).Assembly, Services);
|
||||
IsReady = true;
|
||||
|
||||
await EnsureBotOwnershipAsync();
|
||||
|
||||
await commandHandler.InitializeAsync();
|
||||
|
||||
_ = Task.Run(ExecuteReadySubscriptions);
|
||||
|
||||
await commandHandler.StartHandling();
|
||||
|
||||
Log.Information("Shard {ShardId} ready", Client.ShardId);
|
||||
}
|
||||
|
||||
|
@ -287,7 +308,7 @@ public sealed class Bot : IBot
|
|||
|
||||
Log.Information("Initializing Owner Id...");
|
||||
var info = await Client.GetApplicationInfoAsync();
|
||||
_credsProvider.ModifyCredsFile(x => x.OwnerIds = [info.Owner.Id]);
|
||||
_credsProvider.ModifyCredsFile(x => x.OwnerIds = new[] { info.Owner.Id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -310,8 +331,6 @@ public sealed class Bot : IBot
|
|||
"Failed running OnReadyAsync method on {Type} type: {Message}",
|
||||
toExec.GetType().Name,
|
||||
ex.Message);
|
||||
|
||||
Environment.Exit(9);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -349,10 +368,12 @@ public sealed class Bot : IBot
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#if GLOBAL_ELLIE || DEBUG
|
||||
if (arg.Exception is not null)
|
||||
Log.Warning(arg.Exception, "{ErrorSource} | {ErrorMessage}", arg.Source, arg.Message);
|
||||
else
|
||||
Log.Warning("{ErrorSource} | {ErrorMessage}", arg.Source, arg.Message);
|
||||
#endif
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using EllieBot.Db.Models;
|
||||
using EllieBot.Modules.Administration.Services;
|
||||
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
|
||||
|
@ -11,11 +11,6 @@ namespace EllieBot.Db;
|
|||
public abstract class EllieContext : DbContext
|
||||
{
|
||||
public DbSet<GuildConfig> GuildConfigs { get; set; }
|
||||
public DbSet<Permissionv2> Permissions { get; set; }
|
||||
|
||||
//new
|
||||
public DbSet<XpSettings> XpSettings { get; set; }
|
||||
|
||||
public DbSet<GreetSettings> GreetSettings { get; set; }
|
||||
|
||||
public DbSet<Quote> Quotes { get; set; }
|
||||
|
@ -51,6 +46,7 @@ public abstract class EllieContext : DbContext
|
|||
public DbSet<AutoTranslateChannel> AutoTranslateChannels { get; set; }
|
||||
public DbSet<AutoTranslateUser> AutoTranslateUsers { get; set; }
|
||||
|
||||
public DbSet<Permissionv2> Permissions { get; set; }
|
||||
|
||||
public DbSet<BankUser> BankUsers { get; set; }
|
||||
|
||||
|
@ -113,8 +109,8 @@ public abstract class EllieContext : DbContext
|
|||
#region GuildColors
|
||||
|
||||
modelBuilder.Entity<GuildColors>()
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique(true);
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique(true);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -123,7 +119,7 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<ButtonRole>(br =>
|
||||
{
|
||||
br.HasIndex(x => x.GuildId)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
|
||||
br.HasAlternateKey(x => new
|
||||
{
|
||||
|
@ -145,27 +141,27 @@ public abstract class EllieContext : DbContext
|
|||
});
|
||||
|
||||
sg.HasMany(x => x.Roles)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Sar>()
|
||||
.HasAlternateKey(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.RoleId
|
||||
});
|
||||
.HasAlternateKey(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.RoleId
|
||||
});
|
||||
|
||||
modelBuilder.Entity<SarAutoDelete>()
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rakeback
|
||||
|
||||
modelBuilder.Entity<Rakeback>()
|
||||
.HasKey(x => x.UserId);
|
||||
.HasKey(x => x.UserId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -174,14 +170,14 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<UserBetStats>(ubs =>
|
||||
{
|
||||
ubs.HasIndex(x => new
|
||||
{
|
||||
x.UserId,
|
||||
x.Game
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.UserId,
|
||||
x.Game
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
ubs.HasIndex(x => x.MaxWin)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -189,22 +185,22 @@ public abstract class EllieContext : DbContext
|
|||
#region Flag Translate
|
||||
|
||||
modelBuilder.Entity<FlagTranslateChannel>()
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.ChannelId
|
||||
})
|
||||
.IsUnique();
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.ChannelId
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
#region NCanvas
|
||||
|
||||
modelBuilder.Entity<NCPixel>()
|
||||
.HasAlternateKey(x => x.Position);
|
||||
.HasAlternateKey(x => x.Position);
|
||||
|
||||
modelBuilder.Entity<NCPixel>()
|
||||
.HasIndex(x => x.OwnerId);
|
||||
.HasIndex(x => x.OwnerId);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -221,13 +217,178 @@ public abstract class EllieContext : DbContext
|
|||
var configEntity = modelBuilder.Entity<GuildConfig>();
|
||||
|
||||
configEntity.HasIndex(c => c.GuildId)
|
||||
.IsUnique();
|
||||
.IsUnique();
|
||||
|
||||
configEntity.Property(x => x.VerboseErrors)
|
||||
.HasDefaultValue(true);
|
||||
.HasDefaultValue(true);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.DelMsgOnCmdChannels)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.GuildConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.FollowedStreams)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.GenerateCurrencyChannelIds)
|
||||
.WithOne(x => x.GuildConfig)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.Permissions)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.CommandCooldowns)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.FilterInvitesChannelIds)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.FilterLinksChannelIds)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.FilteredWords)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.FilterWordsChannelIds)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.MutedUsers)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasOne(x => x.AntiRaidSetting)
|
||||
.WithOne()
|
||||
.HasForeignKey<AntiRaidSetting>(x => x.GuildConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// start antispam
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasOne(x => x.AntiSpamSetting)
|
||||
.WithOne()
|
||||
.HasForeignKey<AntiSpamSetting>(x => x.GuildConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<AntiSpamSetting>()
|
||||
.HasMany(x => x.IgnoredChannels)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// end antispam
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasOne(x => x.AntiAltSetting)
|
||||
.WithOne()
|
||||
.HasForeignKey<AntiAltSetting>(x => x.GuildConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.UnmuteTimers)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.UnbanTimer)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.UnroleTimer)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.VcRoleInfos)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.CommandAliases)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.SlowmodeIgnoredRoles)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.SlowmodeIgnoredUsers)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// start shop
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.ShopEntries)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<ShopEntry>()
|
||||
.HasMany(x => x.Items)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// end shop
|
||||
|
||||
// start streamrole
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasOne(x => x.StreamRole)
|
||||
.WithOne(x => x.GuildConfig)
|
||||
.HasForeignKey<StreamRoleSettings>(x => x.GuildConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<StreamRoleSettings>()
|
||||
.HasMany(x => x.Whitelist)
|
||||
.WithOne(x => x.StreamRoleSettings)
|
||||
.HasForeignKey(x => x.StreamRoleSettingsId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<StreamRoleSettings>()
|
||||
.HasMany(x => x.Blacklist)
|
||||
.WithOne(x => x.StreamRoleSettings)
|
||||
.HasForeignKey(x => x.StreamRoleSettingsId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// end streamrole
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasOne(x => x.XpSettings)
|
||||
.WithOne(x => x.GuildConfig)
|
||||
.HasForeignKey<XpSettings>(x => x.GuildConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GuildConfig>()
|
||||
.HasMany(x => x.FeedSubs)
|
||||
.WithOne(x => x.GuildConfig)
|
||||
.HasForeignKey(x => x.GuildConfigId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<FeedSub>()
|
||||
.HasAlternateKey(x => new
|
||||
{
|
||||
x.GuildConfigId,
|
||||
x.Url
|
||||
});
|
||||
|
||||
modelBuilder.Entity<PlantedCurrency>().HasIndex(x => x.MessageId).IsUnique();
|
||||
|
||||
modelBuilder.Entity<PlantedCurrency>().HasIndex(x => x.ChannelId);
|
||||
|
@ -236,7 +397,9 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
#endregion
|
||||
|
||||
modelBuilder.Entity<WarningPunishment>(b =>
|
||||
#region WarningPunishments
|
||||
|
||||
var warnpunishmentEntity = modelBuilder.Entity<WarningPunishment>(b =>
|
||||
{
|
||||
b.HasAlternateKey(x => new
|
||||
{
|
||||
|
@ -245,6 +408,8 @@ public abstract class EllieContext : DbContext
|
|||
});
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
#region MusicPlaylists
|
||||
|
||||
var musicPlaylistEntity = modelBuilder.Entity<MusicPlaylist>();
|
||||
|
@ -271,19 +436,22 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<DiscordUser>(du =>
|
||||
{
|
||||
du.Property(x => x.IsClubAdmin)
|
||||
.HasDefaultValue(false);
|
||||
.HasDefaultValue(false);
|
||||
|
||||
du.Property(x => x.NotifyOnLevelUp)
|
||||
.HasDefaultValue(XpNotificationLocation.None);
|
||||
|
||||
du.Property(x => x.TotalXp)
|
||||
.HasDefaultValue(0);
|
||||
.HasDefaultValue(0);
|
||||
|
||||
du.Property(x => x.CurrencyAmount)
|
||||
.HasDefaultValue(0);
|
||||
.HasDefaultValue(0);
|
||||
|
||||
du.HasAlternateKey(w => w.UserId);
|
||||
du.HasOne(x => x.Club)
|
||||
.WithMany(x => x.Members)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
.WithMany(x => x.Members)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
du.HasIndex(x => x.TotalXp);
|
||||
du.HasIndex(x => x.CurrencyAmount);
|
||||
|
@ -309,11 +477,11 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
var xps = modelBuilder.Entity<UserXpStats>();
|
||||
xps.HasIndex(x => new
|
||||
{
|
||||
x.UserId,
|
||||
x.GuildId
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.UserId,
|
||||
x.GuildId
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
xps.HasIndex(x => x.UserId);
|
||||
xps.HasIndex(x => x.GuildId);
|
||||
|
@ -321,53 +489,80 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
#endregion
|
||||
|
||||
#region XpRoleReward
|
||||
|
||||
modelBuilder.Entity<XpRoleReward>()
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.XpSettingsId,
|
||||
x.Level
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
modelBuilder.Entity<XpSettings>()
|
||||
.HasMany(x => x.RoleRewards)
|
||||
.WithOne(x => x.XpSettings)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<XpSettings>()
|
||||
.HasMany(x => x.CurrencyRewards)
|
||||
.WithOne(x => x.XpSettings)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<XpSettings>()
|
||||
.HasMany(x => x.ExclusionList)
|
||||
.WithOne(x => x.XpSettings)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Club
|
||||
|
||||
var ci = modelBuilder.Entity<ClubInfo>();
|
||||
ci.HasOne(x => x.Owner)
|
||||
.WithOne()
|
||||
.HasForeignKey<ClubInfo>(x => x.OwnerId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
.WithOne()
|
||||
.HasForeignKey<ClubInfo>(x => x.OwnerId)
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
ci.HasIndex(x => new
|
||||
{
|
||||
x.Name
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.Name
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClubManytoMany
|
||||
|
||||
modelBuilder.Entity<ClubApplicants>()
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ClubApplicants>()
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
|
||||
modelBuilder.Entity<ClubApplicants>()
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Applicants);
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Applicants);
|
||||
|
||||
modelBuilder.Entity<ClubBans>()
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
.HasKey(t => new
|
||||
{
|
||||
t.ClubId,
|
||||
t.UserId
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ClubBans>()
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
.HasOne(pt => pt.User)
|
||||
.WithMany();
|
||||
|
||||
modelBuilder.Entity<ClubBans>()
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Bans);
|
||||
.HasOne(pt => pt.Club)
|
||||
.WithMany(x => x.Bans);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -376,16 +571,16 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<CurrencyTransaction>(e =>
|
||||
{
|
||||
e.HasIndex(x => x.UserId)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
|
||||
e.Property(x => x.OtherId)
|
||||
.HasDefaultValueSql(CurrencyTransactionOtherIdDefaultValue);
|
||||
.HasDefaultValueSql(CurrencyTransactionOtherIdDefaultValue);
|
||||
|
||||
e.Property(x => x.Type)
|
||||
.IsRequired();
|
||||
.IsRequired();
|
||||
|
||||
e.Property(x => x.Extra)
|
||||
.IsRequired();
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -400,21 +595,21 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
modelBuilder.Entity<BanTemplate>().HasIndex(x => x.GuildId).IsUnique();
|
||||
modelBuilder.Entity<BanTemplate>()
|
||||
.Property(x => x.PruneDays)
|
||||
.HasDefaultValue(null)
|
||||
.IsRequired(false);
|
||||
.Property(x => x.PruneDays)
|
||||
.HasDefaultValue(null)
|
||||
.IsRequired(false);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Perm Override
|
||||
|
||||
modelBuilder.Entity<DiscordPermOverride>()
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.Command
|
||||
})
|
||||
.IsUnique();
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.Command
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -431,14 +626,14 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<ReactionRoleV2>(rr2 =>
|
||||
{
|
||||
rr2.HasIndex(x => x.GuildId)
|
||||
.IsUnique(false);
|
||||
.IsUnique(false);
|
||||
|
||||
rr2.HasIndex(x => new
|
||||
{
|
||||
x.MessageId,
|
||||
x.Emote
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
x.MessageId,
|
||||
x.Emote
|
||||
})
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -448,18 +643,18 @@ public abstract class EllieContext : DbContext
|
|||
modelBuilder.Entity<LogSetting>(ls => ls.HasIndex(x => x.GuildId).IsUnique());
|
||||
|
||||
modelBuilder.Entity<LogSetting>(ls => ls
|
||||
.HasMany(x => x.LogIgnores)
|
||||
.WithOne(x => x.LogSetting)
|
||||
.OnDelete(DeleteBehavior.Cascade));
|
||||
.HasMany(x => x.LogIgnores)
|
||||
.WithOne(x => x.LogSetting)
|
||||
.OnDelete(DeleteBehavior.Cascade));
|
||||
|
||||
modelBuilder.Entity<IgnoredLogItem>(ili => ili
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.LogSettingId,
|
||||
x.LogItemId,
|
||||
x.ItemType
|
||||
})
|
||||
.IsUnique());
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.LogSettingId,
|
||||
x.LogItemId,
|
||||
x.ItemType
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -512,12 +707,12 @@ public abstract class EllieContext : DbContext
|
|||
{
|
||||
// user can own only one of each item
|
||||
x.HasIndex(model => new
|
||||
{
|
||||
model.UserId,
|
||||
model.ItemType,
|
||||
model.ItemKey
|
||||
})
|
||||
.IsUnique();
|
||||
{
|
||||
model.UserId,
|
||||
model.ItemType,
|
||||
model.ItemKey
|
||||
})
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
@ -525,27 +720,27 @@ public abstract class EllieContext : DbContext
|
|||
#region AutoPublish
|
||||
|
||||
modelBuilder.Entity<AutoPublishChannel>(apc => apc
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique());
|
||||
.HasIndex(x => x.GuildId)
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
#region GamblingStats
|
||||
|
||||
modelBuilder.Entity<GamblingStats>(gs => gs
|
||||
.HasIndex(x => x.Feature)
|
||||
.IsUnique());
|
||||
.HasIndex(x => x.Feature)
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Sticky Roles
|
||||
|
||||
modelBuilder.Entity<StickyRole>(sr => sr.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
{
|
||||
x.GuildId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -553,35 +748,35 @@ public abstract class EllieContext : DbContext
|
|||
#region Giveaway
|
||||
|
||||
modelBuilder.Entity<GiveawayModel>()
|
||||
.HasMany(x => x.Participants)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.GiveawayId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
.HasMany(x => x.Participants)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.GiveawayId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<GiveawayUser>(gu => gu
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GiveawayId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GiveawayId,
|
||||
x.UserId
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
#endregion
|
||||
|
||||
#region Todo
|
||||
|
||||
modelBuilder.Entity<TodoModel>()
|
||||
.HasKey(x => x.Id);
|
||||
.HasKey(x => x.Id);
|
||||
|
||||
modelBuilder.Entity<TodoModel>()
|
||||
.HasIndex(x => x.UserId)
|
||||
.IsUnique(false);
|
||||
.HasIndex(x => x.UserId)
|
||||
.IsUnique(false);
|
||||
|
||||
modelBuilder.Entity<ArchivedTodoListModel>()
|
||||
.HasMany(x => x.Items)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.ArchiveId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
.HasMany(x => x.Items)
|
||||
.WithOne()
|
||||
.HasForeignKey(x => x.ArchiveId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -589,11 +784,11 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
modelBuilder
|
||||
.Entity<GreetSettings>(gs => gs.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.GreetType
|
||||
})
|
||||
.IsUnique());
|
||||
{
|
||||
x.GuildId,
|
||||
x.GreetType
|
||||
})
|
||||
.IsUnique());
|
||||
|
||||
modelBuilder.Entity<GreetSettings>(gs =>
|
||||
{
|
||||
|
@ -611,15 +806,8 @@ public abstract class EllieContext : DbContext
|
|||
|
||||
#if DEBUG
|
||||
private static readonly ILoggerFactory _debugLoggerFactory = LoggerFactory.Create(x => x.AddConsole());
|
||||
#endif
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
#if DEBUG
|
||||
optionsBuilder.UseLoggerFactory(_debugLoggerFactory);
|
||||
=> optionsBuilder.UseLoggerFactory(_debugLoggerFactory);
|
||||
#endif
|
||||
|
||||
optionsBuilder.ConfigureWarnings(x => x.Log(RelationalEventId.PendingModelChangesWarning)
|
||||
.Ignore());
|
||||
}
|
||||
}
|
|
@ -1,21 +1,17 @@
|
|||
using LinqToDB.Common;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace EllieBot.Db;
|
||||
|
||||
public sealed class EllieDbService : DbService
|
||||
public sealed class EllieDbService : DbService
|
||||
{
|
||||
private readonly IBotCredsProvider _creds;
|
||||
|
||||
// these are props because creds can change at runtime
|
||||
private string DbType
|
||||
=> _creds.GetCreds().Db.Type.ToLowerInvariant().Trim();
|
||||
|
||||
private string ConnString
|
||||
=> _creds.GetCreds().Db.ConnectionString;
|
||||
|
||||
private string DbType => _creds.GetCreds().Db.Type.ToLowerInvariant().Trim();
|
||||
private string ConnString => _creds.GetCreds().Db.ConnectionString;
|
||||
|
||||
public EllieDbService(IBotCredsProvider creds)
|
||||
{
|
||||
LinqToDBForEFTools.Initialize();
|
||||
|
@ -26,15 +22,18 @@ public sealed class EllieDbService : DbService
|
|||
|
||||
public override async Task SetupAsync()
|
||||
{
|
||||
await using var context = CreateRawDbContext(DbType, ConnString);
|
||||
|
||||
await RunMigration(context);
|
||||
var dbType = DbType;
|
||||
var connString = ConnString;
|
||||
|
||||
await using var context = CreateRawDbContext(dbType, connString);
|
||||
|
||||
// make sure sqlite db is in wal journal mode
|
||||
if (context is SqliteContext)
|
||||
{
|
||||
await context.Database.ExecuteSqlRawAsync("PRAGMA journal_mode=WAL");
|
||||
}
|
||||
|
||||
await context.Database.MigrateAsync();
|
||||
}
|
||||
|
||||
public override EllieContext CreateRawDbContext(string dbType, string connString)
|
||||
|
@ -51,7 +50,7 @@ public sealed class EllieDbService : DbService
|
|||
throw new NotSupportedException($"The database provide type of '{dbType}' is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private EllieContext GetDbContextInternal()
|
||||
{
|
||||
var dbType = DbType;
|
||||
|
@ -72,57 +71,4 @@ public sealed class EllieDbService : DbService
|
|||
|
||||
public override EllieContext GetDbContext()
|
||||
=> GetDbContextInternal();
|
||||
|
||||
|
||||
private static async Task RunMigration(DbContext ctx)
|
||||
{
|
||||
// if database doesn't exist, run the baseline migration
|
||||
if (!await ctx.Database.CanConnectAsync())
|
||||
{
|
||||
Log.Information("Database does not exist. Creating a new database...");
|
||||
await ctx.Database.MigrateAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
// get the latest applied migration
|
||||
|
||||
var applied = await ctx.Database.GetAppliedMigrationsAsync();
|
||||
|
||||
// get all .sql file names from the migrations folder
|
||||
var available = Directory.GetFiles("Migrations/" + GetMigrationDirectory(ctx.Database), "*_*.sql")
|
||||
.Select(x => Path.GetFileNameWithoutExtension(x))
|
||||
.OrderBy(x => x);
|
||||
|
||||
var lastApplied = applied.Last();
|
||||
|
||||
// apply all migrations with names greater than the last applied
|
||||
foreach (var runnable in available)
|
||||
{
|
||||
if (string.Compare(lastApplied, runnable, StringComparison.Ordinal) < 0)
|
||||
{
|
||||
Log.Warning("Applying migration {MigrationName}", runnable);
|
||||
|
||||
var query = await File.ReadAllTextAsync(GetMigrationPath(ctx.Database, runnable));
|
||||
await ctx.Database.ExecuteSqlRawAsync(query);
|
||||
}
|
||||
}
|
||||
|
||||
// run all migrations that have not been applied yet
|
||||
}
|
||||
|
||||
private static string GetMigrationPath(DatabaseFacade ctxDatabase, string runnable)
|
||||
{
|
||||
return $"Migrations/{GetMigrationDirectory(ctxDatabase)}/{runnable}.sql";
|
||||
}
|
||||
|
||||
private static string GetMigrationDirectory(DatabaseFacade ctxDatabase)
|
||||
{
|
||||
if (ctxDatabase.IsSqlite())
|
||||
return "Sqlite";
|
||||
|
||||
if (ctxDatabase.IsNpgsql())
|
||||
return "PostgreSql";
|
||||
|
||||
throw new NotSupportedException("This database type is not supported.");
|
||||
}
|
||||
}
|
|
@ -7,23 +7,14 @@ namespace EllieBot.Db;
|
|||
|
||||
public static class CurrencyTransactionExtensions
|
||||
{
|
||||
public static async Task<IReadOnlyCollection<CurrencyTransaction>> GetPageFor(
|
||||
public static Task<List<CurrencyTransaction>> GetPageFor(
|
||||
this DbSet<CurrencyTransaction> set,
|
||||
ulong userId,
|
||||
int page)
|
||||
{
|
||||
var items = await set.ToLinqToDBTable()
|
||||
=> set.ToLinqToDBTable()
|
||||
.Where(x => x.UserId == userId)
|
||||
.OrderByDescending(x => x.DateAdded)
|
||||
.Skip(15 * page)
|
||||
.Take(15)
|
||||
.ToListAsyncLinqToDB();
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async Task<int> GetCountFor(this DbSet<CurrencyTransaction> set, ulong userId)
|
||||
=> await set.ToLinqToDBTable()
|
||||
.Where(x => x.UserId == userId)
|
||||
.CountAsyncLinqToDB();
|
||||
}
|
|
@ -9,48 +9,4 @@ public static class DbExtensions
|
|||
public static T GetById<T>(this DbSet<T> set, int id)
|
||||
where T : DbEntity
|
||||
=> set.FirstOrDefault(x => x.Id == id);
|
||||
|
||||
public static GuildFilterConfig FilterConfigForId(
|
||||
this DbContext ctx,
|
||||
ulong guildId,
|
||||
Func<IQueryable<GuildFilterConfig>, IQueryable<GuildFilterConfig>> includes = default)
|
||||
{
|
||||
includes ??= static set => set;
|
||||
|
||||
var gfc = includes(ctx.Set<GuildFilterConfig>()
|
||||
.Where(gc => gc.GuildId == guildId))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (gfc is null)
|
||||
{
|
||||
ctx.Add(gfc = new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
});
|
||||
}
|
||||
|
||||
return gfc;
|
||||
}
|
||||
|
||||
public static GuildConfig GuildConfigsForId(
|
||||
this DbContext ctx,
|
||||
ulong guildId,
|
||||
Func<IQueryable<GuildConfig>, IQueryable<GuildConfig>> includes = default)
|
||||
{
|
||||
includes ??= static set => set;
|
||||
|
||||
var gc = includes(ctx.Set<GuildConfig>()
|
||||
.Where(gc => gc.GuildId == guildId))
|
||||
.FirstOrDefault();
|
||||
|
||||
if (gc is null)
|
||||
{
|
||||
ctx.Add(gc = new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
});
|
||||
}
|
||||
|
||||
return gc;
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ public static class DiscordUserExtensions
|
|||
this DbContext ctx,
|
||||
ulong userId,
|
||||
string username,
|
||||
string discrim,
|
||||
string avatarId)
|
||||
=> ctx.GetTable<DiscordUser>()
|
||||
.InsertOrUpdate(
|
||||
|
@ -64,10 +65,11 @@ public static class DiscordUserExtensions
|
|||
this DbContext ctx,
|
||||
ulong userId,
|
||||
string username,
|
||||
string discrim,
|
||||
string avatarId,
|
||||
Func<IQueryable<DiscordUser>, IQueryable<DiscordUser>> includes = null)
|
||||
{
|
||||
ctx.EnsureUserCreated(userId, username, avatarId);
|
||||
ctx.EnsureUserCreated(userId, username, discrim, avatarId);
|
||||
|
||||
IQueryable<DiscordUser> queryable = ctx.Set<DiscordUser>();
|
||||
if (includes is not null)
|
||||
|
@ -76,6 +78,13 @@ public static class DiscordUserExtensions
|
|||
}
|
||||
|
||||
|
||||
public static int GetUserGlobalRank(this DbSet<DiscordUser> users, ulong id)
|
||||
=> users.AsQueryable()
|
||||
.Where(x => x.TotalXp
|
||||
> users.AsQueryable().Where(y => y.UserId == id).Select(y => y.TotalXp).FirstOrDefault())
|
||||
.Count()
|
||||
+ 1;
|
||||
|
||||
public static Task<List<DiscordUser>> GetTopRichest(
|
||||
this DbSet<DiscordUser> users,
|
||||
ulong botId,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#nullable disable
|
||||
using LinqToDB;
|
||||
using LinqToDB.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EllieBot.Db.Models;
|
||||
|
@ -29,48 +28,126 @@ public static class GuildConfigExtensions
|
|||
/// </summary>
|
||||
/// <param name="ctx">Db Context</param>
|
||||
/// <param name="guildId">Id of the guild to get stream role settings for.</param>
|
||||
/// <returns>Guild's stream role settings</returns>
|
||||
public static async Task<StreamRoleSettings> GetOrCreateStreamRoleSettings(this DbContext ctx, ulong guildId)
|
||||
/// <returns>Guild'p stream role settings</returns>
|
||||
public static StreamRoleSettings GetStreamRoleSettings(this DbContext ctx, ulong guildId)
|
||||
{
|
||||
var srs = await ctx.Set<StreamRoleSettings>()
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefaultAsyncEF();
|
||||
var conf = ctx.GuildConfigsForId(guildId,
|
||||
set => set.Include(y => y.StreamRole)
|
||||
.Include(y => y.StreamRole.Whitelist)
|
||||
.Include(y => y.StreamRole.Blacklist));
|
||||
|
||||
if (srs is not null)
|
||||
return srs;
|
||||
if (conf.StreamRole is null)
|
||||
conf.StreamRole = new();
|
||||
|
||||
srs = new()
|
||||
return conf.StreamRole;
|
||||
}
|
||||
|
||||
private static IQueryable<GuildConfig> IncludeEverything(this DbSet<GuildConfig> configs)
|
||||
=> configs
|
||||
.AsSplitQuery()
|
||||
.Include(gc => gc.CommandCooldowns)
|
||||
.Include(gc => gc.FollowedStreams)
|
||||
.Include(gc => gc.StreamRole)
|
||||
.Include(gc => gc.DelMsgOnCmdChannels)
|
||||
.Include(gc => gc.XpSettings)
|
||||
.ThenInclude(x => x.ExclusionList);
|
||||
|
||||
public static async Task<GuildConfig[]> GetAllGuildConfigs(
|
||||
this DbSet<GuildConfig> configs,
|
||||
List<ulong> availableGuilds)
|
||||
{
|
||||
var result = await configs
|
||||
.IncludeEverything()
|
||||
.Where(x => availableGuilds.Contains(x.GuildId))
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and creates if it doesn't exist a config for a guild.
|
||||
/// </summary>
|
||||
/// <param name="ctx">Context</param>
|
||||
/// <param name="guildId">Id of the guide</param>
|
||||
/// <param name="includes">Use to manipulate the set however you want. Pass null to include everything</param>
|
||||
/// <returns>Config for the guild</returns>
|
||||
public static GuildConfig GuildConfigsForId(
|
||||
this DbContext ctx,
|
||||
ulong guildId,
|
||||
Func<DbSet<GuildConfig>, IQueryable<GuildConfig>> includes)
|
||||
{
|
||||
GuildConfig config;
|
||||
|
||||
if (includes is null)
|
||||
config = ctx.Set<GuildConfig>().IncludeEverything().FirstOrDefault(c => c.GuildId == guildId);
|
||||
else
|
||||
{
|
||||
GuildId = guildId,
|
||||
};
|
||||
var set = includes(ctx.Set<GuildConfig>());
|
||||
config = set.FirstOrDefault(c => c.GuildId == guildId);
|
||||
}
|
||||
|
||||
ctx.Set<StreamRoleSettings>().Add(srs);
|
||||
if (config is null)
|
||||
{
|
||||
ctx.Set<GuildConfig>()
|
||||
.Add(config = new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Permissions = Permissionv2.GetDefaultPermlist,
|
||||
WarningsInitialized = true,
|
||||
});
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
return srs;
|
||||
if (!config.WarningsInitialized)
|
||||
{
|
||||
config.WarningsInitialized = true;
|
||||
}
|
||||
|
||||
return config;
|
||||
|
||||
// ctx.GuildConfigs
|
||||
// .ToLinqToDBTable()
|
||||
// .InsertOrUpdate(() => new()
|
||||
// {
|
||||
// GuildId = guildId,
|
||||
// Permissions = Permissionv2.GetDefaultPermlist,
|
||||
// WarningsInitialized = true,
|
||||
// WarnPunishments = DefaultWarnPunishments
|
||||
// },
|
||||
// _ => new(),
|
||||
// () => new()
|
||||
// {
|
||||
// GuildId = guildId
|
||||
// });
|
||||
//
|
||||
// if(includes is null)
|
||||
// return ctx.GuildConfigs
|
||||
// .ToLinqToDBTable()
|
||||
// .First(x => x.GuildId == guildId);
|
||||
}
|
||||
|
||||
public static LogSetting LogSettingsFor(this DbContext ctx, ulong guildId)
|
||||
{
|
||||
var logSetting = ctx.Set<LogSetting>()
|
||||
.AsQueryable()
|
||||
.Include(x => x.LogIgnores)
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefault();
|
||||
.AsQueryable()
|
||||
.Include(x => x.LogIgnores)
|
||||
.Where(x => x.GuildId == guildId)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (logSetting is null)
|
||||
{
|
||||
ctx.Set<LogSetting>()
|
||||
.Add(logSetting = new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
.Add(logSetting = new()
|
||||
{
|
||||
GuildId = guildId
|
||||
});
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
|
||||
return logSetting;
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<GuildConfig> PermissionsForAll(this DbSet<GuildConfig> configs, List<ulong> include)
|
||||
{
|
||||
var query = configs.AsQueryable().Where(x => include.Contains(x.GuildId)).Include(gc => gc.Permissions);
|
||||
|
@ -81,19 +158,19 @@ public static class GuildConfigExtensions
|
|||
public static GuildConfig GcWithPermissionsFor(this DbContext ctx, ulong guildId)
|
||||
{
|
||||
var config = ctx.Set<GuildConfig>()
|
||||
.AsQueryable()
|
||||
.Where(gc => gc.GuildId == guildId)
|
||||
.Include(gc => gc.Permissions)
|
||||
.FirstOrDefault();
|
||||
.AsQueryable()
|
||||
.Where(gc => gc.GuildId == guildId)
|
||||
.Include(gc => gc.Permissions)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (config is null) // if there is no guildconfig, create new one
|
||||
{
|
||||
ctx.Set<GuildConfig>()
|
||||
.Add(config = new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Permissions = Permissionv2.GetDefaultPermlist
|
||||
});
|
||||
.Add(config = new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
Permissions = Permissionv2.GetDefaultPermlist
|
||||
});
|
||||
ctx.SaveChanges();
|
||||
}
|
||||
else if (config.Permissions is null || !config.Permissions.Any()) // if no perms, add default ones
|
||||
|
@ -105,27 +182,45 @@ public static class GuildConfigExtensions
|
|||
return config;
|
||||
}
|
||||
|
||||
public static async Task<XpSettings> XpSettingsFor(this DbContext ctx, ulong guildId,
|
||||
Func<IQueryable<XpSettings>, IQueryable<XpSettings>> includes = default)
|
||||
public static IEnumerable<FollowedStream> GetFollowedStreams(this DbSet<GuildConfig> configs)
|
||||
=> configs.AsQueryable().Include(x => x.FollowedStreams).SelectMany(gc => gc.FollowedStreams).ToArray();
|
||||
|
||||
public static IEnumerable<FollowedStream> GetFollowedStreams(this DbSet<GuildConfig> configs, List<ulong> included)
|
||||
=> configs.AsQueryable()
|
||||
.Where(gc => included.Contains(gc.GuildId))
|
||||
.Include(gc => gc.FollowedStreams)
|
||||
.SelectMany(gc => gc.FollowedStreams)
|
||||
.ToList();
|
||||
|
||||
|
||||
public static XpSettings XpSettingsFor(this DbContext ctx, ulong guildId)
|
||||
{
|
||||
includes ??= static set => set;
|
||||
var gc = ctx.GuildConfigsForId(guildId,
|
||||
set => set.Include(x => x.XpSettings)
|
||||
.ThenInclude(x => x.RoleRewards)
|
||||
.Include(x => x.XpSettings)
|
||||
.ThenInclude(x => x.CurrencyRewards)
|
||||
.Include(x => x.XpSettings)
|
||||
.ThenInclude(x => x.ExclusionList));
|
||||
|
||||
var srs = await includes(ctx.GetTable<XpSettings>()
|
||||
.Where(x => x.GuildId == guildId))
|
||||
.FirstOrDefaultAsyncLinqToDB();
|
||||
if (gc.XpSettings is null)
|
||||
gc.XpSettings = new();
|
||||
|
||||
if (srs is not null)
|
||||
return srs;
|
||||
|
||||
srs = await ctx.GetTable<XpSettings>()
|
||||
.InsertWithOutputAsync(() => new()
|
||||
{
|
||||
GuildId = guildId,
|
||||
});
|
||||
|
||||
return srs;
|
||||
return gc.XpSettings;
|
||||
}
|
||||
|
||||
public static IEnumerable<GeneratingChannel> GetGeneratingChannels(this DbSet<GuildConfig> configs)
|
||||
=> configs.AsQueryable()
|
||||
.Include(x => x.GenerateCurrencyChannelIds)
|
||||
.Where(x => x.GenerateCurrencyChannelIds.Any())
|
||||
.SelectMany(x => x.GenerateCurrencyChannelIds)
|
||||
.Select(x => new GeneratingChannel
|
||||
{
|
||||
ChannelId = x.ChannelId,
|
||||
GuildId = x.GuildConfig.GuildId
|
||||
})
|
||||
.ToArray();
|
||||
|
||||
public class GeneratingChannel
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
|
|
|
@ -9,7 +9,7 @@ public static class UserXpExtensions
|
|||
{
|
||||
public static async Task<UserXpStats?> GetGuildUserXp(this ITable<UserXpStats> table, ulong guildId, ulong userId)
|
||||
=> await table.FirstOrDefaultAsyncLinqToDB(x => x.GuildId == guildId && x.UserId == userId);
|
||||
|
||||
|
||||
public static UserXpStats GetOrCreateUserXpStats(this DbContext ctx, ulong guildId, ulong userId)
|
||||
{
|
||||
var usr = ctx.Set<UserXpStats>().FirstOrDefault(x => x.UserId == userId && x.GuildId == guildId);
|
||||
|
|
|
@ -1,21 +1,8 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class CommandAlias : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public string Trigger { get; set; }
|
||||
public string Mapping { get; set; }
|
||||
}
|
||||
|
||||
public class CommandAliasEntityConfiguration : IEntityTypeConfiguration<CommandAlias>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<CommandAlias> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId);
|
||||
}
|
||||
}
|
|
@ -1,25 +1,8 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class CommandCooldown : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
{
|
||||
public int Seconds { get; set; }
|
||||
public string CommandName { get; set; }
|
||||
}
|
||||
|
||||
public class CommandCooldownEntityConfiguration : IEntityTypeConfiguration<CommandCooldown>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<CommandCooldown> builder)
|
||||
{
|
||||
builder.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.CommandName
|
||||
})
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
|
@ -1,25 +1,16 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable disable
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class DelMsgOnCmdChannel : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public int GuildConfigId { get; set; }
|
||||
|
||||
public ulong ChannelId { get; set; }
|
||||
public bool State { get; set; }
|
||||
}
|
||||
|
||||
public class DelMsgOnCmdChannelEntityConfiguration : IEntityTypeConfiguration<DelMsgOnCmdChannel>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<DelMsgOnCmdChannel> builder)
|
||||
{
|
||||
builder.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.ChannelId
|
||||
}).IsUnique();
|
||||
}
|
||||
}
|
||||
public override int GetHashCode()
|
||||
=> ChannelId.GetHashCode();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
=> obj is DelMsgOnCmdChannel x && x.ChannelId == ChannelId;
|
||||
}
|
|
@ -1,27 +1,31 @@
|
|||
#nullable disable
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
// FUTURE remove LastLevelUp from here and UserXpStats
|
||||
public class DiscordUser : DbEntity
|
||||
{
|
||||
public const string DEFAULT_USERNAME = "??Unknown";
|
||||
|
||||
public ulong UserId { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public string? AvatarId { get; set; }
|
||||
public string Username { get; set; }
|
||||
// public string Discriminator { get; set; }
|
||||
public string AvatarId { get; set; }
|
||||
|
||||
public int? ClubId { get; set; }
|
||||
public ClubInfo? Club { get; set; }
|
||||
public ClubInfo Club { get; set; }
|
||||
public bool IsClubAdmin { get; set; }
|
||||
|
||||
public long TotalXp { get; set; }
|
||||
public XpNotificationLocation NotifyOnLevelUp { get; set; }
|
||||
|
||||
public long CurrencyAmount { get; set; }
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
public override bool Equals(object obj)
|
||||
=> obj is DiscordUser du ? du.UserId == UserId : false;
|
||||
|
||||
public override int GetHashCode()
|
||||
=> UserId.GetHashCode();
|
||||
|
||||
public override string ToString()
|
||||
=> Username ?? DEFAULT_USERNAME;
|
||||
{
|
||||
return Username;
|
||||
}
|
||||
}
|
|
@ -1,29 +1,19 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class FeedSub : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public int GuildConfigId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
public ulong ChannelId { get; set; }
|
||||
public string Url { get; set; }
|
||||
|
||||
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public sealed class FeedSubEntityConfiguration : IEntityTypeConfiguration<FeedSub>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<FeedSub> builder)
|
||||
{
|
||||
builder
|
||||
.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.Url
|
||||
})
|
||||
.IsUnique();
|
||||
}
|
||||
public override int GetHashCode()
|
||||
=> Url.GetHashCode(StringComparison.InvariantCulture) ^ GuildConfigId.GetHashCode();
|
||||
|
||||
public override bool Equals(object obj)
|
||||
=> obj is FeedSub s && s.Url.ToLower() == Url.ToLower() && s.GuildConfigId == GuildConfigId;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#nullable disable
|
||||
#nullable disable
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class FlagTranslateChannel : DbEntity
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class FollowedStream
|
||||
public class FollowedStream : DbEntity
|
||||
{
|
||||
public enum FType
|
||||
{
|
||||
|
@ -15,13 +12,12 @@ public class FollowedStream
|
|||
Trovo = 6,
|
||||
Kick = 7,
|
||||
}
|
||||
public int Id { get; set; }
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string PrettyName { get; set; } = null;
|
||||
public FType Type { get; set; }
|
||||
public string Message { get; set; } = null;
|
||||
public string Message { get; set; }
|
||||
|
||||
protected bool Equals(FollowedStream other)
|
||||
=> ChannelId == other.ChannelId
|
||||
|
@ -33,17 +29,6 @@ public class FollowedStream
|
|||
|
||||
public override bool Equals(object obj)
|
||||
=> obj is FollowedStream fs && Equals(fs);
|
||||
}
|
||||
|
||||
public sealed class FollowedStreamEntityConfig : IEntityTypeConfiguration<FollowedStream>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<FollowedStream> builder)
|
||||
{
|
||||
builder.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.Username,
|
||||
x.Type,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +1,14 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
#nullable disable
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class GCChannelId : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
}
|
||||
|
||||
public class GCChannelIdEntityConfiguration : IEntityTypeConfiguration<GCChannelId>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<GCChannelId> builder)
|
||||
{
|
||||
builder.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.ChannelId
|
||||
})
|
||||
.IsUnique();
|
||||
}
|
||||
public override bool Equals(object obj)
|
||||
=> obj is GCChannelId gc && gc.ChannelId == ChannelId;
|
||||
|
||||
public override int GetHashCode()
|
||||
=> ChannelId.GetHashCode();
|
||||
}
|
|
@ -1,67 +1,91 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
#nullable disable
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class GuildFilterConfig
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
public bool FilterInvites { get; set; }
|
||||
public bool FilterLinks { get; set; }
|
||||
public bool FilterWords { get; set; }
|
||||
public HashSet<FilterChannelId> FilterInvitesChannelIds { get; set; } = new();
|
||||
public HashSet<FilterLinksChannelId> FilterLinksChannelIds { get; set; } = new();
|
||||
public HashSet<FilteredWord> FilteredWords { get; set; } = new();
|
||||
public HashSet<FilterWordsChannelId> FilterWordsChannelIds { get; set; } = new();
|
||||
}
|
||||
|
||||
public sealed class GuildFilterConfigEntityConfiguration : IEntityTypeConfiguration<GuildFilterConfig>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<GuildFilterConfig> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId);
|
||||
}
|
||||
}
|
||||
|
||||
public class GuildConfig : DbEntity
|
||||
{
|
||||
// public bool Keep { get; set; }
|
||||
public ulong GuildId { get; set; }
|
||||
public string? Prefix { get; set; } = null;
|
||||
|
||||
public bool DeleteMessageOnCommand { get; set; } = false;
|
||||
public string Prefix { get; set; }
|
||||
|
||||
public string? AutoAssignRoleIds { get; set; } = null;
|
||||
public bool DeleteMessageOnCommand { get; set; }
|
||||
public HashSet<DelMsgOnCmdChannel> DelMsgOnCmdChannels { get; set; } = new();
|
||||
|
||||
public string AutoAssignRoleIds { get; set; }
|
||||
|
||||
//todo FUTURE: DELETE, UNUSED
|
||||
public bool ExclusiveSelfAssignedRoles { get; set; }
|
||||
public bool AutoDeleteSelfAssignedRoleMessages { get; set; }
|
||||
|
||||
|
||||
//stream notifications
|
||||
public HashSet<FollowedStream> FollowedStreams { get; set; } = new();
|
||||
|
||||
//currencyGeneration
|
||||
public HashSet<GCChannelId> GenerateCurrencyChannelIds { get; set; } = new();
|
||||
|
||||
public List<Permissionv2> Permissions { get; set; }
|
||||
public bool VerbosePermissions { get; set; } = true;
|
||||
public string? PermissionRole { get; set; } = null;
|
||||
public string PermissionRole { get; set; }
|
||||
|
||||
public HashSet<CommandCooldown> CommandCooldowns { get; set; } = new();
|
||||
|
||||
//filtering
|
||||
public string? MuteRoleName { get; set; } = null;
|
||||
public bool FilterInvites { get; set; }
|
||||
public bool FilterLinks { get; set; }
|
||||
public HashSet<FilterChannelId> FilterInvitesChannelIds { get; set; } = new();
|
||||
public HashSet<FilterLinksChannelId> FilterLinksChannelIds { get; set; } = new();
|
||||
|
||||
public bool FilterWords { get; set; }
|
||||
public HashSet<FilteredWord> FilteredWords { get; set; } = new();
|
||||
public HashSet<FilterWordsChannelId> FilterWordsChannelIds { get; set; } = new();
|
||||
|
||||
// mute
|
||||
public HashSet<MutedUserId> MutedUsers { get; set; } = new();
|
||||
|
||||
public string MuteRoleName { get; set; }
|
||||
|
||||
// chatterbot
|
||||
public bool CleverbotEnabled { get; set; } = false;
|
||||
public bool CleverbotEnabled { get; set; }
|
||||
|
||||
// protection
|
||||
public AntiRaidSetting AntiRaidSetting { get; set; }
|
||||
public AntiSpamSetting AntiSpamSetting { get; set; }
|
||||
public AntiAltSetting AntiAltSetting { get; set; }
|
||||
|
||||
// time
|
||||
public string Locale { get; set; }
|
||||
public string TimeZoneId { get; set; }
|
||||
|
||||
|
||||
// timers
|
||||
public HashSet<UnmuteTimer> UnmuteTimers { get; set; } = new();
|
||||
public HashSet<UnbanTimer> UnbanTimer { get; set; } = new();
|
||||
public HashSet<UnroleTimer> UnroleTimer { get; set; } = new();
|
||||
|
||||
// vcrole
|
||||
public HashSet<VcRoleInfo> VcRoleInfos { get; set; }
|
||||
|
||||
// aliases
|
||||
public bool WarningsInitialized { get; set; } = false;
|
||||
public HashSet<CommandAlias> CommandAliases { get; set; } = new();
|
||||
public bool WarningsInitialized { get; set; }
|
||||
public HashSet<SlowmodeIgnoredUser> SlowmodeIgnoredUsers { get; set; }
|
||||
public HashSet<SlowmodeIgnoredRole> SlowmodeIgnoredRoles { get; set; }
|
||||
|
||||
public ulong? GameVoiceChannel { get; set; } = null;
|
||||
public List<ShopEntry> ShopEntries { get; set; }
|
||||
public ulong? GameVoiceChannel { get; set; }
|
||||
public bool VerboseErrors { get; set; } = true;
|
||||
|
||||
public StreamRoleSettings StreamRole { get; set; }
|
||||
|
||||
public bool NotifyStreamOffline { get; set; } = true;
|
||||
public bool DeleteStreamOnlineMessage { get; set; } = false;
|
||||
public int WarnExpireHours { get; set; } = 0;
|
||||
public XpSettings XpSettings { get; set; }
|
||||
public List<FeedSub> FeedSubs { get; set; } = new();
|
||||
public bool NotifyStreamOffline { get; set; }
|
||||
public bool DeleteStreamOnlineMessage { get; set; }
|
||||
public int WarnExpireHours { get; set; }
|
||||
public WarnExpireAction WarnExpireAction { get; set; } = WarnExpireAction.Clear;
|
||||
|
||||
public bool DisableGlobalExpressions { get; set; } = false;
|
||||
|
||||
public bool StickyRoles { get; set; } = false;
|
||||
|
||||
public string? TimeZoneId { get; set; } = null;
|
||||
public string? Locale { get; set; } = null;
|
||||
|
||||
public List<Permissionv2> Permissions { get; set; } = [];
|
||||
public bool StickyRoles { get; set; }
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
|
@ -6,14 +6,14 @@ public class NCPixel
|
|||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
public required int Position { get; init; }
|
||||
|
||||
|
||||
public required long Price { get; init; }
|
||||
|
||||
|
||||
public required ulong OwnerId { get; init; }
|
||||
public required uint Color { get; init; }
|
||||
|
||||
|
||||
[MaxLength(256)]
|
||||
public required string Text { get; init; }
|
||||
}
|
|
@ -8,7 +8,7 @@ public class Notify
|
|||
public int Id { get; set; }
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong? ChannelId { get; set; }
|
||||
public ulong ChannelId { get; set; }
|
||||
public NotifyType Type { get; set; }
|
||||
|
||||
[MaxLength(10_000)]
|
||||
|
@ -21,6 +21,4 @@ public enum NotifyType
|
|||
Protection = 1, Prot = 1,
|
||||
AddRoleReward = 2,
|
||||
RemoveRoleReward = 3,
|
||||
NiceCatch = 4,
|
||||
// BigWin = 4,
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
@ -9,8 +7,7 @@ namespace EllieBot.Db.Models;
|
|||
[DebuggerDisplay("{PrimaryTarget}{SecondaryTarget} {SecondaryTargetName} {State} {PrimaryTargetId}")]
|
||||
public class Permissionv2 : DbEntity, IIndexed
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public int? GuildConfigId { get; set; }
|
||||
public int Index { get; set; }
|
||||
|
||||
public PrimaryPermissionType PrimaryTarget { get; set; }
|
||||
|
@ -52,12 +49,4 @@ public enum SecondaryPermissionType
|
|||
Module,
|
||||
Command,
|
||||
AllModules
|
||||
}
|
||||
|
||||
public sealed class Permissionv2EntityConfiguration : IEntityTypeConfiguration<Permissionv2>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Permissionv2> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ public sealed class SarGroup
|
|||
public ulong? RoleReq { get; set; }
|
||||
public ICollection<Sar> Roles { get; set; } = [];
|
||||
public bool IsExclusive { get; set; }
|
||||
|
||||
|
||||
[MaxLength(100)]
|
||||
public string? Name { get; set; }
|
||||
}
|
|
@ -1,21 +1,16 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public enum ShopEntryType
|
||||
{
|
||||
Role,
|
||||
|
||||
List,
|
||||
Command
|
||||
}
|
||||
|
||||
public class ShopEntry : DbEntity, IIndexed
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public int Index { get; set; }
|
||||
public int Price { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
@ -30,7 +25,7 @@ public class ShopEntry : DbEntity, IIndexed
|
|||
//list
|
||||
public HashSet<ShopEntryItem> Items { get; set; } = new();
|
||||
public ulong? RoleRequirement { get; set; }
|
||||
|
||||
|
||||
// command
|
||||
public string Command { get; set; }
|
||||
}
|
||||
|
@ -48,22 +43,4 @@ public class ShopEntryItem : DbEntity
|
|||
|
||||
public override int GetHashCode()
|
||||
=> Text.GetHashCode(StringComparison.InvariantCulture);
|
||||
}
|
||||
|
||||
public class ShopEntryEntityConfiguration : IEntityTypeConfiguration<ShopEntry>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ShopEntry> builder)
|
||||
{
|
||||
builder.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.Index
|
||||
})
|
||||
.IsUnique();
|
||||
|
||||
builder
|
||||
.HasMany(x => x.Items)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
|
@ -1,16 +1,10 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class StreamRoleSettings : DbEntity
|
||||
{
|
||||
public int GuildConfigId { get; set; }
|
||||
|
||||
public ulong GuildId { get; set; }
|
||||
public GuildConfig GuildConfig { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the feature is enabled in the guild.
|
||||
|
@ -48,7 +42,7 @@ public class StreamRoleBlacklistedUser : DbEntity
|
|||
{
|
||||
public int StreamRoleSettingsId { get; set; }
|
||||
public StreamRoleSettings StreamRoleSettings { get; set; }
|
||||
|
||||
|
||||
public ulong UserId { get; set; }
|
||||
public string Username { get; set; }
|
||||
|
||||
|
@ -68,7 +62,7 @@ public class StreamRoleWhitelistedUser : DbEntity
|
|||
{
|
||||
public int StreamRoleSettingsId { get; set; }
|
||||
public StreamRoleSettings StreamRoleSettings { get; set; }
|
||||
|
||||
|
||||
public ulong UserId { get; set; }
|
||||
public string Username { get; set; }
|
||||
|
||||
|
@ -77,25 +71,4 @@ public class StreamRoleWhitelistedUser : DbEntity
|
|||
|
||||
public override int GetHashCode()
|
||||
=> UserId.GetHashCode();
|
||||
}
|
||||
|
||||
public class StreamRoleSettingsEntityConfiguration : IEntityTypeConfiguration<StreamRoleSettings>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<StreamRoleSettings> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
|
||||
builder
|
||||
.HasMany(x => x.Whitelist)
|
||||
.WithOne(x => x.StreamRoleSettings)
|
||||
.HasForeignKey(x => x.StreamRoleSettingsId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder
|
||||
.HasMany(x => x.Blacklist)
|
||||
.WithOne(x => x.StreamRoleSettings)
|
||||
.HasForeignKey(x => x.StreamRoleSettingsId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
|
@ -1,26 +1,8 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
#nullable disable
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class VcRoleInfo : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public ulong VoiceChannelId { get; set; }
|
||||
|
||||
public ulong RoleId { get; set; }
|
||||
}
|
||||
|
||||
public class VcRoleInfoEntityConfiguration : IEntityTypeConfiguration<VcRoleInfo>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<VcRoleInfo> builder)
|
||||
{
|
||||
builder.HasIndex(x => new
|
||||
{
|
||||
x.GuildId,
|
||||
x.VoiceChannelId
|
||||
})
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
|
@ -1,28 +1,12 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using LinqToDB.Mapping;
|
||||
using DataType = LinqToDB.DataType;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class AntiAltSetting
|
||||
{
|
||||
[Key]
|
||||
public int GuildConfigId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public ulong GuildId { get; set; }
|
||||
public TimeSpan MinAge { get; set; }
|
||||
public PunishmentAction Action { get; set; }
|
||||
public int ActionDurationMinutes { get; set; }
|
||||
public ulong? RoleId { get; set; }
|
||||
}
|
||||
|
||||
public class AntiAltSettingEntityConfiguration : IEntityTypeConfiguration<AntiAltSetting>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AntiAltSetting> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
#nullable disable
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
|
||||
public class AntiRaidSetting : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
public int GuildConfigId { get; set; }
|
||||
|
||||
public int UserThreshold { get; set; }
|
||||
public int Seconds { get; set; }
|
||||
public PunishmentAction Action { get; set; }
|
||||
|
@ -17,13 +15,4 @@ public class AntiRaidSetting : DbEntity
|
|||
/// Mute, Chatmute, Voicemute, etc...
|
||||
/// </summary>
|
||||
public int PunishDuration { get; set; }
|
||||
}
|
||||
|
||||
public class AntiRaidSettingEntityConfiguration : IEntityTypeConfiguration<AntiRaidSetting>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AntiRaidSetting> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
}
|
||||
}
|
|
@ -3,4 +3,10 @@
|
|||
public class AntiSpamIgnore : DbEntity
|
||||
{
|
||||
public ulong ChannelId { get; set; }
|
||||
|
||||
public override int GetHashCode()
|
||||
=> ChannelId.GetHashCode();
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
=> obj is AntiSpamIgnore inst && inst.ChannelId == ChannelId;
|
||||
}
|
|
@ -1,32 +1,13 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
#nullable disable
|
||||
public class AntiSpamSetting : DbEntity
|
||||
{
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
public int GuildConfigId { get; set; }
|
||||
|
||||
public PunishmentAction Action { get; set; }
|
||||
public int MessageThreshold { get; set; } = 3;
|
||||
public int MuteTime { get; set; }
|
||||
public ulong? RoleId { get; set; }
|
||||
public List<AntiSpamIgnore> IgnoredChannels { get; set; } = new();
|
||||
}
|
||||
|
||||
// setup model
|
||||
public class AntiSpamEntityConfiguration : IEntityTypeConfiguration<AntiSpamSetting>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AntiSpamSetting> builder)
|
||||
{
|
||||
builder.HasIndex(x => x.GuildId)
|
||||
.IsUnique();
|
||||
|
||||
builder.HasMany(x => x.IgnoredChannels)
|
||||
.WithOne()
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
public HashSet<AntiSpamIgnore> IgnoredChannels { get; set; } = new();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
|
@ -24,4 +24,4 @@ public sealed class ButtonRole
|
|||
public string Label { get; set; } = string.Empty;
|
||||
|
||||
public bool Exclusive { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ public class ClubInfo : DbEntity
|
|||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ImageUrl { get; set; } = string.Empty;
|
||||
public string BannerUrl { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public int Xp { get; set; } = 0;
|
||||
public int? OwnerId { get; set; }
|
||||
public DiscordUser Owner { get; set; }
|
||||
|
|
|
@ -1,23 +1,16 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable disable
|
||||
namespace EllieBot.Db.Models;
|
||||
|
||||
public class FilterChannelId
|
||||
public class FilterChannelId : DbEntity
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int? GuildFilterConfigId { get; set; }
|
||||
|
||||
public ulong ChannelId { get; set; }
|
||||
|
||||
protected bool Equals(FilterChannelId other)
|
||||
public bool Equals(FilterChannelId other)
|
||||
=> ChannelId == other.ChannelId;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
=> obj is FilterChannelId fci && fci.Equals(this);
|
||||
public override bool Equals(object obj)
|
||||
=> obj is FilterChannelId fci && Equals(fci);
|
||||
|
||||
public override int GetHashCode()
|
||||
=> ChannelId.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue