Compare commits
3 commits
master
...
remove-unu
Author | SHA1 | Date | |
---|---|---|---|
84e7696939 | |||
a44f9302d7 | |||
f2f07245c2 |
72 changed files with 1794 additions and 1505 deletions
9
.github/dependabot.yml
vendored
9
.github/dependabot.yml
vendored
|
@ -15,10 +15,6 @@ updates:
|
||||||
labels:
|
labels:
|
||||||
- "type: change"
|
- "type: change"
|
||||||
- "area: build/ci"
|
- "area: build/ci"
|
||||||
# For all packages, ignore all patch updates
|
|
||||||
ignore:
|
|
||||||
- dependency-name: "*"
|
|
||||||
update-types: [ "version-update:semver-patch" ]
|
|
||||||
|
|
||||||
- package-ecosystem: "nuget" # See documentation for possible values
|
- package-ecosystem: "nuget" # See documentation for possible values
|
||||||
directory: "/" # Location of package manifests
|
directory: "/" # Location of package manifests
|
||||||
|
@ -34,8 +30,3 @@ updates:
|
||||||
remora:
|
remora:
|
||||||
patterns:
|
patterns:
|
||||||
- "Remora.Discord.*"
|
- "Remora.Discord.*"
|
||||||
# For all packages, ignore all patch updates
|
|
||||||
ignore:
|
|
||||||
- dependency-name: "GitInfo"
|
|
||||||
- dependency-name: "*"
|
|
||||||
update-types: [ "version-update:semver-patch" ]
|
|
||||||
|
|
7
.github/workflows/build-pr.yml
vendored
7
.github/workflows/build-pr.yml
vendored
|
@ -22,13 +22,8 @@ jobs:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup .NET
|
|
||||||
uses: actions/setup-dotnet@v4
|
|
||||||
with:
|
|
||||||
dotnet-version: '9.0.x'
|
|
||||||
|
|
||||||
- name: ReSharper CLI InspectCode
|
- name: ReSharper CLI InspectCode
|
||||||
uses: muno92/resharper_inspectcode@1.13.0
|
uses: muno92/resharper_inspectcode@1.11.7
|
||||||
with:
|
with:
|
||||||
solutionPath: ./Octobot.sln
|
solutionPath: ./Octobot.sln
|
||||||
ignoreIssueType: InvertIf, ConvertIfStatementToSwitchStatement, ConvertToPrimaryConstructor
|
ignoreIssueType: InvertIf, ConvertIfStatementToSwitchStatement, ConvertToPrimaryConstructor
|
||||||
|
|
67
.github/workflows/build-push.yml
vendored
67
.github/workflows/build-push.yml
vendored
|
@ -5,83 +5,60 @@ concurrency:
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "master", "deploy-test" ]
|
branches: [ "master" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
upload-image:
|
upload-solution:
|
||||||
name: Upload Octobot Docker image
|
name: Upload Octobot to production
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
actions: read
|
||||||
|
contents: read
|
||||||
environment: production
|
environment: production
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Login to GitHub Container Registry
|
- name: Checkout repository
|
||||||
uses: docker/login-action@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Publish solution
|
||||||
uses: docker/build-push-action@v6
|
run: dotnet publish $PUBLISH_FLAGS
|
||||||
with:
|
env:
|
||||||
push: true
|
PUBLISH_FLAGS: ${{vars.PUBLISH_FLAGS}}
|
||||||
tags: ghcr.io/${{vars.NAMESPACE}}/${{vars.IMAGE_NAME}}:latest
|
|
||||||
build-args: |
|
|
||||||
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
|
|
||||||
PUBLISH_OPTIONS=${{vars.PUBLISH_OPTIONS}}
|
|
||||||
|
|
||||||
update-production:
|
- name: Setup SSH key
|
||||||
name: Update Octobot on production
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
environment: production
|
|
||||||
needs: upload-image
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Copy SSH key
|
|
||||||
run: |
|
run: |
|
||||||
install -m 600 -D /dev/null ~/.ssh/id_ed25519
|
install -m 600 -D /dev/null ~/.ssh/id_rsa
|
||||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
|
ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
|
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
|
||||||
|
|
||||||
- name: Generate SSH known hosts file
|
|
||||||
run: |
|
|
||||||
ssh-keyscan -H -p $SSH_PORT $SSH_HOST > ~/.ssh/known_hosts
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
SSH_HOST: ${{secrets.SSH_HOST}}
|
SSH_HOST: ${{secrets.SSH_HOST}}
|
||||||
SSH_PORT: ${{secrets.SSH_PORT}}
|
|
||||||
|
|
||||||
- name: Stop currently running instance
|
- name: Stop currently running instance
|
||||||
run: |
|
run: |
|
||||||
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $STOP_COMMAND
|
ssh $SSH_USER@$SSH_HOST $STOP_COMMAND
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
SSH_PORT: ${{secrets.SSH_PORT}}
|
|
||||||
SSH_USER: ${{secrets.SSH_USER}}
|
SSH_USER: ${{secrets.SSH_USER}}
|
||||||
SSH_HOST: ${{secrets.SSH_HOST}}
|
SSH_HOST: ${{secrets.SSH_HOST}}
|
||||||
STOP_COMMAND: ${{vars.STOP_COMMAND}}
|
STOP_COMMAND: ${{vars.STOP_COMMAND}}
|
||||||
|
|
||||||
- name: Update Docker image
|
- name: Upload published solution
|
||||||
run: |
|
run: |
|
||||||
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST docker pull ghcr.io/$NAMESPACE/$IMAGE_NAME:latest
|
scp -r $UPLOAD_FROM $SSH_USER@$SSH_HOST:$UPLOAD_TO
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
SSH_PORT: ${{secrets.SSH_PORT}}
|
|
||||||
SSH_USER: ${{secrets.SSH_USER}}
|
SSH_USER: ${{secrets.SSH_USER}}
|
||||||
SSH_HOST: ${{secrets.SSH_HOST}}
|
SSH_HOST: ${{secrets.SSH_HOST}}
|
||||||
NAMESPACE: ${{vars.NAMESPACE}}
|
UPLOAD_FROM: ${{vars.UPLOAD_FROM}}
|
||||||
IMAGE_NAME: ${{vars.IMAGE_NAME}}
|
UPLOAD_TO: ${{vars.UPLOAD_TO}}
|
||||||
|
|
||||||
- name: Start new instance
|
- name: Start new instance
|
||||||
run: |
|
run: |
|
||||||
ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $START_COMMAND
|
ssh $SSH_USER@$SSH_HOST $START_COMMAND
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
SSH_PORT: ${{secrets.SSH_PORT}}
|
|
||||||
SSH_USER: ${{secrets.SSH_USER}}
|
SSH_USER: ${{secrets.SSH_USER}}
|
||||||
SSH_HOST: ${{secrets.SSH_HOST}}
|
SSH_HOST: ${{secrets.SSH_HOST}}
|
||||||
START_COMMAND: ${{vars.START_COMMAND}}
|
START_COMMAND: ${{vars.START_COMMAND}}
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,4 +8,3 @@ riderModule.iml
|
||||||
/.vs/
|
/.vs/
|
||||||
GuildData/
|
GuildData/
|
||||||
Logs/
|
Logs/
|
||||||
compose.yaml
|
|
||||||
|
|
15
Dockerfile
15
Dockerfile
|
@ -1,15 +0,0 @@
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:9.0@sha256:7d24e90a392e88eb56093e4eb325ff883ad609382a55d42f17fd557b997022ca AS build-env
|
|
||||||
WORKDIR /Octobot
|
|
||||||
|
|
||||||
# Copy everything
|
|
||||||
COPY . ./
|
|
||||||
# Load build argument with publish options
|
|
||||||
ARG PUBLISH_OPTIONS="-c Release"
|
|
||||||
# Build and publish a release
|
|
||||||
RUN dotnet publish ./TeamOctolings.Octobot $PUBLISH_OPTIONS -o out
|
|
||||||
|
|
||||||
# Build runtime image
|
|
||||||
FROM mcr.microsoft.com/dotnet/runtime:9.0@sha256:1e5eb0ed94ca96a34a914456db80e48bd1bb7bc3e3c8eda5e2c3d89c153c3081
|
|
||||||
WORKDIR /Octobot
|
|
||||||
COPY --from=build-env /Octobot/out .
|
|
||||||
ENTRYPOINT ["./TeamOctolings.Octobot"]
|
|
|
@ -1,8 +1,8 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>2.0.0</Version>
|
<Version>2.0.0</Version>
|
||||||
|
@ -16,31 +16,31 @@
|
||||||
<Company>TeamOctolings</Company>
|
<Company>TeamOctolings</Company>
|
||||||
<NeutralLanguage>en</NeutralLanguage>
|
<NeutralLanguage>en</NeutralLanguage>
|
||||||
<Description>A general-purpose Discord bot for moderation written in C#</Description>
|
<Description>A general-purpose Discord bot for moderation written in C#</Description>
|
||||||
<ApplicationIcon>../docs/octobot.ico</ApplicationIcon>
|
<ApplicationIcon>docs/octobot.ico</ApplicationIcon>
|
||||||
<GitVersion>false</GitVersion>
|
<GitVersion>false</GitVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DiffPlex" Version="1.7.2" />
|
<PackageReference Include="DiffPlex" Version="1.7.2" />
|
||||||
<PackageReference Include="GitInfo" Version="3.3.5" />
|
<PackageReference Include="GitInfo" Version="3.3.4" />
|
||||||
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1" />
|
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1" />
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0"/>
|
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0"/>
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Remora.Commands" Version="11.0.1"/>
|
<PackageReference Include="Remora.Commands" Version="10.0.5" />
|
||||||
<PackageReference Include="Remora.Discord.Caching" Version="40.0.0" />
|
<PackageReference Include="Remora.Discord.Caching" Version="38.0.1" />
|
||||||
<PackageReference Include="Remora.Discord.Extensions" Version="6.0.0"/>
|
<PackageReference Include="Remora.Discord.Extensions" Version="5.3.4" />
|
||||||
<PackageReference Include="Remora.Discord.Hosting" Version="7.0.0" />
|
<PackageReference Include="Remora.Discord.Hosting" Version="6.0.9" />
|
||||||
<PackageReference Include="Remora.Discord.Interactivity" Version="6.0.0"/>
|
<PackageReference Include="Remora.Discord.Interactivity" Version="4.5.3" />
|
||||||
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
|
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Update="Messages.resx">
|
<EmbeddedResource Update="locale\Messages.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="..\CodeAnalysis\BannedSymbols.txt" />
|
<AdditionalFiles Include="CodeAnalysis\BannedSymbols.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
10
Octobot.sln
10
Octobot.sln
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamOctolings.Octobot", "TeamOctolings.Octobot\TeamOctolings.Octobot.csproj", "{A1679BA2-3A36-4D98-80C0-EEE771398FBD}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Octobot", "Octobot.csproj", "{9CA7A44F-167C-46D4-923D-88CE71044144}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@ -8,9 +8,9 @@ Global
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{A1679BA2-3A36-4D98-80C0-EEE771398FBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{9CA7A44F-167C-46D4-923D-88CE71044144}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{A1679BA2-3A36-4D98-80C0-EEE771398FBD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9CA7A44F-167C-46D4-923D-88CE71044144}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A1679BA2-3A36-4D98-80C0-EEE771398FBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9CA7A44F-167C-46D4-923D-88CE71044144}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A1679BA2-3A36-4D98-80C0-EEE771398FBD}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9CA7A44F-167C-46D4-923D-88CE71044144}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
@ -1,272 +0,0 @@
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Text;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Remora.Commands.Attributes;
|
|
||||||
using Remora.Commands.Groups;
|
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
|
||||||
using Remora.Discord.Commands.Attributes;
|
|
||||||
using Remora.Discord.Commands.Contexts;
|
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
|
||||||
using Remora.Discord.Extensions.Embeds;
|
|
||||||
using Remora.Discord.Extensions.Formatting;
|
|
||||||
using Remora.Results;
|
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Parsers;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles tool commands: /random, /timestamp, /8ball.
|
|
||||||
/// </summary>
|
|
||||||
[UsedImplicitly]
|
|
||||||
public sealed class ToolsCommandGroup : CommandGroup
|
|
||||||
{
|
|
||||||
private static readonly TimestampStyle[] AllStyles =
|
|
||||||
[
|
|
||||||
TimestampStyle.ShortDate,
|
|
||||||
TimestampStyle.LongDate,
|
|
||||||
TimestampStyle.ShortTime,
|
|
||||||
TimestampStyle.LongTime,
|
|
||||||
TimestampStyle.ShortDateTime,
|
|
||||||
TimestampStyle.LongDateTime,
|
|
||||||
TimestampStyle.RelativeTime
|
|
||||||
];
|
|
||||||
|
|
||||||
private static readonly string[] AnswerTypes =
|
|
||||||
[
|
|
||||||
"Positive", "Questionable", "Neutral", "Negative"
|
|
||||||
];
|
|
||||||
|
|
||||||
private readonly ICommandContext _context;
|
|
||||||
private readonly IFeedbackService _feedback;
|
|
||||||
private readonly GuildDataService _guildData;
|
|
||||||
private readonly IDiscordRestUserAPI _userApi;
|
|
||||||
|
|
||||||
public ToolsCommandGroup(
|
|
||||||
ICommandContext context, IFeedbackService feedback,
|
|
||||||
GuildDataService guildData, IDiscordRestUserAPI userApi)
|
|
||||||
{
|
|
||||||
_context = context;
|
|
||||||
_guildData = guildData;
|
|
||||||
_feedback = feedback;
|
|
||||||
_userApi = userApi;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A slash command that generates a random number using maximum and minimum numbers.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="first">The first number used for randomization.</param>
|
|
||||||
/// <param name="second">The second number used for randomization. Default value: 0</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A feedback sending result which may or may not have succeeded.
|
|
||||||
/// </returns>
|
|
||||||
[Command("random")]
|
|
||||||
[DiscordDefaultDMPermission(false)]
|
|
||||||
[Description("Generates a random number")]
|
|
||||||
[UsedImplicitly]
|
|
||||||
public async Task<Result> ExecuteRandomAsync(
|
|
||||||
[Description("First number")] long first,
|
|
||||||
[Description("Second number (Default: 0)")]
|
|
||||||
long? second = null)
|
|
||||||
{
|
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out _, out var executorId))
|
|
||||||
{
|
|
||||||
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
|
||||||
}
|
|
||||||
|
|
||||||
var executorResult = await _userApi.GetUserAsync(executorId, CancellationToken);
|
|
||||||
if (!executorResult.IsDefined(out var executor))
|
|
||||||
{
|
|
||||||
return ResultExtensions.FromError(executorResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = await _guildData.GetData(guildId, CancellationToken);
|
|
||||||
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
|
||||||
|
|
||||||
return await SendRandomNumberAsync(first, second, executor, CancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task<Result> SendRandomNumberAsync(long first, long? secondNullable,
|
|
||||||
IUser executor, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
const long secondDefault = 0;
|
|
||||||
var second = secondNullable ?? secondDefault;
|
|
||||||
|
|
||||||
var min = Math.Min(first, second);
|
|
||||||
var max = Math.Max(first, second);
|
|
||||||
|
|
||||||
var i = Random.Shared.NextInt64(min, max + 1);
|
|
||||||
|
|
||||||
var description = new StringBuilder().Append("# ").Append(i);
|
|
||||||
|
|
||||||
description.AppendLine().AppendBulletPoint(string.Format(
|
|
||||||
Messages.RandomMin, Markdown.InlineCode(min.ToString())));
|
|
||||||
if (secondNullable is null && first >= secondDefault)
|
|
||||||
{
|
|
||||||
description.Append(' ').Append(Messages.Default);
|
|
||||||
}
|
|
||||||
|
|
||||||
description.AppendLine().AppendBulletPoint(string.Format(
|
|
||||||
Messages.RandomMax, Markdown.InlineCode(max.ToString())));
|
|
||||||
if (secondNullable is null && first < secondDefault)
|
|
||||||
{
|
|
||||||
description.Append(' ').Append(Messages.Default);
|
|
||||||
}
|
|
||||||
|
|
||||||
var embedColor = ColorsList.Blue;
|
|
||||||
if (secondNullable is not null && min == max)
|
|
||||||
{
|
|
||||||
description.AppendLine().Append(Markdown.Italicise(Messages.RandomMinMaxSame));
|
|
||||||
embedColor = ColorsList.Red;
|
|
||||||
}
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
|
||||||
string.Format(Messages.RandomTitle, executor.GetTag()), executor)
|
|
||||||
.WithDescription(description.ToString())
|
|
||||||
.WithColour(embedColor)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A slash command that shows the current timestamp with an optional offset in all styles supported by Discord.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="stringOffset">The offset for the current timestamp.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A feedback sending result which may or may not have succeeded.
|
|
||||||
/// </returns>
|
|
||||||
[Command("timestamp")]
|
|
||||||
[DiscordDefaultDMPermission(false)]
|
|
||||||
[Description("Shows a timestamp in all styles")]
|
|
||||||
[UsedImplicitly]
|
|
||||||
public async Task<Result> ExecuteTimestampAsync(
|
|
||||||
[Description("Offset from current time")] [Option("offset")]
|
|
||||||
string? stringOffset = null)
|
|
||||||
{
|
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out _, out var executorId))
|
|
||||||
{
|
|
||||||
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
|
||||||
}
|
|
||||||
|
|
||||||
var botResult = await _userApi.GetCurrentUserAsync(CancellationToken);
|
|
||||||
if (!botResult.IsDefined(out var bot))
|
|
||||||
{
|
|
||||||
return ResultExtensions.FromError(botResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
var executorResult = await _userApi.GetUserAsync(executorId, CancellationToken);
|
|
||||||
if (!executorResult.IsDefined(out var executor))
|
|
||||||
{
|
|
||||||
return ResultExtensions.FromError(executorResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = await _guildData.GetData(guildId, CancellationToken);
|
|
||||||
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
|
||||||
|
|
||||||
if (stringOffset is null)
|
|
||||||
{
|
|
||||||
return await SendTimestampAsync(null, executor, CancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
var parseResult = TimeSpanParser.TryParse(stringOffset);
|
|
||||||
if (!parseResult.IsDefined(out var offset))
|
|
||||||
{
|
|
||||||
var failedEmbed = new EmbedBuilder()
|
|
||||||
.WithSmallTitle(Messages.InvalidTimeSpan, bot)
|
|
||||||
.WithDescription(Messages.TimeSpanExample)
|
|
||||||
.WithColour(ColorsList.Red)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await SendTimestampAsync(offset, executor, CancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task<Result> SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds();
|
|
||||||
|
|
||||||
var description = new StringBuilder().Append("# ").AppendLine(timestamp.ToString());
|
|
||||||
|
|
||||||
if (offset is not null)
|
|
||||||
{
|
|
||||||
description.AppendLine(string.Format(
|
|
||||||
Messages.TimestampOffset, Markdown.InlineCode(offset.ToString() ?? string.Empty))).AppendLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var markdownTimestamp in AllStyles.Select(style => Markdown.Timestamp(timestamp, style)))
|
|
||||||
{
|
|
||||||
description.AppendBulletPoint(Markdown.InlineCode(markdownTimestamp))
|
|
||||||
.Append(" → ").AppendLine(markdownTimestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
|
||||||
string.Format(Messages.TimestampTitle, executor.GetTag()), executor)
|
|
||||||
.WithDescription(description.ToString())
|
|
||||||
.WithColour(ColorsList.Blue)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A slash command that shows a random answer from the Magic 8-Ball.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="question">Unused input.</param>
|
|
||||||
/// <remarks>
|
|
||||||
/// The 8-Ball answers were taken from <a href="https://en.wikipedia.org/wiki/Magic_8_Ball#Possible_answers">Wikipedia</a>.
|
|
||||||
/// </remarks>
|
|
||||||
/// <returns>
|
|
||||||
/// A feedback sending result which may or may not have succeeded.
|
|
||||||
/// </returns>
|
|
||||||
[Command("8ball")]
|
|
||||||
[DiscordDefaultDMPermission(false)]
|
|
||||||
[Description("Ask the Magic 8-Ball a question")]
|
|
||||||
[UsedImplicitly]
|
|
||||||
public async Task<Result> ExecuteEightBallAsync(
|
|
||||||
// let the user think he's actually asking the ball a question
|
|
||||||
[Description("Question to ask")] string question)
|
|
||||||
{
|
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out _, out _))
|
|
||||||
{
|
|
||||||
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
|
||||||
}
|
|
||||||
|
|
||||||
var botResult = await _userApi.GetCurrentUserAsync(CancellationToken);
|
|
||||||
if (!botResult.IsDefined(out var bot))
|
|
||||||
{
|
|
||||||
return ResultExtensions.FromError(botResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = await _guildData.GetData(guildId, CancellationToken);
|
|
||||||
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
|
||||||
|
|
||||||
return await AnswerEightBallAsync(bot, CancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task<Result> AnswerEightBallAsync(IUser bot, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var typeNumber = Random.Shared.Next(0, 4);
|
|
||||||
var embedColor = typeNumber switch
|
|
||||||
{
|
|
||||||
0 => ColorsList.Blue,
|
|
||||||
1 => ColorsList.Green,
|
|
||||||
2 => ColorsList.Yellow,
|
|
||||||
3 => ColorsList.Red,
|
|
||||||
_ => throw new ArgumentOutOfRangeException(null, nameof(typeNumber))
|
|
||||||
};
|
|
||||||
|
|
||||||
var answer = $"EightBall{AnswerTypes[typeNumber]}{Random.Shared.Next(1, 6)}".Localized();
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(answer, bot)
|
|
||||||
.WithColour(embedColor)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
namespace TeamOctolings.Octobot.Data;
|
|
||||||
|
|
||||||
public sealed record Reminder
|
|
||||||
{
|
|
||||||
public required DateTimeOffset At { get; init; }
|
|
||||||
public required string Text { get; init; }
|
|
||||||
public required ulong ChannelId { get; init; }
|
|
||||||
public required ulong MessageId { get; init; }
|
|
||||||
}
|
|
|
@ -1,297 +0,0 @@
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Nodes;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Remora.Rest.Core;
|
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles saving, loading, initializing and providing <see cref="GuildData" />.
|
|
||||||
/// </summary>
|
|
||||||
public sealed class GuildDataService : BackgroundService
|
|
||||||
{
|
|
||||||
private readonly ConcurrentDictionary<Snowflake, GuildData> _datas = new();
|
|
||||||
private readonly ILogger<GuildDataService> _logger;
|
|
||||||
|
|
||||||
public GuildDataService(ILogger<GuildDataService> logger)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Task StopAsync(CancellationToken ct)
|
|
||||||
{
|
|
||||||
base.StopAsync(ct);
|
|
||||||
return SaveAsync(ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task SaveAsync(CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var tasks = new List<Task>();
|
|
||||||
var datas = _datas.Values.ToArray();
|
|
||||||
foreach (var data in datas.Where(data => !data.DataLoadFailed))
|
|
||||||
{
|
|
||||||
tasks.Add(SerializeObjectSafelyAsync(data.Settings, data.SettingsPath, ct));
|
|
||||||
tasks.Add(SerializeObjectSafelyAsync(data.ScheduledEvents, data.ScheduledEventsPath, ct));
|
|
||||||
|
|
||||||
var memberDatas = data.MemberData.Values.ToArray();
|
|
||||||
tasks.AddRange(memberDatas.Select(memberData =>
|
|
||||||
SerializeObjectSafelyAsync(memberData, $"{data.MemberDataPath}/{memberData.Id}.json", ct)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.WhenAll(tasks);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task SerializeObjectSafelyAsync<T>(T obj, string path, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var tempFilePath = path + ".tmp";
|
|
||||||
await using (var tempFileStream = File.Create(tempFilePath))
|
|
||||||
{
|
|
||||||
await JsonSerializer.SerializeAsync(tempFileStream, obj, cancellationToken: ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
File.Copy(tempFilePath, path, true);
|
|
||||||
File.Delete(tempFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task ExecuteAsync(CancellationToken ct)
|
|
||||||
{
|
|
||||||
using var timer = new PeriodicTimer(TimeSpan.FromMinutes(5));
|
|
||||||
|
|
||||||
while (await timer.WaitForNextTickAsync(ct))
|
|
||||||
{
|
|
||||||
await SaveAsync(ct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<GuildData> GetData(Snowflake guildId, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
return _datas.TryGetValue(guildId, out var data) ? data : await InitializeData(guildId, ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var path = $"GuildData/{guildId}";
|
|
||||||
var memberDataPath = $"{path}/MemberData";
|
|
||||||
|
|
||||||
var settingsPath = $"{path}/Settings.json";
|
|
||||||
|
|
||||||
var scheduledEventsPath = $"{path}/ScheduledEvents.json";
|
|
||||||
|
|
||||||
MigrateDataDirectory(guildId, path);
|
|
||||||
|
|
||||||
Directory.CreateDirectory(path);
|
|
||||||
|
|
||||||
var dataLoadFailed = false;
|
|
||||||
|
|
||||||
var jsonSettings = await LoadGuildSettings(settingsPath, ct);
|
|
||||||
if (jsonSettings is not null)
|
|
||||||
{
|
|
||||||
FixJsonSettings(jsonSettings);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dataLoadFailed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var events = await LoadScheduledEvents(scheduledEventsPath, ct);
|
|
||||||
if (events is null)
|
|
||||||
{
|
|
||||||
dataLoadFailed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var memberData = new Dictionary<ulong, MemberData>();
|
|
||||||
foreach (var dataFileInfo in Directory.CreateDirectory(memberDataPath).GetFiles()
|
|
||||||
.Where(dataFileInfo =>
|
|
||||||
!memberData.ContainsKey(
|
|
||||||
ulong.Parse(dataFileInfo.Name.Replace(".json", "").Replace(".tmp", "")))))
|
|
||||||
{
|
|
||||||
var data = await LoadMemberData(dataFileInfo, memberDataPath, true, ct);
|
|
||||||
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
dataLoadFailed = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
memberData.TryAdd(data.Id, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
var finalData = new GuildData(
|
|
||||||
jsonSettings ?? new JsonObject(), settingsPath,
|
|
||||||
events ?? new Dictionary<ulong, ScheduledEventData>(), scheduledEventsPath,
|
|
||||||
memberData, memberDataPath,
|
|
||||||
dataLoadFailed);
|
|
||||||
|
|
||||||
_datas.TryAdd(guildId, finalData);
|
|
||||||
|
|
||||||
return finalData;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<MemberData?> LoadMemberData(FileInfo dataFileInfo, string memberDataPath, bool loadTmp,
|
|
||||||
CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
MemberData? data;
|
|
||||||
var temporaryPath = $"{dataFileInfo.FullName}.tmp";
|
|
||||||
var usedInfo = loadTmp && File.Exists(temporaryPath) ? new FileInfo(temporaryPath) : dataFileInfo;
|
|
||||||
|
|
||||||
var isTmp = usedInfo.Extension is ".tmp";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await using var dataStream = usedInfo.OpenRead();
|
|
||||||
data = await JsonSerializer.DeserializeAsync<MemberData>(dataStream, cancellationToken: ct);
|
|
||||||
if (isTmp)
|
|
||||||
{
|
|
||||||
usedInfo.CopyTo(usedInfo.FullName.Replace(".tmp", ""), true);
|
|
||||||
usedInfo.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
if (isTmp)
|
|
||||||
{
|
|
||||||
_logger.LogWarning(e,
|
|
||||||
"Unable to load temporary member data file, deleting: {MemberDataPath}/{FileName}", memberDataPath,
|
|
||||||
usedInfo.Name);
|
|
||||||
usedInfo.Delete();
|
|
||||||
return await LoadMemberData(dataFileInfo, memberDataPath, false, ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogError(e, "Member data load failed: {MemberDataPath}/{FileName}", memberDataPath,
|
|
||||||
usedInfo.Name);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<Dictionary<ulong, ScheduledEventData>?> LoadScheduledEvents(string scheduledEventsPath,
|
|
||||||
CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var tempScheduledEventsPath = $"{scheduledEventsPath}.tmp";
|
|
||||||
|
|
||||||
if (!File.Exists(scheduledEventsPath) && !File.Exists(tempScheduledEventsPath))
|
|
||||||
{
|
|
||||||
return new Dictionary<ulong, ScheduledEventData>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (File.Exists(tempScheduledEventsPath))
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Found temporary scheduled events file, will try to parse and copy to main: ${Path}",
|
|
||||||
tempScheduledEventsPath);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await using var tempEventsStream = File.OpenRead(tempScheduledEventsPath);
|
|
||||||
var events = await JsonSerializer.DeserializeAsync<Dictionary<ulong, ScheduledEventData>>(
|
|
||||||
tempEventsStream, cancellationToken: ct);
|
|
||||||
File.Copy(tempScheduledEventsPath, scheduledEventsPath, true);
|
|
||||||
File.Delete(tempScheduledEventsPath);
|
|
||||||
|
|
||||||
_logger.LogInformation("Successfully loaded temporary scheduled events file: ${Path}",
|
|
||||||
tempScheduledEventsPath);
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "Unable to load temporary scheduled events file: {Path}, deleting",
|
|
||||||
tempScheduledEventsPath);
|
|
||||||
File.Delete(tempScheduledEventsPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await using var eventsStream = File.OpenRead(scheduledEventsPath);
|
|
||||||
return await JsonSerializer.DeserializeAsync<Dictionary<ulong, ScheduledEventData>>(
|
|
||||||
eventsStream, cancellationToken: ct);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "Guild scheduled events load failed: {Path}", scheduledEventsPath);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<JsonNode?> LoadGuildSettings(string settingsPath, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
var tempSettingsPath = $"{settingsPath}.tmp";
|
|
||||||
|
|
||||||
if (!File.Exists(settingsPath) && !File.Exists(tempSettingsPath))
|
|
||||||
{
|
|
||||||
return new JsonObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (File.Exists(tempSettingsPath))
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Found temporary settings file, will try to parse and copy to main: ${Path}",
|
|
||||||
tempSettingsPath);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await using var tempSettingsStream = File.OpenRead(tempSettingsPath);
|
|
||||||
var jsonSettings = await JsonNode.ParseAsync(tempSettingsStream, cancellationToken: ct);
|
|
||||||
|
|
||||||
File.Copy(tempSettingsPath, settingsPath, true);
|
|
||||||
File.Delete(tempSettingsPath);
|
|
||||||
|
|
||||||
_logger.LogInformation("Successfully loaded temporary settings file: ${Path}", tempSettingsPath);
|
|
||||||
return jsonSettings;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "Unable to load temporary settings file: {Path}, deleting", tempSettingsPath);
|
|
||||||
File.Delete(tempSettingsPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await using var settingsStream = File.OpenRead(settingsPath);
|
|
||||||
return await JsonNode.ParseAsync(settingsStream, cancellationToken: ct);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.LogError(e, "Guild settings load failed: {Path}", settingsPath);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MigrateDataDirectory(Snowflake guildId, string newPath)
|
|
||||||
{
|
|
||||||
var oldPath = $"{guildId}";
|
|
||||||
|
|
||||||
if (Directory.Exists(oldPath))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory($"{newPath}/..");
|
|
||||||
Directory.Move(oldPath, newPath);
|
|
||||||
|
|
||||||
_logger.LogInformation("Moved guild data to separate folder: \"{OldPath}\" -> \"{NewPath}\"", oldPath,
|
|
||||||
newPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void FixJsonSettings(JsonNode settings)
|
|
||||||
{
|
|
||||||
var language = settings[GuildSettings.Language.Name]?.GetValue<string>();
|
|
||||||
if (language is "mctaylors-ru")
|
|
||||||
{
|
|
||||||
settings[GuildSettings.Language.Name] = "ru";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<JsonNode> GetSettings(Snowflake guildId, CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
return (await GetData(guildId, ct)).Settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICollection<Snowflake> GetGuildIds()
|
|
||||||
{
|
|
||||||
return _datas.Keys;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool UnloadGuildData(Snowflake id)
|
|
||||||
{
|
|
||||||
return _datas.TryRemove(id, out _);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
services:
|
|
||||||
octobot:
|
|
||||||
container_name: octobot
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
- PUBLISH_OPTIONS
|
|
||||||
environment:
|
|
||||||
- BOT_TOKEN
|
|
||||||
volumes:
|
|
||||||
- guild-data:/Octobot/GuildData
|
|
||||||
- logs:/Octobot/Logs
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
guild-data:
|
|
||||||
logs:
|
|
|
@ -15,16 +15,23 @@ Veemo! I'm a general-purpose bot for moderation (formerly known as Boyfriend) wr
|
||||||
* Reminding everyone about that new event you made
|
* Reminding everyone about that new event you made
|
||||||
* Renaming those annoying self-hoisting members
|
* Renaming those annoying self-hoisting members
|
||||||
* Log everything from joining the server to deleting messages
|
* Log everything from joining the server to deleting messages
|
||||||
* Listen to Inkantation!
|
* Listen to music!
|
||||||
|
|
||||||
*...a-a-and more!*
|
*...a-a-and more!*
|
||||||
|
|
||||||
## Building Octobot
|
## Building Octobot
|
||||||
|
|
||||||
Check out the Octobot's Wiki for details.
|
1. Install [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
|
||||||
|
2. Go to the [Discord Developer Portal](https://discord.com/developers), create a new application and get a bot token. Don't forget to also enable all intents!
|
||||||
| [Windows](https://github.com/TeamOctolings/Octobot/wiki/Installing-Windows) | [Linux/macOS](https://github.com/TeamOctolings/Octobot/wiki/Installing-Unix) |
|
3. Clone this repository and open `Octobot` folder.
|
||||||
| --- | --- |
|
```
|
||||||
|
git clone https://github.com/TeamOctolings/Octobot
|
||||||
|
cd Octobot
|
||||||
|
```
|
||||||
|
4. Run Octobot using `dotnet` with `BOT_TOKEN` variable.
|
||||||
|
```
|
||||||
|
dotnet run BOT_TOKEN='ENTER_TOKEN_HERE'
|
||||||
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
|
|
@ -138,24 +138,12 @@
|
||||||
<data name="Milliseconds" xml:space="preserve">
|
<data name="Milliseconds" xml:space="preserve">
|
||||||
<value>ms</value>
|
<value>ms</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ChannelNotSpecified" xml:space="preserve">
|
|
||||||
<value>Not specified</value>
|
|
||||||
</data>
|
|
||||||
<data name="RoleNotSpecified" xml:space="preserve">
|
|
||||||
<value>Not specified</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsLanguage" xml:space="preserve">
|
<data name="SettingsLanguage" xml:space="preserve">
|
||||||
<value>Language</value>
|
<value>Language</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsPrefix" xml:space="preserve">
|
|
||||||
<value>Prefix</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsRemoveRolesOnMute" xml:space="preserve">
|
<data name="SettingsRemoveRolesOnMute" xml:space="preserve">
|
||||||
<value>Remove roles on mute</value>
|
<value>Remove roles on mute</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsSendWelcomeMessages" xml:space="preserve">
|
|
||||||
<value>Send welcome messages</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsMuteRole" xml:space="preserve">
|
<data name="SettingsMuteRole" xml:space="preserve">
|
||||||
<value>Mute role</value>
|
<value>Mute role</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -198,9 +186,6 @@
|
||||||
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||||
<value>Channel for event notifications</value>
|
<value>Channel for event notifications</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
|
||||||
<value>Event start notifications receivers</value>
|
|
||||||
</data>
|
|
||||||
<data name="EventStarted" xml:space="preserve">
|
<data name="EventStarted" xml:space="preserve">
|
||||||
<value>Event "{0}" started</value>
|
<value>Event "{0}" started</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -216,9 +201,6 @@
|
||||||
<data name="SettingsNothingChanged" xml:space="preserve">
|
<data name="SettingsNothingChanged" xml:space="preserve">
|
||||||
<value>Nothing changed! `{0}` is already set to {1}</value>
|
<value>Nothing changed! `{0}` is already set to {1}</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingNotDefined" xml:space="preserve">
|
|
||||||
<value>Not specified</value>
|
|
||||||
</data>
|
|
||||||
<data name="MissingUser" xml:space="preserve">
|
<data name="MissingUser" xml:space="preserve">
|
||||||
<value>You need to specify a user!</value>
|
<value>You need to specify a user!</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -399,8 +381,8 @@
|
||||||
<data name="AboutTitleDevelopers" xml:space="preserve">
|
<data name="AboutTitleDevelopers" xml:space="preserve">
|
||||||
<value>Developers:</value>
|
<value>Developers:</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ButtonOpenWebsite" xml:space="preserve">
|
<data name="ButtonOpenRepository" xml:space="preserve">
|
||||||
<value>Open Website</value>
|
<value>Octobot's source code</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="AboutBot" xml:space="preserve">
|
<data name="AboutBot" xml:space="preserve">
|
||||||
<value>About {0}</value>
|
<value>About {0}</value>
|
||||||
|
@ -447,12 +429,6 @@
|
||||||
<data name="PagesAllowed" xml:space="preserve">
|
<data name="PagesAllowed" xml:space="preserve">
|
||||||
<value>There are {0} total pages</value>
|
<value>There are {0} total pages</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Next" xml:space="preserve">
|
|
||||||
<value>Next</value>
|
|
||||||
</data>
|
|
||||||
<data name="Previous" xml:space="preserve">
|
|
||||||
<value>Previous</value>
|
|
||||||
</data>
|
|
||||||
<data name="ReminderList" xml:space="preserve">
|
<data name="ReminderList" xml:space="preserve">
|
||||||
<value>{0}'s reminders</value>
|
<value>{0}'s reminders</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -681,7 +657,4 @@
|
||||||
<data name="SettingsModeratorRole" xml:space="preserve">
|
<data name="SettingsModeratorRole" xml:space="preserve">
|
||||||
<value>Moderator role</value>
|
<value>Moderator role</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingValueEquals" xml:space="preserve">
|
|
||||||
<value>The setting value is the same as the input value.</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
|
@ -135,24 +135,12 @@
|
||||||
<data name="Milliseconds" xml:space="preserve">
|
<data name="Milliseconds" xml:space="preserve">
|
||||||
<value>мс</value>
|
<value>мс</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ChannelNotSpecified" xml:space="preserve">
|
|
||||||
<value>Не указан</value>
|
|
||||||
</data>
|
|
||||||
<data name="RoleNotSpecified" xml:space="preserve">
|
|
||||||
<value>Не указана</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsLanguage" xml:space="preserve">
|
<data name="SettingsLanguage" xml:space="preserve">
|
||||||
<value>Язык</value>
|
<value>Язык</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsPrefix" xml:space="preserve">
|
|
||||||
<value>Префикс</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsRemoveRolesOnMute" xml:space="preserve">
|
<data name="SettingsRemoveRolesOnMute" xml:space="preserve">
|
||||||
<value>Удалять роли при муте</value>
|
<value>Удалять роли при муте</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsSendWelcomeMessages" xml:space="preserve">
|
|
||||||
<value>Отправлять приветствия</value>
|
|
||||||
</data>
|
|
||||||
<data name="SettingsMuteRole" xml:space="preserve">
|
<data name="SettingsMuteRole" xml:space="preserve">
|
||||||
<value>Роль мута</value>
|
<value>Роль мута</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -195,9 +183,6 @@
|
||||||
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||||
<value>Канал для уведомлений о событиях</value>
|
<value>Канал для уведомлений о событиях</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingsEventStartedReceivers" xml:space="preserve">
|
|
||||||
<value>Получатели уведомлений о начале событий</value>
|
|
||||||
</data>
|
|
||||||
<data name="EventStarted" xml:space="preserve">
|
<data name="EventStarted" xml:space="preserve">
|
||||||
<value>Событие "{0}" началось</value>
|
<value>Событие "{0}" началось</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -213,9 +198,6 @@
|
||||||
<data name="SettingsNothingChanged" xml:space="preserve">
|
<data name="SettingsNothingChanged" xml:space="preserve">
|
||||||
<value>Ничего не изменилось! Значение настройки `{0}` уже {1}</value>
|
<value>Ничего не изменилось! Значение настройки `{0}` уже {1}</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingNotDefined" xml:space="preserve">
|
|
||||||
<value>Не указано</value>
|
|
||||||
</data>
|
|
||||||
<data name="MissingUser" xml:space="preserve">
|
<data name="MissingUser" xml:space="preserve">
|
||||||
<value>Надо указать пользователя!</value>
|
<value>Надо указать пользователя!</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -399,8 +381,8 @@
|
||||||
<data name="AboutTitleDevelopers" xml:space="preserve">
|
<data name="AboutTitleDevelopers" xml:space="preserve">
|
||||||
<value>Разработчики:</value>
|
<value>Разработчики:</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ButtonOpenWebsite" xml:space="preserve">
|
<data name="ButtonOpenRepository" xml:space="preserve">
|
||||||
<value>Открыть веб-сайт</value>
|
<value>Исходный код Octobot</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="AboutBot" xml:space="preserve">
|
<data name="AboutBot" xml:space="preserve">
|
||||||
<value>О боте {0}</value>
|
<value>О боте {0}</value>
|
||||||
|
@ -447,12 +429,6 @@
|
||||||
<data name="PagesAllowed" xml:space="preserve">
|
<data name="PagesAllowed" xml:space="preserve">
|
||||||
<value>Всего есть {0} страниц(-ы)</value>
|
<value>Всего есть {0} страниц(-ы)</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Next" xml:space="preserve">
|
|
||||||
<value>Далее</value>
|
|
||||||
</data>
|
|
||||||
<data name="Previous" xml:space="preserve">
|
|
||||||
<value>Назад</value>
|
|
||||||
</data>
|
|
||||||
<data name="ReminderList" xml:space="preserve">
|
<data name="ReminderList" xml:space="preserve">
|
||||||
<value>Напоминания {0}</value>
|
<value>Напоминания {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -681,7 +657,4 @@
|
||||||
<data name="SettingsModeratorRole" xml:space="preserve">
|
<data name="SettingsModeratorRole" xml:space="preserve">
|
||||||
<value>Роль модератора</value>
|
<value>Роль модератора</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="SettingValueEquals" xml:space="preserve">
|
|
||||||
<value>Значение настройки такое же, как и вводное значение.</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
660
locale/Messages.tt-ru.resx
Normal file
660
locale/Messages.tt-ru.resx
Normal file
|
@ -0,0 +1,660 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader><resheader name="version">2.0</resheader><resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader><resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader><data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data><data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data><data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"><value>[base64 mime encoded serialized .NET Framework object]</value></data><data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"><value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value><comment>This is a comment</comment></data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root" xmlns="">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 </value>
|
||||||
|
</resheader>
|
||||||
|
<data name="Ready" xml:space="preserve">
|
||||||
|
<value>я родился!</value>
|
||||||
|
</data>
|
||||||
|
<data name="CachedMessageDeleted" xml:space="preserve">
|
||||||
|
<value>сообщение {0} вырезано:</value>
|
||||||
|
</data>
|
||||||
|
<data name="CachedMessageEdited" xml:space="preserve">
|
||||||
|
<value>сообщение {0} переделано:</value>
|
||||||
|
</data>
|
||||||
|
<data name="DefaultWelcomeMessage" xml:space="preserve">
|
||||||
|
<value>{0}, добро пожаловать на сервер {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="Generic1" xml:space="preserve">
|
||||||
|
<value>вииимо!</value>
|
||||||
|
</data>
|
||||||
|
<data name="Generic2" xml:space="preserve">
|
||||||
|
<value>вуууми!</value>
|
||||||
|
</data>
|
||||||
|
<data name="Generic3" xml:space="preserve">
|
||||||
|
<value>нгьес!</value>
|
||||||
|
</data>
|
||||||
|
<data name="YouWereBanned" xml:space="preserve">
|
||||||
|
<value>вы были забанены</value>
|
||||||
|
</data>
|
||||||
|
<data name="PunishmentExpired" xml:space="preserve">
|
||||||
|
<value>время бана закончиловсь</value>
|
||||||
|
</data>
|
||||||
|
<data name="YouWereKicked" xml:space="preserve">
|
||||||
|
<value>вы были кикнуты</value>
|
||||||
|
</data>
|
||||||
|
<data name="Milliseconds" xml:space="preserve">
|
||||||
|
<value>мс</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsLanguage" xml:space="preserve">
|
||||||
|
<value>язык</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsRemoveRolesOnMute" xml:space="preserve">
|
||||||
|
<value>удалять звание при муте</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsMuteRole" xml:space="preserve">
|
||||||
|
<value>звание замученного</value>
|
||||||
|
</data>
|
||||||
|
<data name="LanguageNotSupported" xml:space="preserve">
|
||||||
|
<value>такого языка нету...</value>
|
||||||
|
</data>
|
||||||
|
<data name="Yes" xml:space="preserve">
|
||||||
|
<value>да</value>
|
||||||
|
</data>
|
||||||
|
<data name="No" xml:space="preserve">
|
||||||
|
<value>нъет</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserNotBanned" xml:space="preserve">
|
||||||
|
<value>шизик не забанен</value>
|
||||||
|
</data>
|
||||||
|
<data name="MemberNotMuted" xml:space="preserve">
|
||||||
|
<value>шизоид не замучен!</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsWelcomeMessage" xml:space="preserve">
|
||||||
|
<value>здравствуйте (типо настройка)</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserBanned" xml:space="preserve">
|
||||||
|
<value>{0} забанен</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsReceiveStartupMessages" xml:space="preserve">
|
||||||
|
<value>получать инфу о старте бота</value>
|
||||||
|
</data>
|
||||||
|
<data name="InvalidSettingValue" xml:space="preserve">
|
||||||
|
<value>криво настроил прикол, давай по новой</value>
|
||||||
|
</data>
|
||||||
|
<data name="DurationRequiredForTimeOuts" xml:space="preserve">
|
||||||
|
<value>ты шо, мутить больше чем на 28 дней таймаут не разрешает, вот настроишь роль мута, тогда поговорим</value>
|
||||||
|
</data>
|
||||||
|
<data name="CannotTimeOutBot" xml:space="preserve">
|
||||||
|
<value>я не могу замутить ботов, сделай что нибудь</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsEventNotificationRole" xml:space="preserve">
|
||||||
|
<value>роль для уведомлений о создании движухи</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsEventNotificationChannel" xml:space="preserve">
|
||||||
|
<value>канал для уведомлений о движухах</value>
|
||||||
|
</data>
|
||||||
|
<data name="EventStarted" xml:space="preserve">
|
||||||
|
<value>движуха "{0}" начинается</value>
|
||||||
|
</data>
|
||||||
|
<data name="EventCancelled" xml:space="preserve">
|
||||||
|
<value>движуха "{0}" отменена!</value>
|
||||||
|
</data>
|
||||||
|
<data name="EventCompleted" xml:space="preserve">
|
||||||
|
<value>движуха "{0}" завершена!</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessagesCleared" xml:space="preserve">
|
||||||
|
<value>вырезано {0} забавных сообщений</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsNothingChanged" xml:space="preserve">
|
||||||
|
<value>ты все сломал! значение прикола `{0}` и так {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="MissingUser" xml:space="preserve">
|
||||||
|
<value>укажи самого шизика</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotBanMembers" xml:space="preserve">
|
||||||
|
<value>бан</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotManageMessages" xml:space="preserve">
|
||||||
|
<value>тебе нельзя иметь власть над сообщениями шизоидов</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotKickMembers" xml:space="preserve">
|
||||||
|
<value>кик шизиков нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotMuteMembers" xml:space="preserve">
|
||||||
|
<value>тебе нельзя мутить шизоидов</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotUnmuteMembers" xml:space="preserve">
|
||||||
|
<value>тебе нельзя раззамучивать шизоидов</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotManageGuild" xml:space="preserve">
|
||||||
|
<value>тебе нельзя редактировать дурку</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotBanMembers" xml:space="preserve">
|
||||||
|
<value>я не могу ваще никого банить чел.</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotManageMessages" xml:space="preserve">
|
||||||
|
<value>я не могу исправлять орфографический кринж участников, сделай что нибудь.</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotKickMembers" xml:space="preserve">
|
||||||
|
<value>я не могу ваще никого кикать чел.</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotModerateMembers" xml:space="preserve">
|
||||||
|
<value>я не могу контроллировать за всеми ними, сделай что нибудь.</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotManageGuild" xml:space="preserve">
|
||||||
|
<value>я не могу этому серверу хоть че либо нибудь изменить, сделай что нибудь.</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotBanBot" xml:space="preserve">
|
||||||
|
<value>ээбля френдли фаер огонь по своим</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotBanOwner" xml:space="preserve">
|
||||||
|
<value>бан админу нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotBanTarget" xml:space="preserve">
|
||||||
|
<value>бан этому шизику нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotBanThemselves" xml:space="preserve">
|
||||||
|
<value>самобан нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotBanTarget" xml:space="preserve">
|
||||||
|
<value>я не могу его забанить...</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotKickOwner" xml:space="preserve">
|
||||||
|
<value>кик админу нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotKickThemselves" xml:space="preserve">
|
||||||
|
<value>самокик нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotKickBot" xml:space="preserve">
|
||||||
|
<value>ээбля френдли фаер огонь по своим</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotKickTarget" xml:space="preserve">
|
||||||
|
<value>я не могу его кикнуть...</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotKickTarget" xml:space="preserve">
|
||||||
|
<value>кик этому шизику нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotMuteOwner" xml:space="preserve">
|
||||||
|
<value>мут админу нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotMuteThemselves" xml:space="preserve">
|
||||||
|
<value>самомут нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotMuteBot" xml:space="preserve">
|
||||||
|
<value>ээбля френдли фаер огонь по своим</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotMuteTarget" xml:space="preserve">
|
||||||
|
<value>я не могу его замутить...</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotMuteTarget" xml:space="preserve">
|
||||||
|
<value>мут этому шизику нельзя</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotUnmuteOwner" xml:space="preserve">
|
||||||
|
<value>сильно</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotUnmuteThemselves" xml:space="preserve">
|
||||||
|
<value>ты замучен.</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotUnmuteBot" xml:space="preserve">
|
||||||
|
<value>... </value>
|
||||||
|
</data>
|
||||||
|
<data name="UserCannotUnmuteTarget" xml:space="preserve">
|
||||||
|
<value>тебе нельзя раззамучивать</value>
|
||||||
|
</data>
|
||||||
|
<data name="BotCannotUnmuteTarget" xml:space="preserve">
|
||||||
|
<value>я не могу его раззамутить...</value>
|
||||||
|
</data>
|
||||||
|
<data name="EventEarlyNotification" xml:space="preserve">
|
||||||
|
<value>движуха "{0}" начнется {1}!</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsEventEarlyNotificationOffset" xml:space="preserve">
|
||||||
|
<value>заранее пнуть в минутах до начала движухи</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserNotFound" xml:space="preserve">
|
||||||
|
<value>у нас такого шизоида нету, проверь, валиден ли ID уважаемого (я забываю о шизоидах если они ливнули минимум месяц назад)</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsDefaultRole" xml:space="preserve">
|
||||||
|
<value>дефолтное звание</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsPrivateFeedbackChannel" xml:space="preserve">
|
||||||
|
<value>канал для секретных уведомлений</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsPublicFeedbackChannel" xml:space="preserve">
|
||||||
|
<value>канал для не секретных уведомлений</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsReturnRolesOnRejoin" xml:space="preserve">
|
||||||
|
<value>вернуть звания при переподключении в дурку</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsAutoStartEvents" xml:space="preserve">
|
||||||
|
<value>автоматом стартить движухи</value>
|
||||||
|
</data>
|
||||||
|
<data name="IssuedBy" xml:space="preserve">
|
||||||
|
<value>ответственный</value>
|
||||||
|
</data>
|
||||||
|
<data name="EventCreatedTitle" xml:space="preserve">
|
||||||
|
<value>{0} создает новое событие:</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionLocalEventCreated" xml:space="preserve">
|
||||||
|
<value>движуха произойдет {0} в канале {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionExternalEventCreated" xml:space="preserve">
|
||||||
|
<value>движуха будет происходить с {0} до {1} в {2}</value>
|
||||||
|
</data>
|
||||||
|
<data name="ButtonOpenEventInfo" xml:space="preserve">
|
||||||
|
<value>открыть ивент</value>
|
||||||
|
</data>
|
||||||
|
<data name="EventDuration" xml:space="preserve">
|
||||||
|
<value>все это длилось `{0}`</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionLocalEventStarted" xml:space="preserve">
|
||||||
|
<value>движуха происходит в {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionExternalEventStarted" xml:space="preserve">
|
||||||
|
<value>движуха происходит в {0} до {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserAlreadyBanned" xml:space="preserve">
|
||||||
|
<value>этот шизоид уже лежит в бане</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserUnbanned" xml:space="preserve">
|
||||||
|
<value>{0} раззабанен</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserMuted" xml:space="preserve">
|
||||||
|
<value>{0} в муте</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserUnmuted" xml:space="preserve">
|
||||||
|
<value>{0} в размуте</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserNotMuted" xml:space="preserve">
|
||||||
|
<value>этого шизоида никто не мутил.</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserNotFoundShort" xml:space="preserve">
|
||||||
|
<value>у нас такого шизоида нету...</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserKicked" xml:space="preserve">
|
||||||
|
<value>{0} вышел с посторонней помощью</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionActionReason" xml:space="preserve">
|
||||||
|
<value>причина: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionActionExpiresAt" xml:space="preserve">
|
||||||
|
<value>до: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserAlreadyMuted" xml:space="preserve">
|
||||||
|
<value>этот шизоид УЖЕ замучился</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessageFrom" xml:space="preserve">
|
||||||
|
<value>от {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="AboutTitleDevelopers" xml:space="preserve">
|
||||||
|
<value>девелоперы:</value>
|
||||||
|
</data>
|
||||||
|
<data name="ButtonOpenRepository" xml:space="preserve">
|
||||||
|
<value>репа Octobot (тык)</value>
|
||||||
|
</data>
|
||||||
|
<data name="AboutBot" xml:space="preserve">
|
||||||
|
<value>немного об {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="AboutDeveloper@mctaylors" xml:space="preserve">
|
||||||
|
<value>скучный девелопер + дизайнер создавший Octobot's Wiki</value>
|
||||||
|
</data>
|
||||||
|
<data name="AboutDeveloper@neroduckale" xml:space="preserve">
|
||||||
|
<value>ВАЖНЫЙ соучастник кодинг-стримов @Octol1ttle</value>
|
||||||
|
</data>
|
||||||
|
<data name="AboutDeveloper@Octol1ttle" xml:space="preserve">
|
||||||
|
<value>САМЫЙ ВАЖНЫЙ чел написавший кода больше всех (99.99%)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderCreated" xml:space="preserve">
|
||||||
|
<value>напоминалка для {0} скрафченА</value>
|
||||||
|
</data>
|
||||||
|
<data name="Reminder" xml:space="preserve">
|
||||||
|
<value>напоминалка для {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionReminder" xml:space="preserve">
|
||||||
|
<value>ты хотел чтоб я напомнил тебе {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsListTitle" xml:space="preserve">
|
||||||
|
<value>приколы Octobot</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingSuccessfullyChanged" xml:space="preserve">
|
||||||
|
<value>прикол редактирован</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingNotChanged" xml:space="preserve">
|
||||||
|
<value>прикол сдох</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingIsNow" xml:space="preserve">
|
||||||
|
<value>стало</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsRenameHoistedUsers" xml:space="preserve">
|
||||||
|
<value>переобувать шизоидов пытающихся поднять себя в табе</value>
|
||||||
|
</data>
|
||||||
|
<data name="Page" xml:space="preserve">
|
||||||
|
<value>это страница</value>
|
||||||
|
</data>
|
||||||
|
<data name="PageNotFound" xml:space="preserve">
|
||||||
|
<value>если я был бы html, я бы сказал 404</value>
|
||||||
|
</data>
|
||||||
|
<data name="PagesAllowed" xml:space="preserve">
|
||||||
|
<value>ну а если быть точнее, тут всего {0} страниц(-ы)</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderList" xml:space="preserve">
|
||||||
|
<value>напоминалки {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="InvalidReminderPosition" xml:space="preserve">
|
||||||
|
<value>у тебя нет напоминалки на этом номере!</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderDeleted" xml:space="preserve">
|
||||||
|
<value>напоминалка уничтожена</value>
|
||||||
|
</data>
|
||||||
|
<data name="NoRemindersFound" xml:space="preserve">
|
||||||
|
<value>ты еще не крафтил напоминалки</value>
|
||||||
|
</data>
|
||||||
|
<data name="SingleSettingReset" xml:space="preserve">
|
||||||
|
<value>{0} откачен к заводским</value>
|
||||||
|
</data>
|
||||||
|
<data name="AllSettingsReset" xml:space="preserve">
|
||||||
|
<value>откатываемся к заводским...</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionActionJumpToMessage" xml:space="preserve">
|
||||||
|
<value>чекнуть сообщение: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="DescriptionActionJumpToChannel" xml:space="preserve">
|
||||||
|
<value>чекнуть канал: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderPosition" xml:space="preserve">
|
||||||
|
<value>номер в списке: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderTime" xml:space="preserve">
|
||||||
|
<value>время отправки: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderText" xml:space="preserve">
|
||||||
|
<value>че там в напоминалке: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoDisplayName" xml:space="preserve">
|
||||||
|
<value>дисплейнейм</value>
|
||||||
|
</data>
|
||||||
|
<data name="InformationAbout" xml:space="preserve">
|
||||||
|
<value>деанон {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoMuted" xml:space="preserve">
|
||||||
|
<value>замучен</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoDiscordUserSince" xml:space="preserve">
|
||||||
|
<value>юзер Discord со времен</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoBanned" xml:space="preserve">
|
||||||
|
<value>забанен</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoPunishments" xml:space="preserve">
|
||||||
|
<value>приколы полученные по заслугам</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoBannedPermanently" xml:space="preserve">
|
||||||
|
<value>пермабан</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoNotOnGuild" xml:space="preserve">
|
||||||
|
<value>вышел из сервера</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoMutedByTimeout" xml:space="preserve">
|
||||||
|
<value>замучен таймаутом</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoMutedByMuteRole" xml:space="preserve">
|
||||||
|
<value>замучен ролькой</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoGuildMemberSince" xml:space="preserve">
|
||||||
|
<value>участник сервера со времен</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoGuildNickname" xml:space="preserve">
|
||||||
|
<value>сервернейм</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoGuildRoles" xml:space="preserve">
|
||||||
|
<value>рольки</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoGuildMemberPremiumSince" xml:space="preserve">
|
||||||
|
<value>бустит сервер со времен</value>
|
||||||
|
</data>
|
||||||
|
<data name="RandomTitle" xml:space="preserve">
|
||||||
|
<value>рандомное число {0}:</value>
|
||||||
|
</data>
|
||||||
|
<data name="RandomMinMaxSame" xml:space="preserve">
|
||||||
|
<value>ну чувак...</value>
|
||||||
|
</data>
|
||||||
|
<data name="RandomMax" xml:space="preserve">
|
||||||
|
<value>наибольшее: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="RandomMin" xml:space="preserve">
|
||||||
|
<value>наименьшее: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="Default" xml:space="preserve">
|
||||||
|
<value>(дефолт)</value>
|
||||||
|
</data>
|
||||||
|
<data name="TimestampTitle" xml:space="preserve">
|
||||||
|
<value>таймштамп для {0}:</value>
|
||||||
|
</data>
|
||||||
|
<data name="TimestampOffset" xml:space="preserve">
|
||||||
|
<value>офсет: {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="GuildInfoDescription" xml:space="preserve">
|
||||||
|
<value>дескрипшон гильдии</value>
|
||||||
|
</data>
|
||||||
|
<data name="GuildInfoCreatedAt" xml:space="preserve">
|
||||||
|
<value>создался</value>
|
||||||
|
</data>
|
||||||
|
<data name="GuildInfoOwner" xml:space="preserve">
|
||||||
|
<value>админ гильдии</value>
|
||||||
|
</data>
|
||||||
|
<data name="GuildInfoServerBoost" xml:space="preserve">
|
||||||
|
<value>буст гильдии</value>
|
||||||
|
</data>
|
||||||
|
<data name="GuildInfoBoostTier" xml:space="preserve">
|
||||||
|
<value>уровень</value>
|
||||||
|
</data>
|
||||||
|
<data name="GuildInfoBoostCount" xml:space="preserve">
|
||||||
|
<value>кол-во бустов</value>
|
||||||
|
</data>
|
||||||
|
<data name="NoMessagesToClear" xml:space="preserve">
|
||||||
|
<value>алло а чё мне удалять-то</value>
|
||||||
|
</data>
|
||||||
|
<data name="MessagesClearedFiltered" xml:space="preserve">
|
||||||
|
<value>вырезано {0} забавных сообщений от {1}</value>
|
||||||
|
</data>
|
||||||
|
<data name="DataLoadFailedTitle" xml:space="preserve">
|
||||||
|
<value>произошёл тотальный разнос в гилддате.</value>
|
||||||
|
</data>
|
||||||
|
<data name="DataLoadFailedDescription" xml:space="preserve">
|
||||||
|
<value>возможно всё съедет с крыши, но знай, что я больше ничё не сохраню.</value>
|
||||||
|
</data>
|
||||||
|
<data name="CommandExecutionFailed" xml:space="preserve">
|
||||||
|
<value>произошёл тотальный разнос в команде, удачи.</value>
|
||||||
|
</data>
|
||||||
|
<data name="ContactDevelopers" xml:space="preserve">
|
||||||
|
<value>если ты это читаешь второй раз за сегодня, пиши разрабам</value>
|
||||||
|
</data>
|
||||||
|
<data name="ButtonReportIssue" xml:space="preserve">
|
||||||
|
<value>зарепортить баг</value>
|
||||||
|
</data>
|
||||||
|
<data name="DefaultLeaveMessage" xml:space="preserve">
|
||||||
|
<value>ну, мы потеряли {0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsLeaveMessage" xml:space="preserve">
|
||||||
|
<value>до свидания (типо настройка)</value>
|
||||||
|
</data>
|
||||||
|
<data name="InvalidTimeSpan" xml:space="preserve">
|
||||||
|
<value>ты там правильно напиши таймспан</value>
|
||||||
|
</data>
|
||||||
|
<data name="UserInfoKicked" xml:space="preserve">
|
||||||
|
<value>кикнут</value>
|
||||||
|
</data>
|
||||||
|
<data name="ReminderEdited" xml:space="preserve">
|
||||||
|
<value>напоминалка подправлена</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallPositive1" xml:space="preserve">
|
||||||
|
<value>абсолютли</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallPositive2" xml:space="preserve">
|
||||||
|
<value>заявлено</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallPositive3" xml:space="preserve">
|
||||||
|
<value>ваще не сомневайся</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallPositive4" xml:space="preserve">
|
||||||
|
<value>100% да</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallPositive5" xml:space="preserve">
|
||||||
|
<value>будь в этом уверен</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallQuestionable1" xml:space="preserve">
|
||||||
|
<value>я считаю что да</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallQuestionable2" xml:space="preserve">
|
||||||
|
<value>ну вполне вероятно</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallQuestionable3" xml:space="preserve">
|
||||||
|
<value>ну выглядит нормально</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallQuestionable4" xml:space="preserve">
|
||||||
|
<value>мне сказали ок</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallQuestionable5" xml:space="preserve">
|
||||||
|
<value>мгм</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNeutral1" xml:space="preserve">
|
||||||
|
<value>ну-ка попробуй снова</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNeutral2" xml:space="preserve">
|
||||||
|
<value>давай позже</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNeutral3" xml:space="preserve">
|
||||||
|
<value>щас пока не скажу</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNeutral4" xml:space="preserve">
|
||||||
|
<value>я не могу сейчас предсказать</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNeutral5" xml:space="preserve">
|
||||||
|
<value>ну сконцентрируйся и давай еще раз</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNegative1" xml:space="preserve">
|
||||||
|
<value>даже не думай</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNegative2" xml:space="preserve">
|
||||||
|
<value>мое завление это нет</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNegative3" xml:space="preserve">
|
||||||
|
<value>я тут посчитал, короче нет</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNegative4" xml:space="preserve">
|
||||||
|
<value>выглядит такое себе</value>
|
||||||
|
</data>
|
||||||
|
<data name="EightBallNegative5" xml:space="preserve">
|
||||||
|
<value>чот сомневаюсь</value>
|
||||||
|
</data>
|
||||||
|
<data name="TimeSpanExample" xml:space="preserve">
|
||||||
|
<value>правильно пишут так: `1h30m`</value>
|
||||||
|
</data>
|
||||||
|
<data name="Version" xml:space="preserve">
|
||||||
|
<value>{0}</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsWelcomeMessagesChannel" xml:space="preserve">
|
||||||
|
<value>канал куда говорить здравствуйте</value>
|
||||||
|
</data>
|
||||||
|
<data name="ButtonDirty" xml:space="preserve">
|
||||||
|
<value>вот иди сам и почини что сломал</value>
|
||||||
|
</data>
|
||||||
|
<data name="ButtonOpenWiki" xml:space="preserve">
|
||||||
|
<value>вики Octobot (жмак)</value>
|
||||||
|
</data>
|
||||||
|
<data name="SettingsModeratorRole" xml:space="preserve">
|
||||||
|
<value>звание админа</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
|
@ -1,4 +1,4 @@
|
||||||
namespace TeamOctolings.Octobot.Attributes;
|
namespace Octobot.Attributes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Any property marked with <see cref="StaticCallersOnlyAttribute"/> should only be accessed by static methods.
|
/// Any property marked with <see cref="StaticCallersOnlyAttribute"/> should only be accessed by static methods.
|
|
@ -1,10 +1,8 @@
|
||||||
namespace TeamOctolings.Octobot;
|
namespace Octobot;
|
||||||
|
|
||||||
public static class BuildInfo
|
public static class BuildInfo
|
||||||
{
|
{
|
||||||
public const string WebsiteUrl = "https://teamoctolings.github.io/Octobot";
|
public const string RepositoryUrl = "https://github.com/TeamOctolings/Octobot";
|
||||||
|
|
||||||
private const string RepositoryUrl = "https://github.com/TeamOctolings/Octobot";
|
|
||||||
|
|
||||||
public const string IssuesUrl = $"{RepositoryUrl}/issues";
|
public const string IssuesUrl = $"{RepositoryUrl}/issues";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot;
|
namespace Octobot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains all colors used in embeds.
|
/// Contains all colors used in embeds.
|
|
@ -1,6 +1,9 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -15,17 +18,14 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the command to show information about this bot: /about.
|
/// Handles the command to show information about this bot: /about.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class AboutCommandGroup : CommandGroup
|
public class AboutCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private static readonly (string Username, Snowflake Id)[] Developers =
|
private static readonly (string Username, Snowflake Id)[] Developers =
|
||||||
[
|
[
|
||||||
|
@ -36,9 +36,9 @@ public sealed class AboutCommandGroup : CommandGroup
|
||||||
|
|
||||||
private readonly ICommandContext _context;
|
private readonly ICommandContext _context;
|
||||||
private readonly IFeedbackService _feedback;
|
private readonly IFeedbackService _feedback;
|
||||||
private readonly IDiscordRestGuildAPI _guildApi;
|
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
private readonly IDiscordRestUserAPI _userApi;
|
private readonly IDiscordRestUserAPI _userApi;
|
||||||
|
private readonly IDiscordRestGuildAPI _guildApi;
|
||||||
|
|
||||||
public AboutCommandGroup(
|
public AboutCommandGroup(
|
||||||
ICommandContext context, GuildDataService guildData,
|
ICommandContext context, GuildDataService guildData,
|
||||||
|
@ -100,21 +100,21 @@ public sealed class AboutCommandGroup : CommandGroup
|
||||||
.WithSmallTitle(string.Format(Messages.AboutBot, bot.Username), bot)
|
.WithSmallTitle(string.Format(Messages.AboutBot, bot.Username), bot)
|
||||||
.WithDescription(builder.ToString())
|
.WithDescription(builder.ToString())
|
||||||
.WithColour(ColorsList.Cyan)
|
.WithColour(ColorsList.Cyan)
|
||||||
.WithImageUrl("https://raw.githubusercontent.com/TeamOctolings/Octobot/HEAD/docs/octobot-banner.png")
|
.WithImageUrl("https://i.ibb.co/fS6wZhh/octobot-banner.png")
|
||||||
.WithFooter(string.Format(Messages.Version, BuildInfo.Version))
|
.WithFooter(string.Format(Messages.Version, BuildInfo.Version))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var repositoryButton = new ButtonComponent(
|
var repositoryButton = new ButtonComponent(
|
||||||
ButtonComponentStyle.Link,
|
ButtonComponentStyle.Link,
|
||||||
Messages.ButtonOpenWebsite,
|
Messages.ButtonOpenRepository,
|
||||||
new PartialEmoji(Name: "\ud83c\udf10"), // 'GLOBE WITH MERIDIANS' (U+1F310)
|
new PartialEmoji(Name: "🌐"),
|
||||||
URL: BuildInfo.WebsiteUrl
|
URL: BuildInfo.RepositoryUrl
|
||||||
);
|
);
|
||||||
|
|
||||||
var wikiButton = new ButtonComponent(
|
var wikiButton = new ButtonComponent(
|
||||||
ButtonComponentStyle.Link,
|
ButtonComponentStyle.Link,
|
||||||
Messages.ButtonOpenWiki,
|
Messages.ButtonOpenWiki,
|
||||||
new PartialEmoji(Name: "\ud83d\udcd6"), // 'OPEN BOOK' (U+1F4D6)
|
new PartialEmoji(Name: "📖"),
|
||||||
URL: BuildInfo.WikiUrl
|
URL: BuildInfo.WikiUrl
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ public sealed class AboutCommandGroup : CommandGroup
|
||||||
BuildInfo.IsDirty
|
BuildInfo.IsDirty
|
||||||
? Messages.ButtonDirty
|
? Messages.ButtonDirty
|
||||||
: Messages.ButtonReportIssue,
|
: Messages.ButtonReportIssue,
|
||||||
new PartialEmoji(Name: "\u26a0\ufe0f"), // 'WARNING SIGN' (U+26A0)
|
new PartialEmoji(Name: "⚠️"),
|
||||||
URL: BuildInfo.IssuesUrl,
|
URL: BuildInfo.IssuesUrl,
|
||||||
IsDisabled: BuildInfo.IsDirty
|
IsDisabled: BuildInfo.IsDirty
|
||||||
);
|
);
|
||||||
|
@ -131,7 +131,7 @@ public sealed class AboutCommandGroup : CommandGroup
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed,
|
return await _feedback.SendContextualEmbedResultAsync(embed,
|
||||||
new FeedbackMessageOptions(MessageComponents: new[]
|
new FeedbackMessageOptions(MessageComponents: new[]
|
||||||
{
|
{
|
||||||
new ActionRowComponent([repositoryButton, wikiButton, issuesButton])
|
new ActionRowComponent(new[] { repositoryButton, wikiButton, issuesButton })
|
||||||
}), ct);
|
}), ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,6 +2,11 @@ using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Parsers;
|
||||||
|
using Octobot.Services;
|
||||||
|
using Octobot.Services.Update;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -14,19 +19,14 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Parsers;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
using TeamOctolings.Octobot.Services.Update;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles commands related to ban management: /ban and /unban.
|
/// Handles commands related to ban management: /ban and /unban.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class BanCommandGroup : CommandGroup
|
public class BanCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private readonly AccessControlService _access;
|
private readonly AccessControlService _access;
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
|
@ -62,7 +62,7 @@ public sealed class BanCommandGroup : CommandGroup
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the user
|
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the user
|
||||||
/// was banned and vice versa.
|
/// was banned and vice-versa.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <seealso cref="ExecuteUnban" />
|
/// <seealso cref="ExecuteUnban" />
|
||||||
[Command("ban", "бан")]
|
[Command("ban", "бан")]
|
||||||
|
@ -219,7 +219,7 @@ public sealed class BanCommandGroup : CommandGroup
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the user
|
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the user
|
||||||
/// was unbanned and vice versa.
|
/// was unbanned and vice-versa.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <seealso cref="ExecuteBanAsync" />
|
/// <seealso cref="ExecuteBanAsync" />
|
||||||
/// <seealso cref="MemberUpdateService.TickMemberDataAsync" />
|
/// <seealso cref="MemberUpdateService.TickMemberDataAsync" />
|
|
@ -1,6 +1,9 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -13,17 +16,14 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the command to clear messages in a channel: /clear.
|
/// Handles the command to clear messages in a channel: /clear.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class ClearCommandGroup : CommandGroup
|
public class ClearCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
private readonly ICommandContext _context;
|
private readonly ICommandContext _context;
|
||||||
|
@ -51,7 +51,7 @@ public sealed class ClearCommandGroup : CommandGroup
|
||||||
/// <param name="author">The user whose messages will be cleared.</param>
|
/// <param name="author">The user whose messages will be cleared.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that any messages
|
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that any messages
|
||||||
/// were cleared and vice versa.
|
/// were cleared and vice-versa.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Command("clear", "очистить")]
|
[Command("clear", "очистить")]
|
||||||
[DiscordDefaultMemberPermissions(DiscordPermission.ManageMessages)]
|
[DiscordDefaultMemberPermissions(DiscordPermission.ManageMessages)]
|
||||||
|
@ -64,7 +64,6 @@ public sealed class ClearCommandGroup : CommandGroup
|
||||||
public async Task<Result> ExecuteClear(
|
public async Task<Result> ExecuteClear(
|
||||||
[Description("Number of messages to remove (2-100)")] [MinValue(2)] [MaxValue(100)]
|
[Description("Number of messages to remove (2-100)")] [MinValue(2)] [MaxValue(100)]
|
||||||
int amount,
|
int amount,
|
||||||
[Description("Ignore messages except from the specified author")]
|
|
||||||
IUser? author = null)
|
IUser? author = null)
|
||||||
{
|
{
|
||||||
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
if (!_context.TryGetContextIDs(out var guildId, out var channelId, out var executorId))
|
|
@ -1,5 +1,6 @@
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Extensions;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.API.Objects;
|
using Remora.Discord.API.Objects;
|
||||||
|
@ -10,15 +11,14 @@ using Remora.Discord.Commands.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands.Events;
|
namespace Octobot.Commands.Events;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles error logging for slash command groups.
|
/// Handles error logging for slash command groups.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
|
public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
|
||||||
{
|
{
|
||||||
private readonly IFeedbackService _feedback;
|
private readonly IFeedbackService _feedback;
|
||||||
private readonly ILogger<ErrorLoggingPostExecutionEvent> _logger;
|
private readonly ILogger<ErrorLoggingPostExecutionEvent> _logger;
|
||||||
|
@ -73,7 +73,7 @@ public sealed class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
|
||||||
BuildInfo.IsDirty
|
BuildInfo.IsDirty
|
||||||
? Messages.ButtonDirty
|
? Messages.ButtonDirty
|
||||||
: Messages.ButtonReportIssue,
|
: Messages.ButtonReportIssue,
|
||||||
new PartialEmoji(Name: "\u26a0\ufe0f"), // 'WARNING SIGN' (U+26A0)
|
new PartialEmoji(Name: "⚠️"),
|
||||||
URL: BuildInfo.IssuesUrl,
|
URL: BuildInfo.IssuesUrl,
|
||||||
IsDisabled: BuildInfo.IsDirty
|
IsDisabled: BuildInfo.IsDirty
|
||||||
);
|
);
|
||||||
|
@ -81,7 +81,7 @@ public sealed class ErrorLoggingPostExecutionEvent : IPostExecutionEvent
|
||||||
return ResultExtensions.FromError(await _feedback.SendContextualEmbedResultAsync(embed,
|
return ResultExtensions.FromError(await _feedback.SendContextualEmbedResultAsync(embed,
|
||||||
new FeedbackMessageOptions(MessageComponents: new[]
|
new FeedbackMessageOptions(MessageComponents: new[]
|
||||||
{
|
{
|
||||||
new ActionRowComponent([issuesButton])
|
new ActionRowComponent(new[] { issuesButton })
|
||||||
}), ct)
|
}), ct)
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Extensions;
|
||||||
using Remora.Discord.Commands.Contexts;
|
using Remora.Discord.Commands.Contexts;
|
||||||
using Remora.Discord.Commands.Services;
|
using Remora.Discord.Commands.Services;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands.Events;
|
namespace Octobot.Commands.Events;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles error logging for slash commands that couldn't be successfully prepared.
|
/// Handles error logging for slash commands that couldn't be successfully prepared.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class LoggingPreparationErrorEvent : IPreparationErrorEvent
|
public class LoggingPreparationErrorEvent : IPreparationErrorEvent
|
||||||
{
|
{
|
||||||
private readonly ILogger<LoggingPreparationErrorEvent> _logger;
|
private readonly ILogger<LoggingPreparationErrorEvent> _logger;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -12,17 +15,14 @@ using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the command to kick members of a guild: /kick.
|
/// Handles the command to kick members of a guild: /kick.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class KickCommandGroup : CommandGroup
|
public class KickCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private readonly AccessControlService _access;
|
private readonly AccessControlService _access;
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
|
@ -57,7 +57,7 @@ public sealed class KickCommandGroup : CommandGroup
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
||||||
/// was kicked and vice versa.
|
/// was kicked and vice-versa.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
[Command("kick", "кик")]
|
[Command("kick", "кик")]
|
||||||
[DiscordDefaultMemberPermissions(DiscordPermission.ManageMessages)]
|
[DiscordDefaultMemberPermissions(DiscordPermission.ManageMessages)]
|
|
@ -2,6 +2,11 @@ using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Parsers;
|
||||||
|
using Octobot.Services;
|
||||||
|
using Octobot.Services.Update;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -14,19 +19,14 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Parsers;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
using TeamOctolings.Octobot.Services.Update;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles commands related to mute management: /mute and /unmute.
|
/// Handles commands related to mute management: /mute and /unmute.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class MuteCommandGroup : CommandGroup
|
public class MuteCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private readonly AccessControlService _access;
|
private readonly AccessControlService _access;
|
||||||
private readonly ICommandContext _context;
|
private readonly ICommandContext _context;
|
||||||
|
@ -59,7 +59,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
||||||
/// was muted and vice versa.
|
/// was muted and vice-versa.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <seealso cref="ExecuteUnmute" />
|
/// <seealso cref="ExecuteUnmute" />
|
||||||
[Command("mute", "мут")]
|
[Command("mute", "мут")]
|
||||||
|
@ -170,7 +170,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
||||||
|
|
||||||
private async Task<Result> SelectMuteMethodAsync(
|
private async Task<Result> SelectMuteMethodAsync(
|
||||||
IUser executor, IUser target, string reason, TimeSpan duration, Snowflake guildId, GuildData data,
|
IUser executor, IUser target, string reason, TimeSpan duration, Snowflake guildId, GuildData data,
|
||||||
IUser bot, DateTimeOffset until, CancellationToken ct = default)
|
IUser bot, DateTimeOffset until, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var muteRole = GuildSettings.MuteRole.Get(data.Settings);
|
var muteRole = GuildSettings.MuteRole.Get(data.Settings);
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
||||||
|
|
||||||
private async Task<Result> RoleMuteUserAsync(
|
private async Task<Result> RoleMuteUserAsync(
|
||||||
IUser executor, IUser target, string reason, Snowflake guildId, GuildData data,
|
IUser executor, IUser target, string reason, Snowflake guildId, GuildData data,
|
||||||
DateTimeOffset until, Snowflake muteRole, CancellationToken ct = default)
|
DateTimeOffset until, Snowflake muteRole, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var assignRoles = new List<Snowflake> { muteRole };
|
var assignRoles = new List<Snowflake> { muteRole };
|
||||||
var memberData = data.GetOrCreateMemberData(target.ID);
|
var memberData = data.GetOrCreateMemberData(target.ID);
|
||||||
|
@ -208,7 +208,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
||||||
|
|
||||||
private async Task<Result> TimeoutUserAsync(
|
private async Task<Result> TimeoutUserAsync(
|
||||||
IUser executor, IUser target, string reason, TimeSpan duration, Snowflake guildId,
|
IUser executor, IUser target, string reason, TimeSpan duration, Snowflake guildId,
|
||||||
IUser bot, DateTimeOffset until, CancellationToken ct = default)
|
IUser bot, DateTimeOffset until, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (duration.TotalDays >= 28)
|
if (duration.TotalDays >= 28)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +235,7 @@ public sealed class MuteCommandGroup : CommandGroup
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
/// A feedback sending result which may or may not have succeeded. A successful result does not mean that the member
|
||||||
/// was unmuted and vice versa.
|
/// was unmuted and vice-versa.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <seealso cref="ExecuteMute" />
|
/// <seealso cref="ExecuteMute" />
|
||||||
/// <seealso cref="MemberUpdateService.TickMemberDataAsync" />
|
/// <seealso cref="MemberUpdateService.TickMemberDataAsync" />
|
|
@ -1,5 +1,8 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -12,17 +15,14 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Gateway;
|
using Remora.Discord.Gateway;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the command to get the time taken for the gateway to respond to the last heartbeat: /ping
|
/// Handles the command to get the time taken for the gateway to respond to the last heartbeat: /ping
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class PingCommandGroup : CommandGroup
|
public class PingCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
private readonly DiscordGatewayClient _client;
|
private readonly DiscordGatewayClient _client;
|
|
@ -2,6 +2,9 @@ using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -14,24 +17,21 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
using Octobot.Parsers;
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Parsers;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles commands to manage reminders: /remind, /listremind, /delremind
|
/// Handles commands to manage reminders: /remind, /listremind, /delremind
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class RemindCommandGroup : CommandGroup
|
public class RemindCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private readonly IInteractionCommandContext _context;
|
private readonly IInteractionCommandContext _context;
|
||||||
private readonly IFeedbackService _feedback;
|
private readonly IFeedbackService _feedback;
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
private readonly IDiscordRestInteractionAPI _interactionApi;
|
|
||||||
private readonly IDiscordRestUserAPI _userApi;
|
private readonly IDiscordRestUserAPI _userApi;
|
||||||
|
private readonly IDiscordRestInteractionAPI _interactionApi;
|
||||||
|
|
||||||
public RemindCommandGroup(
|
public RemindCommandGroup(
|
||||||
IInteractionCommandContext context, GuildDataService guildData, IFeedbackService feedback,
|
IInteractionCommandContext context, GuildDataService guildData, IFeedbackService feedback,
|
||||||
|
@ -78,7 +78,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
||||||
return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), guildId, executor, bot, CancellationToken);
|
return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), guildId, executor, bot, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<Result> ListRemindersAsync(MemberData data, Snowflake guildId, IUser executor, IUser bot, CancellationToken ct = default)
|
private Task<Result> ListRemindersAsync(MemberData data, Snowflake guildId, IUser executor, IUser bot, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (data.Reminders.Count == 0)
|
if (data.Reminders.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
var reminder = data.Reminders[i];
|
var reminder = data.Reminders[i];
|
||||||
builder.AppendBulletPointLine(string.Format(Messages.ReminderPosition, Markdown.InlineCode((i + 1).ToString())))
|
builder.AppendBulletPointLine(string.Format(Messages.ReminderPosition, Markdown.InlineCode((i + 1).ToString())))
|
||||||
.AppendSubBulletPointLine(string.Format(Messages.ReminderText, reminder.Text))
|
.AppendSubBulletPointLine(string.Format(Messages.ReminderText, Markdown.InlineCode(reminder.Text)))
|
||||||
.AppendSubBulletPointLine(string.Format(Messages.ReminderTime, Markdown.Timestamp(reminder.At)))
|
.AppendSubBulletPointLine(string.Format(Messages.ReminderTime, Markdown.Timestamp(reminder.At)))
|
||||||
.AppendSubBulletPointLine(string.Format(Messages.DescriptionActionJumpToMessage, $"https://discord.com/channels/{guildId.Value}/{reminder.ChannelId}/{reminder.MessageId}"));
|
.AppendSubBulletPointLine(string.Format(Messages.DescriptionActionJumpToMessage, $"https://discord.com/channels/{guildId.Value}/{reminder.ChannelId}/{reminder.MessageId}"));
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
||||||
});
|
});
|
||||||
|
|
||||||
var builder = new StringBuilder()
|
var builder = new StringBuilder()
|
||||||
.AppendLine(MarkdownExtensions.Quote(text))
|
.AppendBulletPointLine(string.Format(Messages.ReminderText, Markdown.InlineCode(text)))
|
||||||
.AppendBulletPoint(string.Format(Messages.ReminderTime, Markdown.Timestamp(remindAt)));
|
.AppendBulletPoint(string.Format(Messages.ReminderTime, Markdown.Timestamp(remindAt)));
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
string.Format(Messages.ReminderCreated, executor.GetTag()), executor)
|
string.Format(Messages.ReminderCreated, executor.GetTag()), executor)
|
||||||
|
@ -279,7 +279,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
||||||
data.Reminders.RemoveAt(index);
|
data.Reminders.RemoveAt(index);
|
||||||
|
|
||||||
var builder = new StringBuilder()
|
var builder = new StringBuilder()
|
||||||
.AppendLine(MarkdownExtensions.Quote(oldReminder.Text))
|
.AppendBulletPointLine(string.Format(Messages.ReminderText, Markdown.InlineCode(oldReminder.Text)))
|
||||||
.AppendBulletPoint(string.Format(Messages.ReminderTime, Markdown.Timestamp(remindAt)));
|
.AppendBulletPoint(string.Format(Messages.ReminderTime, Markdown.Timestamp(remindAt)));
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
string.Format(Messages.ReminderEdited, executor.GetTag()), executor)
|
string.Format(Messages.ReminderEdited, executor.GetTag()), executor)
|
||||||
|
@ -309,7 +309,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
||||||
data.Reminders.RemoveAt(index);
|
data.Reminders.RemoveAt(index);
|
||||||
|
|
||||||
var builder = new StringBuilder()
|
var builder = new StringBuilder()
|
||||||
.AppendLine(MarkdownExtensions.Quote(value))
|
.AppendBulletPointLine(string.Format(Messages.ReminderText, Markdown.InlineCode(value)))
|
||||||
.AppendBulletPoint(string.Format(Messages.ReminderTime, Markdown.Timestamp(oldReminder.At)));
|
.AppendBulletPoint(string.Format(Messages.ReminderTime, Markdown.Timestamp(oldReminder.At)));
|
||||||
var embed = new EmbedBuilder().WithSmallTitle(
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
string.Format(Messages.ReminderEdited, executor.GetTag()), executor)
|
string.Format(Messages.ReminderEdited, executor.GetTag()), executor)
|
||||||
|
@ -353,7 +353,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<Result> DeleteReminderAsync(MemberData data, int index, IUser bot,
|
private Task<Result> DeleteReminderAsync(MemberData data, int index, IUser bot,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (index >= data.Reminders.Count)
|
if (index >= data.Reminders.Count)
|
||||||
{
|
{
|
||||||
|
@ -367,7 +367,7 @@ public sealed class RemindCommandGroup : CommandGroup
|
||||||
var reminder = data.Reminders[index];
|
var reminder = data.Reminders[index];
|
||||||
|
|
||||||
var description = new StringBuilder()
|
var description = new StringBuilder()
|
||||||
.AppendLine(MarkdownExtensions.Quote(reminder.Text))
|
.AppendBulletPointLine(string.Format(Messages.ReminderText, Markdown.InlineCode(reminder.Text)))
|
||||||
.AppendBulletPointLine(string.Format(Messages.ReminderTime, Markdown.Timestamp(reminder.At)));
|
.AppendBulletPointLine(string.Format(Messages.ReminderTime, Markdown.Timestamp(reminder.At)));
|
||||||
|
|
||||||
data.Reminders.RemoveAt(index);
|
data.Reminders.RemoveAt(index);
|
|
@ -3,6 +3,10 @@ using System.ComponentModel.DataAnnotations;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Data.Options;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -15,27 +19,23 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Data.Options;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the commands to list and modify per-guild settings: /settings and /settings list.
|
/// Handles the commands to list and modify per-guild settings: /settings and /settings list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class SettingsCommandGroup : CommandGroup
|
public class SettingsCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents all options as an array of objects implementing <see cref="IGuildOption" />.
|
/// Represents all options as an array of objects implementing <see cref="IOption" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// WARNING: If you update this array in any way, you must also update <see cref="AllOptionsEnum" /> and make sure
|
/// WARNING: If you update this array in any way, you must also update <see cref="AllOptionsEnum" /> and make sure
|
||||||
/// that the orders match.
|
/// that the orders match.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
private static readonly IGuildOption[] AllOptions =
|
private static readonly IOption[] AllOptions =
|
||||||
[
|
[
|
||||||
GuildSettings.Language,
|
GuildSettings.Language,
|
||||||
GuildSettings.WelcomeMessage,
|
GuildSettings.WelcomeMessage,
|
||||||
|
@ -199,30 +199,9 @@ public sealed class SettingsCommandGroup : CommandGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> EditSettingAsync(
|
private async Task<Result> EditSettingAsync(
|
||||||
IGuildOption option, string value, GuildData data, Snowflake channelId, IUser executor, IUser bot,
|
IOption option, string value, GuildData data, Snowflake channelId, IUser executor, IUser bot,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var equalsResult = option.ValueEquals(data.Settings, value);
|
|
||||||
if (!equalsResult.IsSuccess)
|
|
||||||
{
|
|
||||||
var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.SettingNotChanged, bot)
|
|
||||||
.WithDescription(equalsResult.Error.Message)
|
|
||||||
.WithColour(ColorsList.Red)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (equalsResult.Entity)
|
|
||||||
{
|
|
||||||
var failedEmbed = new EmbedBuilder().WithSmallTitle(Messages.SettingNotChanged, bot)
|
|
||||||
.WithDescription(Messages.SettingValueEquals)
|
|
||||||
.WithColour(ColorsList.Red)
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: ct);
|
|
||||||
}
|
|
||||||
|
|
||||||
var setResult = option.Set(data.Settings, value);
|
var setResult = option.Set(data.Settings, value);
|
||||||
if (!setResult.IsSuccess)
|
if (!setResult.IsSuccess)
|
||||||
{
|
{
|
||||||
|
@ -291,7 +270,7 @@ public sealed class SettingsCommandGroup : CommandGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> ResetSingleSettingAsync(JsonNode cfg, IUser bot,
|
private async Task<Result> ResetSingleSettingAsync(JsonNode cfg, IUser bot,
|
||||||
IGuildOption option, CancellationToken ct = default)
|
IOption option, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var resetResult = option.Reset(cfg);
|
var resetResult = option.Reset(cfg);
|
||||||
if (!resetResult.IsSuccess)
|
if (!resetResult.IsSuccess)
|
|
@ -2,6 +2,10 @@ using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Parsers;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Commands.Attributes;
|
using Remora.Commands.Attributes;
|
||||||
using Remora.Commands.Groups;
|
using Remora.Commands.Groups;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
@ -13,17 +17,14 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Commands;
|
namespace Octobot.Commands;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles info commands: /userinfo, /guildinfo.
|
/// Handles tool commands: /userinfo, /guildinfo, /random, /timestamp, /8ball.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class InfoCommandGroup : CommandGroup
|
public class ToolsCommandGroup : CommandGroup
|
||||||
{
|
{
|
||||||
private readonly ICommandContext _context;
|
private readonly ICommandContext _context;
|
||||||
private readonly IFeedbackService _feedback;
|
private readonly IFeedbackService _feedback;
|
||||||
|
@ -31,7 +32,7 @@ public sealed class InfoCommandGroup : CommandGroup
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
private readonly IDiscordRestUserAPI _userApi;
|
private readonly IDiscordRestUserAPI _userApi;
|
||||||
|
|
||||||
public InfoCommandGroup(
|
public ToolsCommandGroup(
|
||||||
ICommandContext context, IFeedbackService feedback,
|
ICommandContext context, IFeedbackService feedback,
|
||||||
GuildDataService guildData, IDiscordRestGuildAPI guildApi,
|
GuildDataService guildData, IDiscordRestGuildAPI guildApi,
|
||||||
IDiscordRestUserAPI userApi)
|
IDiscordRestUserAPI userApi)
|
||||||
|
@ -288,7 +289,7 @@ public sealed class InfoCommandGroup : CommandGroup
|
||||||
return await ShowGuildInfoAsync(bot, guild, CancellationToken);
|
return await ShowGuildInfoAsync(bot, guild, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<Result> ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct = default)
|
private Task<Result> ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var description = new StringBuilder().AppendLine($"## {guild.Name}");
|
var description = new StringBuilder().AppendLine($"## {guild.Name}");
|
||||||
|
|
||||||
|
@ -326,4 +327,235 @@ public sealed class InfoCommandGroup : CommandGroup
|
||||||
|
|
||||||
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A slash command that generates a random number using maximum and minimum numbers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="first">The first number used for randomization.</param>
|
||||||
|
/// <param name="second">The second number used for randomization. Default value: 0</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A feedback sending result which may or may not have succeeded.
|
||||||
|
/// </returns>
|
||||||
|
[Command("random")]
|
||||||
|
[DiscordDefaultDMPermission(false)]
|
||||||
|
[Description("Generates a random number")]
|
||||||
|
[UsedImplicitly]
|
||||||
|
public async Task<Result> ExecuteRandomAsync(
|
||||||
|
[Description("First number")] long first,
|
||||||
|
[Description("Second number (Default: 0)")]
|
||||||
|
long? second = null)
|
||||||
|
{
|
||||||
|
if (!_context.TryGetContextIDs(out var guildId, out _, out var executorId))
|
||||||
|
{
|
||||||
|
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
||||||
|
}
|
||||||
|
|
||||||
|
var executorResult = await _userApi.GetUserAsync(executorId, CancellationToken);
|
||||||
|
if (!executorResult.IsDefined(out var executor))
|
||||||
|
{
|
||||||
|
return ResultExtensions.FromError(executorResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _guildData.GetData(guildId, CancellationToken);
|
||||||
|
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
||||||
|
|
||||||
|
return await SendRandomNumberAsync(first, second, executor, CancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task<Result> SendRandomNumberAsync(long first, long? secondNullable,
|
||||||
|
IUser executor, CancellationToken ct)
|
||||||
|
{
|
||||||
|
const long secondDefault = 0;
|
||||||
|
var second = secondNullable ?? secondDefault;
|
||||||
|
|
||||||
|
var min = Math.Min(first, second);
|
||||||
|
var max = Math.Max(first, second);
|
||||||
|
|
||||||
|
var i = Random.Shared.NextInt64(min, max + 1);
|
||||||
|
|
||||||
|
var description = new StringBuilder().Append("# ").Append(i);
|
||||||
|
|
||||||
|
description.AppendLine().AppendBulletPoint(string.Format(
|
||||||
|
Messages.RandomMin, Markdown.InlineCode(min.ToString())));
|
||||||
|
if (secondNullable is null && first >= secondDefault)
|
||||||
|
{
|
||||||
|
description.Append(' ').Append(Messages.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
description.AppendLine().AppendBulletPoint(string.Format(
|
||||||
|
Messages.RandomMax, Markdown.InlineCode(max.ToString())));
|
||||||
|
if (secondNullable is null && first < secondDefault)
|
||||||
|
{
|
||||||
|
description.Append(' ').Append(Messages.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
var embedColor = ColorsList.Blue;
|
||||||
|
if (secondNullable is not null && min == max)
|
||||||
|
{
|
||||||
|
description.AppendLine().Append(Markdown.Italicise(Messages.RandomMinMaxSame));
|
||||||
|
embedColor = ColorsList.Red;
|
||||||
|
}
|
||||||
|
|
||||||
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
|
string.Format(Messages.RandomTitle, executor.GetTag()), executor)
|
||||||
|
.WithDescription(description.ToString())
|
||||||
|
.WithColour(embedColor)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly TimestampStyle[] AllStyles =
|
||||||
|
[
|
||||||
|
TimestampStyle.ShortDate,
|
||||||
|
TimestampStyle.LongDate,
|
||||||
|
TimestampStyle.ShortTime,
|
||||||
|
TimestampStyle.LongTime,
|
||||||
|
TimestampStyle.ShortDateTime,
|
||||||
|
TimestampStyle.LongDateTime,
|
||||||
|
TimestampStyle.RelativeTime
|
||||||
|
];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A slash command that shows the current timestamp with an optional offset in all styles supported by Discord.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stringOffset">The offset for the current timestamp.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A feedback sending result which may or may not have succeeded.
|
||||||
|
/// </returns>
|
||||||
|
[Command("timestamp")]
|
||||||
|
[DiscordDefaultDMPermission(false)]
|
||||||
|
[Description("Shows a timestamp in all styles")]
|
||||||
|
[UsedImplicitly]
|
||||||
|
public async Task<Result> ExecuteTimestampAsync(
|
||||||
|
[Description("Offset from current time")] [Option("offset")]
|
||||||
|
string? stringOffset = null)
|
||||||
|
{
|
||||||
|
if (!_context.TryGetContextIDs(out var guildId, out _, out var executorId))
|
||||||
|
{
|
||||||
|
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
||||||
|
}
|
||||||
|
|
||||||
|
var botResult = await _userApi.GetCurrentUserAsync(CancellationToken);
|
||||||
|
if (!botResult.IsDefined(out var bot))
|
||||||
|
{
|
||||||
|
return ResultExtensions.FromError(botResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
var executorResult = await _userApi.GetUserAsync(executorId, CancellationToken);
|
||||||
|
if (!executorResult.IsDefined(out var executor))
|
||||||
|
{
|
||||||
|
return ResultExtensions.FromError(executorResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _guildData.GetData(guildId, CancellationToken);
|
||||||
|
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
||||||
|
|
||||||
|
if (stringOffset is null)
|
||||||
|
{
|
||||||
|
return await SendTimestampAsync(null, executor, CancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
var parseResult = TimeSpanParser.TryParse(stringOffset);
|
||||||
|
if (!parseResult.IsDefined(out var offset))
|
||||||
|
{
|
||||||
|
var failedEmbed = new EmbedBuilder()
|
||||||
|
.WithSmallTitle(Messages.InvalidTimeSpan, bot)
|
||||||
|
.WithDescription(Messages.TimeSpanExample)
|
||||||
|
.WithColour(ColorsList.Red)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct: CancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await SendTimestampAsync(offset, executor, CancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task<Result> SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds();
|
||||||
|
|
||||||
|
var description = new StringBuilder().Append("# ").AppendLine(timestamp.ToString());
|
||||||
|
|
||||||
|
if (offset is not null)
|
||||||
|
{
|
||||||
|
description.AppendLine(string.Format(
|
||||||
|
Messages.TimestampOffset, Markdown.InlineCode(offset.ToString() ?? string.Empty))).AppendLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var markdownTimestamp in AllStyles.Select(style => Markdown.Timestamp(timestamp, style)))
|
||||||
|
{
|
||||||
|
description.AppendBulletPoint(Markdown.InlineCode(markdownTimestamp))
|
||||||
|
.Append(" → ").AppendLine(markdownTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
var embed = new EmbedBuilder().WithSmallTitle(
|
||||||
|
string.Format(Messages.TimestampTitle, executor.GetTag()), executor)
|
||||||
|
.WithDescription(description.ToString())
|
||||||
|
.WithColour(ColorsList.Blue)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A slash command that shows a random answer from the Magic 8-Ball.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="question">Unused input.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// The 8-Ball answers were taken from <a href="https://en.wikipedia.org/wiki/Magic_8_Ball#Possible_answers">Wikipedia</a>.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>
|
||||||
|
/// A feedback sending result which may or may not have succeeded.
|
||||||
|
/// </returns>
|
||||||
|
[Command("8ball")]
|
||||||
|
[DiscordDefaultDMPermission(false)]
|
||||||
|
[Description("Ask the Magic 8-Ball a question")]
|
||||||
|
[UsedImplicitly]
|
||||||
|
public async Task<Result> ExecuteEightBallAsync(
|
||||||
|
// let the user think he's actually asking the ball a question
|
||||||
|
[Description("Question to ask")] string question)
|
||||||
|
{
|
||||||
|
if (!_context.TryGetContextIDs(out var guildId, out _, out _))
|
||||||
|
{
|
||||||
|
return new ArgumentInvalidError(nameof(_context), "Unable to retrieve necessary IDs from command context");
|
||||||
|
}
|
||||||
|
|
||||||
|
var botResult = await _userApi.GetCurrentUserAsync(CancellationToken);
|
||||||
|
if (!botResult.IsDefined(out var bot))
|
||||||
|
{
|
||||||
|
return ResultExtensions.FromError(botResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _guildData.GetData(guildId, CancellationToken);
|
||||||
|
Messages.Culture = GuildSettings.Language.Get(data.Settings);
|
||||||
|
|
||||||
|
return await AnswerEightBallAsync(bot, CancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly string[] AnswerTypes =
|
||||||
|
[
|
||||||
|
"Positive", "Questionable", "Neutral", "Negative"
|
||||||
|
];
|
||||||
|
|
||||||
|
private Task<Result> AnswerEightBallAsync(IUser bot, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var typeNumber = Random.Shared.Next(0, 4);
|
||||||
|
var embedColor = typeNumber switch
|
||||||
|
{
|
||||||
|
0 => ColorsList.Blue,
|
||||||
|
1 => ColorsList.Green,
|
||||||
|
2 => ColorsList.Yellow,
|
||||||
|
3 => ColorsList.Red,
|
||||||
|
_ => throw new ArgumentOutOfRangeException(null, nameof(typeNumber))
|
||||||
|
};
|
||||||
|
|
||||||
|
var answer = $"EightBall{AnswerTypes[typeNumber]}{Random.Shared.Next(1, 6)}".Localized();
|
||||||
|
|
||||||
|
var embed = new EmbedBuilder().WithSmallTitle(answer, bot)
|
||||||
|
.WithColour(embedColor)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return _feedback.SendContextualEmbedResultAsync(embed, ct: ct);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data;
|
namespace Octobot.Data;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores information about a guild. This information is not accessible via the Discord API.
|
/// Stores information about a guild. This information is not accessible via the Discord API.
|
|
@ -1,8 +1,8 @@
|
||||||
|
using Octobot.Data.Options;
|
||||||
|
using Octobot.Responders;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using TeamOctolings.Octobot.Data.Options;
|
|
||||||
using TeamOctolings.Octobot.Responders;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data;
|
namespace Octobot.Data;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains all per-guild settings that can be set by a member
|
/// Contains all per-guild settings that can be set by a member
|
||||||
|
@ -22,7 +22,7 @@ public static class GuildSettings
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <seealso cref="GuildMemberJoinedResponder" />
|
/// <seealso cref="GuildMemberJoinedResponder" />
|
||||||
public static readonly GuildOption<string> WelcomeMessage = new("WelcomeMessage", "default");
|
public static readonly Option<string> WelcomeMessage = new("WelcomeMessage", "default");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls what message should be sent in <see cref="PublicFeedbackChannel" /> when a member leaves the guild.
|
/// Controls what message should be sent in <see cref="PublicFeedbackChannel" /> when a member leaves the guild.
|
||||||
|
@ -34,7 +34,7 @@ public static class GuildSettings
|
||||||
/// </list>
|
/// </list>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <seealso cref="GuildMemberLeftResponder" />
|
/// <seealso cref="GuildMemberLeftResponder" />
|
||||||
public static readonly GuildOption<string> LeaveMessage = new("LeaveMessage", "default");
|
public static readonly Option<string> LeaveMessage = new("LeaveMessage", "default");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Controls whether or not the <see cref="Messages.Ready" /> message should be sent
|
/// Controls whether or not the <see cref="Messages.Ready" /> message should be sent
|
|
@ -1,4 +1,4 @@
|
||||||
namespace TeamOctolings.Octobot.Data;
|
namespace Octobot.Data;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores information about a member
|
/// Stores information about a member
|
|
@ -1,7 +1,7 @@
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using TeamOctolings.Octobot.Commands;
|
using Octobot.Commands;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data.Options;
|
namespace Octobot.Data.Options;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents all options as enums.
|
/// Represents all options as enums.
|
|
@ -1,9 +1,9 @@
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data.Options;
|
namespace Octobot.Data.Options;
|
||||||
|
|
||||||
public sealed class BoolOption : GuildOption<bool>
|
public sealed class BoolOption : Option<bool>
|
||||||
{
|
{
|
||||||
public BoolOption(string name, bool defaultValue) : base(name, defaultValue) { }
|
public BoolOption(string name, bool defaultValue) : base(name, defaultValue) { }
|
||||||
|
|
||||||
|
@ -12,16 +12,6 @@ public sealed class BoolOption : GuildOption<bool>
|
||||||
return Get(settings) ? Messages.Yes : Messages.No;
|
return Get(settings) ? Messages.Yes : Messages.No;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Result<bool> ValueEquals(JsonNode settings, string value)
|
|
||||||
{
|
|
||||||
if (!TryParseBool(value, out var boolean))
|
|
||||||
{
|
|
||||||
return new ArgumentInvalidError(nameof(value), Messages.InvalidSettingValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Value(settings).Equals(boolean.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Result Set(JsonNode settings, string from)
|
public override Result Set(JsonNode settings, string from)
|
||||||
{
|
{
|
||||||
if (!TryParseBool(from, out var value))
|
if (!TryParseBool(from, out var value))
|
|
@ -1,13 +1,12 @@
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data.Options;
|
namespace Octobot.Data.Options;
|
||||||
|
|
||||||
public interface IGuildOption
|
public interface IOption
|
||||||
{
|
{
|
||||||
string Name { get; }
|
string Name { get; }
|
||||||
string Display(JsonNode settings);
|
string Display(JsonNode settings);
|
||||||
Result<bool> ValueEquals(JsonNode settings, string value);
|
|
||||||
Result Set(JsonNode settings, string from);
|
Result Set(JsonNode settings, string from);
|
||||||
Result Reset(JsonNode settings);
|
Result Reset(JsonNode settings);
|
||||||
}
|
}
|
|
@ -1,23 +1,25 @@
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data.Options;
|
namespace Octobot.Data.Options;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public sealed class LanguageOption : GuildOption<CultureInfo>
|
public sealed class LanguageOption : Option<CultureInfo>
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, CultureInfo> CultureInfoCache = new()
|
private static readonly Dictionary<string, CultureInfo> CultureInfoCache = new()
|
||||||
{
|
{
|
||||||
{ "en", new CultureInfo("en-US") },
|
{ "en", new CultureInfo("en-US") },
|
||||||
{ "ru", new CultureInfo("ru-RU") }
|
{ "ru", new CultureInfo("ru-RU") },
|
||||||
|
{ "mctaylors-ru", new CultureInfo("tt-RU") }
|
||||||
};
|
};
|
||||||
|
|
||||||
public LanguageOption(string name, string defaultValue) : base(name, CultureInfoCache[defaultValue]) { }
|
public LanguageOption(string name, string defaultValue) : base(name, CultureInfoCache[defaultValue]) { }
|
||||||
|
|
||||||
protected override string Value(JsonNode settings)
|
public override string Display(JsonNode settings)
|
||||||
{
|
{
|
||||||
return settings[Name]?.GetValue<string>() ?? "en";
|
return Markdown.InlineCode(settings[Name]?.GetValue<string>() ?? "en");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
|
@ -2,18 +2,18 @@ using System.Text.Json.Nodes;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data.Options;
|
namespace Octobot.Data.Options;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a per-guild option.
|
/// Represents an per-guild option.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The type of the option.</typeparam>
|
/// <typeparam name="T">The type of the option.</typeparam>
|
||||||
public class GuildOption<T> : IGuildOption
|
public class Option<T> : IOption
|
||||||
where T : notnull
|
where T : notnull
|
||||||
{
|
{
|
||||||
protected readonly T DefaultValue;
|
protected readonly T DefaultValue;
|
||||||
|
|
||||||
public GuildOption(string name, T defaultValue)
|
public Option(string name, T defaultValue)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
DefaultValue = defaultValue;
|
DefaultValue = defaultValue;
|
||||||
|
@ -21,19 +21,9 @@ public class GuildOption<T> : IGuildOption
|
||||||
|
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
protected virtual string Value(JsonNode settings)
|
|
||||||
{
|
|
||||||
return Get(settings).ToString() ?? throw new InvalidOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual string Display(JsonNode settings)
|
public virtual string Display(JsonNode settings)
|
||||||
{
|
{
|
||||||
return Markdown.InlineCode(Value(settings));
|
return Markdown.InlineCode(Get(settings).ToString() ?? throw new InvalidOperationException());
|
||||||
}
|
|
||||||
|
|
||||||
public virtual Result<bool> ValueEquals(JsonNode settings, string value)
|
|
||||||
{
|
|
||||||
return Value(settings).Equals(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
|
@ -1,13 +1,13 @@
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Octobot.Extensions;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data.Options;
|
namespace Octobot.Data.Options;
|
||||||
|
|
||||||
public sealed partial class SnowflakeOption : GuildOption<Snowflake>
|
public sealed partial class SnowflakeOption : Option<Snowflake>
|
||||||
{
|
{
|
||||||
public SnowflakeOption(string name) : base(name, 0UL.ToSnowflake()) { }
|
public SnowflakeOption(string name) : base(name, 0UL.ToSnowflake()) { }
|
||||||
|
|
|
@ -1,23 +1,13 @@
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
using Octobot.Parsers;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Parsers;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data.Options;
|
namespace Octobot.Data.Options;
|
||||||
|
|
||||||
public sealed class TimeSpanOption : GuildOption<TimeSpan>
|
public sealed class TimeSpanOption : Option<TimeSpan>
|
||||||
{
|
{
|
||||||
public TimeSpanOption(string name, TimeSpan defaultValue) : base(name, defaultValue) { }
|
public TimeSpanOption(string name, TimeSpan defaultValue) : base(name, defaultValue) { }
|
||||||
|
|
||||||
public override Result<bool> ValueEquals(JsonNode settings, string value)
|
|
||||||
{
|
|
||||||
if (!TimeSpanParser.TryParse(value).IsDefined(out var span))
|
|
||||||
{
|
|
||||||
return new ArgumentInvalidError(nameof(value), Messages.InvalidSettingValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Value(settings).Equals(span.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public override TimeSpan Get(JsonNode settings)
|
public override TimeSpan Get(JsonNode settings)
|
||||||
{
|
{
|
||||||
var property = settings[Name];
|
var property = settings[Name];
|
9
src/Data/Reminder.cs
Normal file
9
src/Data/Reminder.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Octobot.Data;
|
||||||
|
|
||||||
|
public struct Reminder
|
||||||
|
{
|
||||||
|
public DateTimeOffset At { get; init; }
|
||||||
|
public string Text { get; init; }
|
||||||
|
public ulong ChannelId { get; init; }
|
||||||
|
public ulong MessageId { get; init; }
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Data;
|
namespace Octobot.Data;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores information about scheduled events. This information is not provided by the Discord API.
|
/// Stores information about scheduled events. This information is not provided by the Discord API.
|
|
@ -5,19 +5,18 @@ using Remora.Discord.API.Objects;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class ChannelApiExtensions
|
public static class ChannelApiExtensions
|
||||||
{
|
{
|
||||||
public static async Task<Result> CreateMessageWithEmbedResultAsync(this IDiscordRestChannelAPI channelApi,
|
public static async Task<Result> CreateMessageWithEmbedResultAsync(this IDiscordRestChannelAPI channelApi,
|
||||||
Snowflake channelId, Optional<string> message = default, Optional<string> nonce = default,
|
Snowflake channelId, Optional<string> message = default, Optional<string> nonce = default,
|
||||||
Optional<bool> isTextToSpeech = default, Optional<Result<Embed>> embedResult = default,
|
Optional<bool> isTextToSpeech = default, Optional<Result<Embed>> embedResult = default,
|
||||||
Optional<IAllowedMentions> allowedMentions = default, Optional<IMessageReference> messageReference = default,
|
Optional<IAllowedMentions> allowedMentions = default, Optional<IMessageReference> messageRefenence = default,
|
||||||
Optional<IReadOnlyList<IMessageComponent>> components = default,
|
Optional<IReadOnlyList<IMessageComponent>> components = default,
|
||||||
Optional<IReadOnlyList<Snowflake>> stickerIds = default,
|
Optional<IReadOnlyList<Snowflake>> stickerIds = default,
|
||||||
Optional<IReadOnlyList<OneOf<FileData, IPartialAttachment>>> attachments = default,
|
Optional<IReadOnlyList<OneOf<FileData, IPartialAttachment>>> attachments = default,
|
||||||
Optional<MessageFlags> flags = default, Optional<bool> enforceNonce = default,
|
Optional<MessageFlags> flags = default, CancellationToken ct = default)
|
||||||
Optional<IPollCreateRequest> poll = default, CancellationToken ct = default)
|
|
||||||
{
|
{
|
||||||
if (!embedResult.IsDefined() || !embedResult.Value.IsDefined(out var embed))
|
if (!embedResult.IsDefined() || !embedResult.Value.IsDefined(out var embed))
|
||||||
{
|
{
|
||||||
|
@ -25,6 +24,6 @@ public static class ChannelApiExtensions
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Result)await channelApi.CreateMessageAsync(channelId, message, nonce, isTextToSpeech, new[] { embed },
|
return (Result)await channelApi.CreateMessageAsync(channelId, message, nonce, isTextToSpeech, new[] { embed },
|
||||||
allowedMentions, messageReference, components, stickerIds, attachments, flags, enforceNonce, poll, ct);
|
allowedMentions, messageRefenence, components, stickerIds, attachments, flags, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class CollectionExtensions
|
public static class CollectionExtensions
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
using Remora.Discord.Commands.Extensions;
|
using Remora.Discord.Commands.Extensions;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class CommandContextExtensions
|
public static class CommandContextExtensions
|
||||||
{
|
{
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiffPlex.DiffBuilder.Model;
|
using DiffPlex.DiffBuilder.Model;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class DiffPaneModelExtensions
|
public static class DiffPaneModelExtensions
|
||||||
{
|
{
|
|
@ -4,7 +4,7 @@ using Remora.Discord.API.Objects;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class EmbedBuilderExtensions
|
public static class EmbedBuilderExtensions
|
||||||
{
|
{
|
|
@ -3,7 +3,7 @@ using Remora.Discord.Commands.Feedback.Messages;
|
||||||
using Remora.Discord.Commands.Feedback.Services;
|
using Remora.Discord.Commands.Feedback.Services;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class FeedbackServiceExtensions
|
public static class FeedbackServiceExtensions
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class GuildScheduledEventExtensions
|
public static class GuildScheduledEventExtensions
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ public static class GuildScheduledEventExtensions
|
||||||
out string? location)
|
out string? location)
|
||||||
{
|
{
|
||||||
endTime = default;
|
endTime = default;
|
||||||
location = null;
|
location = default;
|
||||||
if (!scheduledEvent.EntityMetadata.AsOptional().IsDefined(out var metadata))
|
if (!scheduledEvent.EntityMetadata.AsOptional().IsDefined(out var metadata))
|
||||||
{
|
{
|
||||||
return new ArgumentNullError(nameof(scheduledEvent.EntityMetadata));
|
return new ArgumentNullError(nameof(scheduledEvent.EntityMetadata));
|
|
@ -1,7 +1,7 @@
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class LoggerExtensions
|
public static class LoggerExtensions
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ public static class LoggerExtensions
|
||||||
|
|
||||||
if (result.Error is ExceptionError exe)
|
if (result.Error is ExceptionError exe)
|
||||||
{
|
{
|
||||||
if (exe.Exception is OperationCanceledException)
|
if (exe.Exception is TaskCanceledException)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class MarkdownExtensions
|
public static class MarkdownExtensions
|
||||||
{
|
{
|
||||||
|
@ -13,16 +13,4 @@ public static class MarkdownExtensions
|
||||||
{
|
{
|
||||||
return $"- {text}";
|
return $"- {text}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Formats a string to use Markdown Quote formatting.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="text">The input text to format.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A markdown-formatted quote string.
|
|
||||||
/// </returns>
|
|
||||||
public static string Quote(string text)
|
|
||||||
{
|
|
||||||
return $"> {text}";
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class ResultExtensions
|
public static class ResultExtensions
|
||||||
{
|
{
|
||||||
|
@ -21,25 +21,21 @@ public static class ResultExtensions
|
||||||
return casted;
|
return casted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Conditional("DEBUG")]
|
||||||
private static void LogResultStackTrace(Result result)
|
private static void LogResultStackTrace(Result result)
|
||||||
{
|
{
|
||||||
if (result.IsSuccess || result.Error is ExceptionError { Exception: OperationCanceledException })
|
if (Octobot.StaticLogger is null || result.IsSuccess)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utility.StaticLogger is null)
|
Octobot.StaticLogger.LogError("{ErrorType}: {ErrorMessage}{NewLine}{StackTrace}",
|
||||||
{
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
Utility.StaticLogger.LogError("{ErrorType}: {ErrorMessage}{NewLine}{StackTrace}",
|
|
||||||
result.Error.GetType().FullName, result.Error.Message, Environment.NewLine, ConstructStackTrace());
|
result.Error.GetType().FullName, result.Error.Message, Environment.NewLine, ConstructStackTrace());
|
||||||
|
|
||||||
var inner = result.Inner;
|
var inner = result.Inner;
|
||||||
while (inner is { IsSuccess: false })
|
while (inner is { IsSuccess: false })
|
||||||
{
|
{
|
||||||
Utility.StaticLogger.LogError("Caused by: {ResultType}: {ResultMessage}",
|
Octobot.StaticLogger.LogError("Caused by: {ResultType}: {ResultMessage}",
|
||||||
inner.Error.GetType().FullName, inner.Error.Message);
|
inner.Error.GetType().FullName, inner.Error.Message);
|
||||||
|
|
||||||
inner = inner.Inner;
|
inner = inner.Inner;
|
|
@ -1,6 +1,6 @@
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class SnowflakeExtensions
|
public static class SnowflakeExtensions
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class StringBuilderExtensions
|
public static class StringBuilderExtensions
|
||||||
{
|
{
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class StringExtensions
|
public static class StringExtensions
|
||||||
{
|
{
|
|
@ -1,7 +1,7 @@
|
||||||
using Remora.Discord.API;
|
using Remora.Discord.API;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class UInt64Extensions
|
public static class UInt64Extensions
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Extensions;
|
namespace Octobot.Extensions;
|
||||||
|
|
||||||
public static class UserExtensions
|
public static class UserExtensions
|
||||||
{
|
{
|
File diff suppressed because it is too large
Load diff
|
@ -2,8 +2,13 @@ using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Attributes;
|
||||||
|
using Octobot.Commands.Events;
|
||||||
|
using Octobot.Services;
|
||||||
|
using Octobot.Services.Update;
|
||||||
using Remora.Discord.API.Abstractions.Gateway.Commands;
|
using Remora.Discord.API.Abstractions.Gateway.Commands;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
|
using Remora.Discord.API.Objects;
|
||||||
using Remora.Discord.Caching.Extensions;
|
using Remora.Discord.Caching.Extensions;
|
||||||
using Remora.Discord.Caching.Services;
|
using Remora.Discord.Caching.Services;
|
||||||
using Remora.Discord.Commands.Extensions;
|
using Remora.Discord.Commands.Extensions;
|
||||||
|
@ -11,20 +16,24 @@ using Remora.Discord.Commands.Services;
|
||||||
using Remora.Discord.Extensions.Extensions;
|
using Remora.Discord.Extensions.Extensions;
|
||||||
using Remora.Discord.Gateway;
|
using Remora.Discord.Gateway;
|
||||||
using Remora.Discord.Hosting.Extensions;
|
using Remora.Discord.Hosting.Extensions;
|
||||||
|
using Remora.Rest.Core;
|
||||||
using Serilog.Extensions.Logging;
|
using Serilog.Extensions.Logging;
|
||||||
using TeamOctolings.Octobot.Commands.Events;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
using TeamOctolings.Octobot.Services.Update;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot;
|
namespace Octobot;
|
||||||
|
|
||||||
public sealed class Program
|
public sealed class Octobot
|
||||||
{
|
{
|
||||||
|
public static readonly AllowedMentions NoMentions = new(
|
||||||
|
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());
|
||||||
|
|
||||||
|
[StaticCallersOnly]
|
||||||
|
public static ILogger<Octobot>? StaticLogger { get; private set; }
|
||||||
|
|
||||||
public static async Task Main(string[] args)
|
public static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
var host = CreateHostBuilder(args).UseConsoleLifetime().Build();
|
var host = CreateHostBuilder(args).UseConsoleLifetime().Build();
|
||||||
var services = host.Services;
|
var services = host.Services;
|
||||||
Utility.StaticLogger = services.GetRequiredService<ILogger<Program>>();
|
StaticLogger = services.GetRequiredService<ILogger<Octobot>>();
|
||||||
|
|
||||||
var slashService = services.GetRequiredService<SlashService>();
|
var slashService = services.GetRequiredService<SlashService>();
|
||||||
// Providing a guild ID to this call will result in command duplicates!
|
// Providing a guild ID to this call will result in command duplicates!
|
||||||
|
@ -39,7 +48,8 @@ public sealed class Program
|
||||||
private static IHostBuilder CreateHostBuilder(string[] args)
|
private static IHostBuilder CreateHostBuilder(string[] args)
|
||||||
{
|
{
|
||||||
return Host.CreateDefaultBuilder(args)
|
return Host.CreateDefaultBuilder(args)
|
||||||
.AddDiscordService(services =>
|
.AddDiscordService(
|
||||||
|
services =>
|
||||||
{
|
{
|
||||||
var configuration = services.GetRequiredService<IConfiguration>();
|
var configuration = services.GetRequiredService<IConfiguration>();
|
||||||
|
|
||||||
|
@ -48,29 +58,32 @@ public sealed class Program
|
||||||
"No bot token has been provided. Set the "
|
"No bot token has been provided. Set the "
|
||||||
+ "BOT_TOKEN environment variable to a valid token.");
|
+ "BOT_TOKEN environment variable to a valid token.");
|
||||||
}
|
}
|
||||||
).ConfigureServices((_, services) =>
|
).ConfigureServices(
|
||||||
|
(_, services) =>
|
||||||
{
|
{
|
||||||
services.Configure<DiscordGatewayClientOptions>(options =>
|
services.Configure<DiscordGatewayClientOptions>(
|
||||||
{
|
options =>
|
||||||
options.Intents |= GatewayIntents.MessageContents
|
{
|
||||||
| GatewayIntents.GuildMembers
|
options.Intents |= GatewayIntents.MessageContents
|
||||||
| GatewayIntents.GuildPresences
|
| GatewayIntents.GuildMembers
|
||||||
| GatewayIntents.GuildScheduledEvents;
|
| GatewayIntents.GuildPresences
|
||||||
});
|
| GatewayIntents.GuildScheduledEvents;
|
||||||
services.Configure<CacheSettings>(cSettings =>
|
});
|
||||||
{
|
services.Configure<CacheSettings>(
|
||||||
cSettings.SetDefaultAbsoluteExpiration(TimeSpan.FromHours(1));
|
cSettings =>
|
||||||
cSettings.SetDefaultSlidingExpiration(TimeSpan.FromMinutes(30));
|
{
|
||||||
cSettings.SetAbsoluteExpiration<IMessage>(TimeSpan.FromDays(7));
|
cSettings.SetDefaultAbsoluteExpiration(TimeSpan.FromHours(1));
|
||||||
cSettings.SetSlidingExpiration<IMessage>(TimeSpan.FromDays(7));
|
cSettings.SetDefaultSlidingExpiration(TimeSpan.FromMinutes(30));
|
||||||
});
|
cSettings.SetAbsoluteExpiration<IMessage>(TimeSpan.FromDays(7));
|
||||||
|
cSettings.SetSlidingExpiration<IMessage>(TimeSpan.FromDays(7));
|
||||||
|
});
|
||||||
|
|
||||||
services.AddTransient<IConfigurationBuilder, ConfigurationBuilder>()
|
services.AddTransient<IConfigurationBuilder, ConfigurationBuilder>()
|
||||||
// Init
|
// Init
|
||||||
.AddDiscordCaching()
|
.AddDiscordCaching()
|
||||||
.AddDiscordCommands(true, false)
|
.AddDiscordCommands(true, false)
|
||||||
.AddRespondersFromAssembly(typeof(Program).Assembly)
|
.AddRespondersFromAssembly(typeof(Octobot).Assembly)
|
||||||
.AddCommandGroupsFromAssembly(typeof(Program).Assembly)
|
.AddCommandGroupsFromAssembly(typeof(Octobot).Assembly)
|
||||||
// Slash command event handlers
|
// Slash command event handlers
|
||||||
.AddPreparationErrorEvent<LoggingPreparationErrorEvent>()
|
.AddPreparationErrorEvent<LoggingPreparationErrorEvent>()
|
||||||
.AddPostExecutionEvent<ErrorLoggingPostExecutionEvent>()
|
.AddPostExecutionEvent<ErrorLoggingPostExecutionEvent>()
|
||||||
|
@ -83,13 +96,14 @@ public sealed class Program
|
||||||
.AddHostedService<ScheduledEventUpdateService>()
|
.AddHostedService<ScheduledEventUpdateService>()
|
||||||
.AddHostedService<SongUpdateService>();
|
.AddHostedService<SongUpdateService>();
|
||||||
}
|
}
|
||||||
).ConfigureLogging(c => c.AddConsole()
|
).ConfigureLogging(
|
||||||
.AddFile("Logs/Octobot-{Date}.log",
|
c => c.AddConsole()
|
||||||
outputTemplate: "{Timestamp:o} [{Level:u4}] {Message} {NewLine}{Exception}")
|
.AddFile("Logs/Octobot-{Date}.log",
|
||||||
.AddFilter("System.Net.Http.HttpClient.*.LogicalHandler", LogLevel.Warning)
|
outputTemplate: "{Timestamp:o} [{Level:u4}] {Message} {NewLine}{Exception}")
|
||||||
.AddFilter("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning)
|
.AddFilter("System.Net.Http.HttpClient.*.LogicalHandler", LogLevel.Warning)
|
||||||
.AddFilter<SerilogLoggerProvider>("System.Net.Http.HttpClient.*.LogicalHandler", LogLevel.Warning)
|
.AddFilter("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning)
|
||||||
.AddFilter<SerilogLoggerProvider>("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning)
|
.AddFilter<SerilogLoggerProvider>("System.Net.Http.HttpClient.*.LogicalHandler", LogLevel.Warning)
|
||||||
|
.AddFilter<SerilogLoggerProvider>("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ using JetBrains.Annotations;
|
||||||
using Remora.Commands.Parsers;
|
using Remora.Commands.Parsers;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Parsers;
|
namespace Octobot.Parsers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses <see cref="TimeSpan"/>s.
|
/// Parses <see cref="TimeSpan"/>s.
|
|
@ -1,5 +1,8 @@
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
|
@ -8,18 +11,15 @@ using Remora.Discord.API.Objects;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Gateway.Responders;
|
using Remora.Discord.Gateway.Responders;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Responders;
|
namespace Octobot.Responders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles sending a <see cref="Ready" /> message to a guild that has just initialized if that guild
|
/// Handles sending a <see cref="Ready" /> message to a guild that has just initialized if that guild
|
||||||
/// has <see cref="GuildSettings.ReceiveStartupMessages" /> enabled
|
/// has <see cref="GuildSettings.ReceiveStartupMessages" /> enabled
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class GuildLoadedResponder : IResponder<IGuildCreate>
|
public class GuildLoadedResponder : IResponder<IGuildCreate>
|
||||||
{
|
{
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
|
@ -94,7 +94,7 @@ public sealed class GuildLoadedResponder : IResponder<IGuildCreate>
|
||||||
GuildSettings.PrivateFeedbackChannel.Get(cfg), embedResult: embed, ct: ct);
|
GuildSettings.PrivateFeedbackChannel.Get(cfg), embedResult: embed, ct: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendDataLoadFailed(IGuild guild, GuildData data, IUser bot, CancellationToken ct = default)
|
private async Task<Result> SendDataLoadFailed(IGuild guild, GuildData data, IUser bot, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var channelResult = await _utility.GetEmergencyFeedbackChannel(guild, data, ct);
|
var channelResult = await _utility.GetEmergencyFeedbackChannel(guild, data, ct);
|
||||||
if (!channelResult.IsDefined(out var channel))
|
if (!channelResult.IsDefined(out var channel))
|
||||||
|
@ -114,12 +114,12 @@ public sealed class GuildLoadedResponder : IResponder<IGuildCreate>
|
||||||
BuildInfo.IsDirty
|
BuildInfo.IsDirty
|
||||||
? Messages.ButtonDirty
|
? Messages.ButtonDirty
|
||||||
: Messages.ButtonReportIssue,
|
: Messages.ButtonReportIssue,
|
||||||
new PartialEmoji(Name: "\u26a0\ufe0f"), // 'WARNING SIGN' (U+26A0)
|
new PartialEmoji(Name: "⚠️"),
|
||||||
URL: BuildInfo.IssuesUrl,
|
URL: BuildInfo.IssuesUrl,
|
||||||
IsDisabled: BuildInfo.IsDirty
|
IsDisabled: BuildInfo.IsDirty
|
||||||
);
|
);
|
||||||
|
|
||||||
return await _channelApi.CreateMessageWithEmbedResultAsync(channel, embedResult: errorEmbed,
|
return await _channelApi.CreateMessageWithEmbedResultAsync(channel, embedResult: errorEmbed,
|
||||||
components: new[] { new ActionRowComponent([issuesButton]) }, ct: ct);
|
components: new[] { new ActionRowComponent(new[] { issuesButton }) }, ct: ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Gateway.Responders;
|
using Remora.Discord.Gateway.Responders;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Responders;
|
namespace Octobot.Responders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles sending a guild's <see cref="GuildSettings.WelcomeMessage" /> if one is set.
|
/// Handles sending a guild's <see cref="GuildSettings.WelcomeMessage" /> if one is set.
|
||||||
|
@ -18,7 +18,7 @@ namespace TeamOctolings.Octobot.Responders;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="GuildSettings.WelcomeMessage" />
|
/// <seealso cref="GuildSettings.WelcomeMessage" />
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class GuildMemberJoinedResponder : IResponder<IGuildMemberAdd>
|
public class GuildMemberJoinedResponder : IResponder<IGuildMemberAdd>
|
||||||
{
|
{
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
private readonly IDiscordRestGuildAPI _guildApi;
|
private readonly IDiscordRestGuildAPI _guildApi;
|
||||||
|
@ -77,11 +77,11 @@ public sealed class GuildMemberJoinedResponder : IResponder<IGuildMemberAdd>
|
||||||
|
|
||||||
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
||||||
GuildSettings.WelcomeMessagesChannel.Get(cfg), embedResult: embed,
|
GuildSettings.WelcomeMessagesChannel.Get(cfg), embedResult: embed,
|
||||||
allowedMentions: Utility.NoMentions, ct: ct);
|
allowedMentions: Octobot.NoMentions, ct: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> TryReturnRolesAsync(
|
private async Task<Result> TryReturnRolesAsync(
|
||||||
JsonNode cfg, MemberData memberData, Snowflake guildId, Snowflake userId, CancellationToken ct = default)
|
JsonNode cfg, MemberData memberData, Snowflake guildId, Snowflake userId, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (!GuildSettings.ReturnRolesOnRejoin.Get(cfg))
|
if (!GuildSettings.ReturnRolesOnRejoin.Get(cfg))
|
||||||
{
|
{
|
|
@ -1,21 +1,21 @@
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Gateway.Responders;
|
using Remora.Discord.Gateway.Responders;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Responders;
|
namespace Octobot.Responders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles sending a guild's <see cref="GuildSettings.LeaveMessage" /> if one is set.
|
/// Handles sending a guild's <see cref="GuildSettings.LeaveMessage" /> if one is set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="GuildSettings.LeaveMessage" />
|
/// <seealso cref="GuildSettings.LeaveMessage" />
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class GuildMemberLeftResponder : IResponder<IGuildMemberRemove>
|
public class GuildMemberLeftResponder : IResponder<IGuildMemberRemove>
|
||||||
{
|
{
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
private readonly IDiscordRestGuildAPI _guildApi;
|
private readonly IDiscordRestGuildAPI _guildApi;
|
||||||
|
@ -36,9 +36,13 @@ public sealed class GuildMemberLeftResponder : IResponder<IGuildMemberRemove>
|
||||||
var cfg = data.Settings;
|
var cfg = data.Settings;
|
||||||
|
|
||||||
var memberData = data.GetOrCreateMemberData(user.ID);
|
var memberData = data.GetOrCreateMemberData(user.ID);
|
||||||
if (memberData.BannedUntil is not null || memberData.Kicked
|
if (memberData.BannedUntil is not null || memberData.Kicked)
|
||||||
|| GuildSettings.WelcomeMessagesChannel.Get(cfg).Empty()
|
{
|
||||||
|| GuildSettings.LeaveMessage.Get(cfg) is "off" or "disable" or "disabled")
|
return Result.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GuildSettings.WelcomeMessagesChannel.Get(cfg).Empty()
|
||||||
|
|| GuildSettings.LeaveMessage.Get(cfg) is "off" or "disable" or "disabled")
|
||||||
{
|
{
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
@ -63,6 +67,6 @@ public sealed class GuildMemberLeftResponder : IResponder<IGuildMemberRemove>
|
||||||
|
|
||||||
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
||||||
GuildSettings.WelcomeMessagesChannel.Get(cfg), embedResult: embed,
|
GuildSettings.WelcomeMessagesChannel.Get(cfg), embedResult: embed,
|
||||||
allowedMentions: Utility.NoMentions, ct: ct);
|
allowedMentions: Octobot.NoMentions, ct: ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,18 +1,18 @@
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||||
using Remora.Discord.Gateway.Responders;
|
using Remora.Discord.Gateway.Responders;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Responders;
|
namespace Octobot.Responders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles removing guild ID from <see cref="GuildData" /> if the guild becomes unavailable.
|
/// Handles removing guild ID from <see cref="GuildData" /> if the guild becomes unavailable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class GuildUnloadedResponder : IResponder<IGuildDelete>
|
public class GuildUnloadedResponder : IResponder<IGuildDelete>
|
||||||
{
|
{
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
private readonly ILogger<GuildUnloadedResponder> _logger;
|
private readonly ILogger<GuildUnloadedResponder> _logger;
|
|
@ -1,5 +1,8 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
|
@ -7,18 +10,15 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Discord.Gateway.Responders;
|
using Remora.Discord.Gateway.Responders;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Responders;
|
namespace Octobot.Responders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles logging the contents of a deleted message and the user who deleted the message
|
/// Handles logging the contents of a deleted message and the user who deleted the message
|
||||||
/// to a guild's <see cref="GuildSettings.PrivateFeedbackChannel" /> if one is set.
|
/// to a guild's <see cref="GuildSettings.PrivateFeedbackChannel" /> if one is set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class MessageDeletedResponder : IResponder<IMessageDelete>
|
public class MessageDeletedResponder : IResponder<IMessageDelete>
|
||||||
{
|
{
|
||||||
private readonly IDiscordRestAuditLogAPI _auditLogApi;
|
private readonly IDiscordRestAuditLogAPI _auditLogApi;
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
|
@ -66,10 +66,10 @@ public sealed class MessageDeletedResponder : IResponder<IMessageDelete>
|
||||||
return ResultExtensions.FromError(auditLogResult);
|
return ResultExtensions.FromError(auditLogResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
var deleterResult = Result<IUser>.FromSuccess(message.Author);
|
var auditLog = auditLogPage.AuditLogEntries.Single();
|
||||||
|
|
||||||
var auditLog = auditLogPage.AuditLogEntries.SingleOrDefault();
|
var deleterResult = Result<IUser>.FromSuccess(message.Author);
|
||||||
if (auditLog is { UserID: not null }
|
if (auditLog.UserID is not null
|
||||||
&& auditLog.Options.Value.ChannelID == gatewayEvent.ChannelID
|
&& auditLog.Options.Value.ChannelID == gatewayEvent.ChannelID
|
||||||
&& DateTimeOffset.UtcNow.Subtract(auditLog.ID.Timestamp).TotalSeconds <= 2)
|
&& DateTimeOffset.UtcNow.Subtract(auditLog.ID.Timestamp).TotalSeconds <= 2)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,6 @@ public sealed class MessageDeletedResponder : IResponder<IMessageDelete>
|
||||||
|
|
||||||
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
||||||
GuildSettings.PrivateFeedbackChannel.Get(cfg), embedResult: embed,
|
GuildSettings.PrivateFeedbackChannel.Get(cfg), embedResult: embed,
|
||||||
allowedMentions: Utility.NoMentions, ct: ct);
|
allowedMentions: Octobot.NoMentions, ct: ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DiffPlex.DiffBuilder;
|
using DiffPlex.DiffBuilder;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Octobot.Services;
|
||||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
|
@ -9,18 +12,15 @@ using Remora.Discord.Caching.Services;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Gateway.Responders;
|
using Remora.Discord.Gateway.Responders;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
using TeamOctolings.Octobot.Services;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Responders;
|
namespace Octobot.Responders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles logging the difference between an edited message's old and new content
|
/// Handles logging the difference between an edited message's old and new content
|
||||||
/// to a guild's <see cref="GuildSettings.PrivateFeedbackChannel" /> if one is set.
|
/// to a guild's <see cref="GuildSettings.PrivateFeedbackChannel" /> if one is set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class MessageEditedResponder : IResponder<IMessageUpdate>
|
public class MessageEditedResponder : IResponder<IMessageUpdate>
|
||||||
{
|
{
|
||||||
private readonly CacheService _cacheService;
|
private readonly CacheService _cacheService;
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
|
@ -36,29 +36,40 @@ public sealed class MessageEditedResponder : IResponder<IMessageUpdate>
|
||||||
|
|
||||||
public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default)
|
public async Task<Result> RespondAsync(IMessageUpdate gatewayEvent, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
|
if (!gatewayEvent.ID.IsDefined(out var messageId))
|
||||||
|
{
|
||||||
|
return new ArgumentNullError(nameof(gatewayEvent.ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gatewayEvent.ChannelID.IsDefined(out var channelId))
|
||||||
|
{
|
||||||
|
return new ArgumentNullError(nameof(gatewayEvent.ChannelID));
|
||||||
|
}
|
||||||
|
|
||||||
if (!gatewayEvent.GuildID.IsDefined(out var guildId)
|
if (!gatewayEvent.GuildID.IsDefined(out var guildId)
|
||||||
|| !gatewayEvent.EditedTimestamp.HasValue
|
|| !gatewayEvent.Author.IsDefined(out var author)
|
||||||
|| gatewayEvent.Author.IsBot.OrDefault(false))
|
|| !gatewayEvent.EditedTimestamp.IsDefined(out var timestamp)
|
||||||
|
|| !gatewayEvent.Content.IsDefined(out var newContent))
|
||||||
{
|
{
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg = await _guildData.GetSettings(guildId, ct);
|
var cfg = await _guildData.GetSettings(guildId, ct);
|
||||||
if (GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
|
if (author.IsBot.OrDefault(false) || GuildSettings.PrivateFeedbackChannel.Get(cfg).Empty())
|
||||||
{
|
{
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cacheKey = new KeyHelpers.MessageCacheKey(gatewayEvent.ChannelID, gatewayEvent.ID);
|
var cacheKey = new KeyHelpers.MessageCacheKey(channelId, messageId);
|
||||||
var messageResult = await _cacheService.TryGetValueAsync<IMessage>(
|
var messageResult = await _cacheService.TryGetValueAsync<IMessage>(
|
||||||
cacheKey, ct);
|
cacheKey, ct);
|
||||||
if (!messageResult.IsDefined(out var message))
|
if (!messageResult.IsDefined(out var message))
|
||||||
{
|
{
|
||||||
_ = _channelApi.GetChannelMessageAsync(gatewayEvent.ChannelID, gatewayEvent.ID, ct);
|
_ = _channelApi.GetChannelMessageAsync(channelId, messageId, ct);
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.Content == gatewayEvent.Content)
|
if (message.Content == newContent)
|
||||||
{
|
{
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
@ -72,27 +83,27 @@ public sealed class MessageEditedResponder : IResponder<IMessageUpdate>
|
||||||
// We don't need to await this since the result is not needed
|
// We don't need to await this since the result is not needed
|
||||||
// NOTE: Because this is not awaited, there may be a race condition depending on how fast clients are able to edit their messages
|
// NOTE: Because this is not awaited, there may be a race condition depending on how fast clients are able to edit their messages
|
||||||
// NOTE: Awaiting this might not even solve this if the same responder is called asynchronously
|
// NOTE: Awaiting this might not even solve this if the same responder is called asynchronously
|
||||||
_ = _channelApi.GetChannelMessageAsync(gatewayEvent.ChannelID, gatewayEvent.ID, ct);
|
_ = _channelApi.GetChannelMessageAsync(channelId, messageId, ct);
|
||||||
|
|
||||||
var diff = InlineDiffBuilder.Diff(message.Content, gatewayEvent.Content);
|
var diff = InlineDiffBuilder.Diff(message.Content, newContent);
|
||||||
|
|
||||||
Messages.Culture = GuildSettings.Language.Get(cfg);
|
Messages.Culture = GuildSettings.Language.Get(cfg);
|
||||||
|
|
||||||
var builder = new StringBuilder()
|
var builder = new StringBuilder()
|
||||||
.AppendLine(diff.AsMarkdown())
|
.AppendLine(diff.AsMarkdown())
|
||||||
.AppendLine(string.Format(Messages.DescriptionActionJumpToMessage,
|
.AppendLine(string.Format(Messages.DescriptionActionJumpToMessage,
|
||||||
$"https://discord.com/channels/{guildId}/{gatewayEvent.ChannelID}/{gatewayEvent.ID}")
|
$"https://discord.com/channels/{guildId}/{channelId}/{messageId}")
|
||||||
);
|
);
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithSmallTitle(string.Format(Messages.CachedMessageEdited, message.Author.GetTag()), message.Author)
|
.WithSmallTitle(string.Format(Messages.CachedMessageEdited, message.Author.GetTag()), message.Author)
|
||||||
.WithDescription(builder.ToString())
|
.WithDescription(builder.ToString())
|
||||||
.WithTimestamp(gatewayEvent.EditedTimestamp.Value)
|
.WithTimestamp(timestamp.Value)
|
||||||
.WithColour(ColorsList.Yellow)
|
.WithColour(ColorsList.Yellow)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
||||||
GuildSettings.PrivateFeedbackChannel.Get(cfg), embedResult: embed,
|
GuildSettings.PrivateFeedbackChannel.Get(cfg), embedResult: embed,
|
||||||
allowedMentions: Utility.NoMentions, ct: ct);
|
allowedMentions: Octobot.NoMentions, ct: ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,13 +5,13 @@ using Remora.Discord.Gateway.Responders;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Responders;
|
namespace Octobot.Responders;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles sending replies to easter egg messages.
|
/// Handles sending replies to easter egg messages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class MessageCreateResponder : IResponder<IMessageCreate>
|
public class MessageCreateResponder : IResponder<IMessageCreate>
|
||||||
{
|
{
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
|
|
|
@ -1,39 +1,44 @@
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
|
using Remora.Discord.Commands.Conditions;
|
||||||
|
using Remora.Discord.Commands.Results;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Services;
|
namespace Octobot.Services;
|
||||||
|
|
||||||
public sealed class AccessControlService
|
public sealed class AccessControlService
|
||||||
{
|
{
|
||||||
private readonly GuildDataService _data;
|
private readonly GuildDataService _data;
|
||||||
private readonly IDiscordRestGuildAPI _guildApi;
|
private readonly IDiscordRestGuildAPI _guildApi;
|
||||||
|
private readonly RequireDiscordPermissionCondition _permission;
|
||||||
private readonly IDiscordRestUserAPI _userApi;
|
private readonly IDiscordRestUserAPI _userApi;
|
||||||
|
|
||||||
public AccessControlService(GuildDataService data, IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi)
|
public AccessControlService(GuildDataService data, IDiscordRestGuildAPI guildApi, IDiscordRestUserAPI userApi,
|
||||||
|
RequireDiscordPermissionCondition permission)
|
||||||
{
|
{
|
||||||
_data = data;
|
_data = data;
|
||||||
_guildApi = guildApi;
|
_guildApi = guildApi;
|
||||||
_userApi = userApi;
|
_userApi = userApi;
|
||||||
|
_permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CheckPermission(IEnumerable<IRole> roles, GuildData data, MemberData memberData,
|
private async Task<Result<bool>> CheckPermissionAsync(GuildData data, Snowflake memberId, IGuildMember member,
|
||||||
DiscordPermission permission)
|
DiscordPermission permission, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var moderatorRole = GuildSettings.ModeratorRole.Get(data.Settings);
|
var moderatorRole = GuildSettings.ModeratorRole.Get(data.Settings);
|
||||||
if (!moderatorRole.Empty() && memberData.Roles.Contains(moderatorRole.Value))
|
var result = await _permission.CheckAsync(new RequireDiscordPermissionAttribute([permission]), member, ct);
|
||||||
|
|
||||||
|
if (result.Error is not null and not PermissionDeniedError)
|
||||||
{
|
{
|
||||||
return true;
|
return Result<bool>.FromError(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return roles
|
var hasPermission = result.IsSuccess;
|
||||||
.Where(r => memberData.Roles.Contains(r.ID.Value))
|
return hasPermission || (!moderatorRole.Empty() &&
|
||||||
.Any(r =>
|
data.GetOrCreateMemberData(memberId).Roles.Contains(moderatorRole.Value));
|
||||||
r.Permissions.HasPermission(permission)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -62,21 +67,28 @@ public sealed class AccessControlService
|
||||||
return Result<string?>.FromSuccess($"UserCannot{action}Themselves".Localized());
|
return Result<string?>.FromSuccess($"UserCannot{action}Themselves".Localized());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var botResult = await _userApi.GetCurrentUserAsync(ct);
|
||||||
|
if (!botResult.IsDefined(out var bot))
|
||||||
|
{
|
||||||
|
return Result<string?>.FromError(botResult);
|
||||||
|
}
|
||||||
|
|
||||||
var guildResult = await _guildApi.GetGuildAsync(guildId, ct: ct);
|
var guildResult = await _guildApi.GetGuildAsync(guildId, ct: ct);
|
||||||
if (!guildResult.IsDefined(out var guild))
|
if (!guildResult.IsDefined(out var guild))
|
||||||
{
|
{
|
||||||
return Result<string?>.FromError(guildResult);
|
return Result<string?>.FromError(guildResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (interacterId == guild.OwnerID)
|
var targetMemberResult = await _guildApi.GetGuildMemberAsync(guildId, targetId, ct);
|
||||||
|
if (!targetMemberResult.IsDefined(out var targetMember))
|
||||||
{
|
{
|
||||||
return Result<string?>.FromSuccess(null);
|
return Result<string?>.FromSuccess(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var botResult = await _userApi.GetCurrentUserAsync(ct);
|
var botMemberResult = await _guildApi.GetGuildMemberAsync(guildId, bot.ID, ct);
|
||||||
if (!botResult.IsDefined(out var bot))
|
if (!botMemberResult.IsDefined(out var botMember))
|
||||||
{
|
{
|
||||||
return Result<string?>.FromError(botResult);
|
return Result<string?>.FromError(botMemberResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
var rolesResult = await _guildApi.GetGuildRolesAsync(guildId, ct);
|
var rolesResult = await _guildApi.GetGuildRolesAsync(guildId, ct);
|
||||||
|
@ -85,46 +97,63 @@ public sealed class AccessControlService
|
||||||
return Result<string?>.FromError(rolesResult);
|
return Result<string?>.FromError(rolesResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = await _data.GetData(guildId, ct);
|
|
||||||
var targetData = data.GetOrCreateMemberData(targetId);
|
|
||||||
var botData = data.GetOrCreateMemberData(bot.ID);
|
|
||||||
|
|
||||||
if (interacterId is null)
|
if (interacterId is null)
|
||||||
{
|
{
|
||||||
return CheckInteractions(action, guild, roles, targetData, botData, botData);
|
return CheckInteractions(action, guild, roles, targetMember, botMember, botMember);
|
||||||
}
|
}
|
||||||
|
|
||||||
var interacterData = data.GetOrCreateMemberData(interacterId.Value);
|
var interacterResult = await _guildApi.GetGuildMemberAsync(guildId, interacterId.Value, ct);
|
||||||
var hasPermission = CheckPermission(roles, data, interacterData,
|
if (!interacterResult.IsDefined(out var interacter))
|
||||||
|
{
|
||||||
|
return Result<string?>.FromError(interacterResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = await _data.GetData(guildId, ct);
|
||||||
|
|
||||||
|
var permissionResult = await CheckPermissionAsync(data, interacterId.Value, interacter,
|
||||||
action switch
|
action switch
|
||||||
{
|
{
|
||||||
"Ban" => DiscordPermission.BanMembers,
|
"Ban" => DiscordPermission.BanMembers,
|
||||||
"Kick" => DiscordPermission.KickMembers,
|
"Kick" => DiscordPermission.KickMembers,
|
||||||
"Mute" or "Unmute" => DiscordPermission.ModerateMembers,
|
"Mute" or "Unmute" => DiscordPermission.ModerateMembers,
|
||||||
_ => throw new Exception()
|
_ => throw new Exception()
|
||||||
});
|
}, ct);
|
||||||
|
if (!permissionResult.IsDefined(out var hasPermission))
|
||||||
|
{
|
||||||
|
return Result<string?>.FromError(permissionResult);
|
||||||
|
}
|
||||||
|
|
||||||
return hasPermission
|
return hasPermission
|
||||||
? CheckInteractions(action, guild, roles, targetData, botData, interacterData)
|
? CheckInteractions(action, guild, roles, targetMember, botMember, interacter)
|
||||||
: Result<string?>.FromSuccess($"UserCannot{action}Members".Localized());
|
: Result<string?>.FromSuccess($"UserCannot{action}Members".Localized());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Result<string?> CheckInteractions(
|
private static Result<string?> CheckInteractions(
|
||||||
string action, IGuild guild, IReadOnlyList<IRole> roles, MemberData targetData, MemberData botData,
|
string action, IGuild guild, IReadOnlyList<IRole> roles, IGuildMember targetMember, IGuildMember botMember,
|
||||||
MemberData interacterData)
|
IGuildMember interacter)
|
||||||
{
|
{
|
||||||
if (botData.Id == targetData.Id)
|
if (!targetMember.User.IsDefined(out var targetUser))
|
||||||
|
{
|
||||||
|
return new ArgumentNullError(nameof(targetMember.User));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!interacter.User.IsDefined(out var interacterUser))
|
||||||
|
{
|
||||||
|
return new ArgumentNullError(nameof(interacter.User));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (botMember.User == targetMember.User)
|
||||||
{
|
{
|
||||||
return Result<string?>.FromSuccess($"UserCannot{action}Bot".Localized());
|
return Result<string?>.FromSuccess($"UserCannot{action}Bot".Localized());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetData.Id == guild.OwnerID)
|
if (targetUser.ID == guild.OwnerID)
|
||||||
{
|
{
|
||||||
return Result<string?>.FromSuccess($"UserCannot{action}Owner".Localized());
|
return Result<string?>.FromSuccess($"UserCannot{action}Owner".Localized());
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetRoles = roles.Where(r => targetData.Roles.Contains(r.ID.Value)).ToList();
|
var targetRoles = roles.Where(r => targetMember.Roles.Contains(r.ID)).ToList();
|
||||||
var botRoles = roles.Where(r => botData.Roles.Contains(r.ID.Value));
|
var botRoles = roles.Where(r => botMember.Roles.Contains(r.ID));
|
||||||
|
|
||||||
var targetBotRoleDiff = targetRoles.MaxOrDefault(r => r.Position) - botRoles.MaxOrDefault(r => r.Position);
|
var targetBotRoleDiff = targetRoles.MaxOrDefault(r => r.Position) - botRoles.MaxOrDefault(r => r.Position);
|
||||||
if (targetBotRoleDiff >= 0)
|
if (targetBotRoleDiff >= 0)
|
||||||
|
@ -132,7 +161,12 @@ public sealed class AccessControlService
|
||||||
return Result<string?>.FromSuccess($"BotCannot{action}Target".Localized());
|
return Result<string?>.FromSuccess($"BotCannot{action}Target".Localized());
|
||||||
}
|
}
|
||||||
|
|
||||||
var interacterRoles = roles.Where(r => interacterData.Roles.Contains(r.ID.Value));
|
if (interacterUser.ID == guild.OwnerID)
|
||||||
|
{
|
||||||
|
return Result<string?>.FromSuccess(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
var interacterRoles = roles.Where(r => interacter.Roles.Contains(r.ID));
|
||||||
var targetInteracterRoleDiff
|
var targetInteracterRoleDiff
|
||||||
= targetRoles.MaxOrDefault(r => r.Position) - interacterRoles.MaxOrDefault(r => r.Position);
|
= targetRoles.MaxOrDefault(r => r.Position) - interacterRoles.MaxOrDefault(r => r.Position);
|
||||||
return targetInteracterRoleDiff < 0
|
return targetInteracterRoleDiff < 0
|
186
src/Services/GuildDataService.cs
Normal file
186
src/Services/GuildDataService.cs
Normal file
|
@ -0,0 +1,186 @@
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Remora.Rest.Core;
|
||||||
|
|
||||||
|
namespace Octobot.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles saving, loading, initializing and providing <see cref="GuildData" />.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class GuildDataService : BackgroundService
|
||||||
|
{
|
||||||
|
private readonly ConcurrentDictionary<Snowflake, GuildData> _datas = new();
|
||||||
|
private readonly ILogger<GuildDataService> _logger;
|
||||||
|
|
||||||
|
public GuildDataService(ILogger<GuildDataService> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task StopAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
base.StopAsync(ct);
|
||||||
|
return SaveAsync(ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task SaveAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
var tasks = new List<Task>();
|
||||||
|
var datas = _datas.Values.ToArray();
|
||||||
|
foreach (var data in datas.Where(data => !data.DataLoadFailed))
|
||||||
|
{
|
||||||
|
tasks.Add(SerializeObjectSafelyAsync(data.Settings, data.SettingsPath, ct));
|
||||||
|
tasks.Add(SerializeObjectSafelyAsync(data.ScheduledEvents, data.ScheduledEventsPath, ct));
|
||||||
|
|
||||||
|
var memberDatas = data.MemberData.Values.ToArray();
|
||||||
|
tasks.AddRange(memberDatas.Select(memberData =>
|
||||||
|
SerializeObjectSafelyAsync(memberData, $"{data.MemberDataPath}/{memberData.Id}.json", ct)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.WhenAll(tasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task SerializeObjectSafelyAsync<T>(T obj, string path, CancellationToken ct)
|
||||||
|
{
|
||||||
|
var tempFilePath = path + ".tmp";
|
||||||
|
await using (var tempFileStream = File.Create(tempFilePath))
|
||||||
|
{
|
||||||
|
await JsonSerializer.SerializeAsync(tempFileStream, obj, cancellationToken: ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
File.Copy(tempFilePath, path, true);
|
||||||
|
File.Delete(tempFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task ExecuteAsync(CancellationToken ct)
|
||||||
|
{
|
||||||
|
using var timer = new PeriodicTimer(TimeSpan.FromMinutes(5));
|
||||||
|
|
||||||
|
while (await timer.WaitForNextTickAsync(ct))
|
||||||
|
{
|
||||||
|
await SaveAsync(ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<GuildData> GetData(Snowflake guildId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return _datas.TryGetValue(guildId, out var data) ? data : await InitializeData(guildId, ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<GuildData> InitializeData(Snowflake guildId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
var path = $"GuildData/{guildId}";
|
||||||
|
var memberDataPath = $"{path}/MemberData";
|
||||||
|
var settingsPath = $"{path}/Settings.json";
|
||||||
|
var scheduledEventsPath = $"{path}/ScheduledEvents.json";
|
||||||
|
|
||||||
|
MigrateGuildData(guildId, path);
|
||||||
|
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
|
||||||
|
if (!File.Exists(settingsPath))
|
||||||
|
{
|
||||||
|
await File.WriteAllTextAsync(settingsPath, "{}", ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.Exists(scheduledEventsPath))
|
||||||
|
{
|
||||||
|
await File.WriteAllTextAsync(scheduledEventsPath, "{}", ct);
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataLoadFailed = false;
|
||||||
|
|
||||||
|
await using var settingsStream = File.OpenRead(settingsPath);
|
||||||
|
JsonNode? jsonSettings = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jsonSettings = await JsonNode.ParseAsync(settingsStream, cancellationToken: ct);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "Guild settings load failed: {Path}", settingsPath);
|
||||||
|
dataLoadFailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
await using var eventsStream = File.OpenRead(scheduledEventsPath);
|
||||||
|
Dictionary<ulong, ScheduledEventData>? events = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
events = await JsonSerializer.DeserializeAsync<Dictionary<ulong, ScheduledEventData>>(
|
||||||
|
eventsStream, cancellationToken: ct);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "Guild scheduled events load failed: {Path}", scheduledEventsPath);
|
||||||
|
dataLoadFailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var memberData = new Dictionary<ulong, MemberData>();
|
||||||
|
foreach (var dataFileInfo in Directory.CreateDirectory(memberDataPath).GetFiles())
|
||||||
|
{
|
||||||
|
await using var dataStream = dataFileInfo.OpenRead();
|
||||||
|
MemberData? data;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
data = await JsonSerializer.DeserializeAsync<MemberData>(dataStream, cancellationToken: ct);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "Member data load failed: {MemberDataPath}/{FileName}", memberDataPath,
|
||||||
|
dataFileInfo.Name);
|
||||||
|
dataLoadFailed = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
memberData.Add(data.Id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
var finalData = new GuildData(
|
||||||
|
jsonSettings ?? new JsonObject(), settingsPath,
|
||||||
|
events ?? new Dictionary<ulong, ScheduledEventData>(), scheduledEventsPath,
|
||||||
|
memberData, memberDataPath,
|
||||||
|
dataLoadFailed);
|
||||||
|
|
||||||
|
_datas.TryAdd(guildId, finalData);
|
||||||
|
|
||||||
|
return finalData;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MigrateGuildData(Snowflake guildId, string newPath)
|
||||||
|
{
|
||||||
|
var oldPath = $"{guildId}";
|
||||||
|
|
||||||
|
if (Directory.Exists(oldPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory($"{newPath}/..");
|
||||||
|
Directory.Move(oldPath, newPath);
|
||||||
|
|
||||||
|
_logger.LogInformation("Moved guild data to separate folder: \"{OldPath}\" -> \"{NewPath}\"", oldPath,
|
||||||
|
newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<JsonNode> GetSettings(Snowflake guildId, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return (await GetData(guildId, ct)).Settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICollection<Snowflake> GetGuildIds()
|
||||||
|
{
|
||||||
|
return _datas.Keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UnloadGuildData(Snowflake id)
|
||||||
|
{
|
||||||
|
return _datas.TryRemove(id, out _);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,16 +2,16 @@ using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Services.Update;
|
namespace Octobot.Services.Update;
|
||||||
|
|
||||||
public sealed partial class MemberUpdateService : BackgroundService
|
public sealed partial class MemberUpdateService : BackgroundService
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> TickMemberDatasAsync(Snowflake guildId, CancellationToken ct = default)
|
private async Task<Result> TickMemberDatasAsync(Snowflake guildId, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var guildData = await _guildData.GetData(guildId, ct);
|
var guildData = await _guildData.GetData(guildId, ct);
|
||||||
var defaultRole = GuildSettings.DefaultRole.Get(guildData.Settings);
|
var defaultRole = GuildSettings.DefaultRole.Get(guildData.Settings);
|
||||||
|
@ -79,7 +79,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
||||||
|
|
||||||
private async Task<Result> TickMemberDataAsync(Snowflake guildId, GuildData guildData, Snowflake defaultRole,
|
private async Task<Result> TickMemberDataAsync(Snowflake guildId, GuildData guildData, Snowflake defaultRole,
|
||||||
MemberData data,
|
MemberData data,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
var failedResults = new List<Result>();
|
var failedResults = new List<Result>();
|
||||||
var id = data.Id.ToSnowflake();
|
var id = data.Id.ToSnowflake();
|
||||||
|
@ -144,7 +144,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> TryAutoUnbanAsync(
|
private async Task<Result> TryAutoUnbanAsync(
|
||||||
Snowflake guildId, Snowflake id, MemberData data, CancellationToken ct = default)
|
Snowflake guildId, Snowflake id, MemberData data, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (data.BannedUntil is null || DateTimeOffset.UtcNow <= data.BannedUntil)
|
if (data.BannedUntil is null || DateTimeOffset.UtcNow <= data.BannedUntil)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> TryAutoUnmuteAsync(
|
private async Task<Result> TryAutoUnmuteAsync(
|
||||||
Snowflake guildId, Snowflake id, MemberData data, CancellationToken ct = default)
|
Snowflake guildId, Snowflake id, MemberData data, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (data.MutedUntil is null || DateTimeOffset.UtcNow <= data.MutedUntil)
|
if (data.MutedUntil is null || DateTimeOffset.UtcNow <= data.MutedUntil)
|
||||||
{
|
{
|
||||||
|
@ -188,7 +188,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> FilterNicknameAsync(Snowflake guildId, IUser user, IGuildMember member,
|
private async Task<Result> FilterNicknameAsync(Snowflake guildId, IUser user, IGuildMember member,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
var currentNickname = member.Nickname.IsDefined(out var nickname)
|
var currentNickname = member.Nickname.IsDefined(out var nickname)
|
||||||
? nickname
|
? nickname
|
||||||
|
@ -226,7 +226,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
||||||
private static partial Regex IllegalChars();
|
private static partial Regex IllegalChars();
|
||||||
|
|
||||||
private async Task<Result> TickReminderAsync(Reminder reminder, IUser user, MemberData data, Snowflake guildId,
|
private async Task<Result> TickReminderAsync(Reminder reminder, IUser user, MemberData data, Snowflake guildId,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (DateTimeOffset.UtcNow < reminder.At)
|
if (DateTimeOffset.UtcNow < reminder.At)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +234,7 @@ public sealed partial class MemberUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
var builder = new StringBuilder()
|
var builder = new StringBuilder()
|
||||||
.AppendLine(MarkdownExtensions.Quote(reminder.Text))
|
.AppendBulletPointLine(string.Format(Messages.DescriptionReminder, Markdown.InlineCode(reminder.Text)))
|
||||||
.AppendBulletPointLine(string.Format(Messages.DescriptionActionJumpToMessage,
|
.AppendBulletPointLine(string.Format(Messages.DescriptionActionJumpToMessage,
|
||||||
$"https://discord.com/channels/{guildId.Value}/{reminder.ChannelId}/{reminder.MessageId}"));
|
$"https://discord.com/channels/{guildId.Value}/{reminder.ChannelId}/{reminder.MessageId}"));
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.API.Objects;
|
using Remora.Discord.API.Objects;
|
||||||
|
@ -8,10 +10,8 @@ using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Services.Update;
|
namespace Octobot.Services.Update;
|
||||||
|
|
||||||
public sealed class ScheduledEventUpdateService : BackgroundService
|
public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> TickScheduledEventsAsync(Snowflake guildId, CancellationToken ct = default)
|
private async Task<Result> TickScheduledEventsAsync(Snowflake guildId, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var failedResults = new List<Result>();
|
var failedResults = new List<Result>();
|
||||||
var data = await _guildData.GetData(guildId, ct);
|
var data = await _guildData.GetData(guildId, ct);
|
||||||
|
@ -133,7 +133,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
|
|
||||||
private async Task<Result> TickScheduledEventAsync(
|
private async Task<Result> TickScheduledEventAsync(
|
||||||
Snowflake guildId, GuildData data, IGuildScheduledEvent scheduledEvent, ScheduledEventData eventData,
|
Snowflake guildId, GuildData data, IGuildScheduledEvent scheduledEvent, ScheduledEventData eventData,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (GuildSettings.AutoStartEvents.Get(data.Settings)
|
if (GuildSettings.AutoStartEvents.Get(data.Settings)
|
||||||
&& DateTimeOffset.UtcNow >= scheduledEvent.ScheduledStartTime
|
&& DateTimeOffset.UtcNow >= scheduledEvent.ScheduledStartTime
|
||||||
|
@ -160,7 +160,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> AutoStartEventAsync(
|
private async Task<Result> AutoStartEventAsync(
|
||||||
Snowflake guildId, IGuildScheduledEvent scheduledEvent, CancellationToken ct = default)
|
Snowflake guildId, IGuildScheduledEvent scheduledEvent, CancellationToken ct)
|
||||||
{
|
{
|
||||||
return (Result)await _eventApi.ModifyGuildScheduledEventAsync(
|
return (Result)await _eventApi.ModifyGuildScheduledEventAsync(
|
||||||
guildId, scheduledEvent.ID,
|
guildId, scheduledEvent.ID,
|
||||||
|
@ -223,13 +223,13 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
var button = new ButtonComponent(
|
var button = new ButtonComponent(
|
||||||
ButtonComponentStyle.Link,
|
ButtonComponentStyle.Link,
|
||||||
Messages.ButtonOpenEventInfo,
|
Messages.ButtonOpenEventInfo,
|
||||||
new PartialEmoji(Name: "\ud83d\udccb"), // 'CLIPBOARD' (U+1F4CB)
|
new PartialEmoji(Name: "📋"),
|
||||||
URL: $"https://discord.com/events/{scheduledEvent.GuildID}/{scheduledEvent.ID}"
|
URL: $"https://discord.com/events/{scheduledEvent.GuildID}/{scheduledEvent.ID}"
|
||||||
);
|
);
|
||||||
|
|
||||||
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
return await _channelApi.CreateMessageWithEmbedResultAsync(
|
||||||
GuildSettings.EventNotificationChannel.Get(settings), roleMention, embedResult: embed,
|
GuildSettings.EventNotificationChannel.Get(settings), roleMention, embedResult: embed,
|
||||||
components: new[] { new ActionRowComponent([button]) }, ct: ct);
|
components: new[] { new ActionRowComponent(new[] { button }) }, ct: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Result<string> GetExternalScheduledEventCreatedEmbedDescription(
|
private static Result<string> GetExternalScheduledEventCreatedEmbedDescription(
|
||||||
|
@ -319,7 +319,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendScheduledEventCompletedMessage(ScheduledEventData eventData, GuildData data,
|
private async Task<Result> SendScheduledEventCompletedMessage(ScheduledEventData eventData, GuildData data,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
||||||
{
|
{
|
||||||
|
@ -351,7 +351,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendScheduledEventCancelledMessage(ScheduledEventData eventData, GuildData data,
|
private async Task<Result> SendScheduledEventCancelledMessage(ScheduledEventData eventData, GuildData data,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
||||||
{
|
{
|
||||||
|
@ -405,7 +405,7 @@ public sealed class ScheduledEventUpdateService : BackgroundService
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendEarlyEventNotificationAsync(
|
private async Task<Result> SendEarlyEventNotificationAsync(
|
||||||
IGuildScheduledEvent scheduledEvent, GuildData data, CancellationToken ct = default)
|
IGuildScheduledEvent scheduledEvent, GuildData data, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
if (GuildSettings.EventNotificationChannel.Get(data.Settings).Empty())
|
||||||
{
|
{
|
|
@ -4,7 +4,7 @@ using Remora.Discord.API.Gateway.Commands;
|
||||||
using Remora.Discord.API.Objects;
|
using Remora.Discord.API.Objects;
|
||||||
using Remora.Discord.Gateway;
|
using Remora.Discord.Gateway;
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot.Services.Update;
|
namespace Octobot.Services.Update;
|
||||||
|
|
||||||
public sealed class SongUpdateService : BackgroundService
|
public sealed class SongUpdateService : BackgroundService
|
||||||
{
|
{
|
||||||
|
@ -29,19 +29,10 @@ public sealed class SongUpdateService : BackgroundService
|
||||||
("Callie", "Bomb Rush Blush", new TimeSpan(0, 2, 18)),
|
("Callie", "Bomb Rush Blush", new TimeSpan(0, 2, 18)),
|
||||||
("Turquoise October", "Octoling Rendezvous", new TimeSpan(0, 1, 57)),
|
("Turquoise October", "Octoling Rendezvous", new TimeSpan(0, 1, 57)),
|
||||||
("Damp Socks feat. Off the Hook", "Tentacle to the Metal", new TimeSpan(0, 2, 51)),
|
("Damp Socks feat. Off the Hook", "Tentacle to the Metal", new TimeSpan(0, 2, 51)),
|
||||||
("Off the Hook feat. Dedf1sh", "Spectrum Obligato ~ Ebb & Flow (Out of Order)", new TimeSpan(0, 4, 30)),
|
("Off the Hook", "Fly Octo Fly ~ Ebb & Flow (Octo)", new TimeSpan(0, 3, 5))
|
||||||
("Dedf1sh feat. Off the Hook", "#47 onward", new TimeSpan(0, 4, 40)),
|
|
||||||
("Free Association", "EchΘ Θnslaught", new TimeSpan(0, 2, 52)),
|
|
||||||
("Off the Hook", "Short Order", new TimeSpan(0, 3, 36)),
|
|
||||||
("Deep Cut", "Fins in the Air", new TimeSpan(0, 3, 1))
|
|
||||||
];
|
];
|
||||||
|
|
||||||
private static readonly (string Author, string Name, TimeSpan Duration)[] SpecialSongList =
|
private readonly List<Activity> _activityList = [new Activity("with Remora.Discord", ActivityType.Game)];
|
||||||
[
|
|
||||||
("Squid Sisters", "Maritime Memory", new TimeSpan(0, 2, 47))
|
|
||||||
];
|
|
||||||
|
|
||||||
private readonly List<Activity> _activityList = [new("with Remora.Discord", ActivityType.Game)];
|
|
||||||
|
|
||||||
private readonly DiscordGatewayClient _client;
|
private readonly DiscordGatewayClient _client;
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
|
@ -63,33 +54,19 @@ public sealed class SongUpdateService : BackgroundService
|
||||||
|
|
||||||
while (!ct.IsCancellationRequested)
|
while (!ct.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
var nextSong = NextSong();
|
var nextSong = SongList[_nextSongIndex];
|
||||||
_activityList[0] = new Activity($"{nextSong.Name} / {nextSong.Author}",
|
_activityList[0] = new Activity($"{nextSong.Name} / {nextSong.Author}",
|
||||||
ActivityType.Listening);
|
ActivityType.Listening);
|
||||||
_client.SubmitCommand(
|
_client.SubmitCommand(
|
||||||
new UpdatePresence(
|
new UpdatePresence(
|
||||||
UserStatus.Online, false, DateTimeOffset.UtcNow, _activityList));
|
UserStatus.Online, false, DateTimeOffset.UtcNow, _activityList));
|
||||||
|
_nextSongIndex++;
|
||||||
|
if (_nextSongIndex >= SongList.Length)
|
||||||
|
{
|
||||||
|
_nextSongIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
await Task.Delay(nextSong.Duration, ct);
|
await Task.Delay(nextSong.Duration, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private (string Author, string Name, TimeSpan Duration) NextSong()
|
|
||||||
{
|
|
||||||
var today = DateTime.Today;
|
|
||||||
// Discontinuation of Online Services for Nintendo Wii U
|
|
||||||
if (today.Day is 8 or 9 && today.Month is 4)
|
|
||||||
{
|
|
||||||
return SpecialSongList[0]; // Maritime Memory / Squid Sisters
|
|
||||||
}
|
|
||||||
|
|
||||||
var nextSong = SongList[_nextSongIndex];
|
|
||||||
_nextSongIndex++;
|
|
||||||
if (_nextSongIndex >= SongList.Length)
|
|
||||||
{
|
|
||||||
_nextSongIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nextSong;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,19 +1,16 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using Microsoft.Extensions.Logging;
|
using Octobot.Data;
|
||||||
|
using Octobot.Extensions;
|
||||||
using Remora.Discord.API.Abstractions.Objects;
|
using Remora.Discord.API.Abstractions.Objects;
|
||||||
using Remora.Discord.API.Abstractions.Rest;
|
using Remora.Discord.API.Abstractions.Rest;
|
||||||
using Remora.Discord.API.Objects;
|
|
||||||
using Remora.Discord.Extensions.Embeds;
|
using Remora.Discord.Extensions.Embeds;
|
||||||
using Remora.Discord.Extensions.Formatting;
|
using Remora.Discord.Extensions.Formatting;
|
||||||
using Remora.Rest.Core;
|
using Remora.Rest.Core;
|
||||||
using Remora.Results;
|
using Remora.Results;
|
||||||
using TeamOctolings.Octobot.Attributes;
|
|
||||||
using TeamOctolings.Octobot.Data;
|
|
||||||
using TeamOctolings.Octobot.Extensions;
|
|
||||||
|
|
||||||
namespace TeamOctolings.Octobot;
|
namespace Octobot.Services;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides utility methods that cannot be transformed to extension methods because they require usage
|
/// Provides utility methods that cannot be transformed to extension methods because they require usage
|
||||||
|
@ -21,9 +18,6 @@ namespace TeamOctolings.Octobot;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class Utility
|
public sealed class Utility
|
||||||
{
|
{
|
||||||
public static readonly AllowedMentions NoMentions = new(
|
|
||||||
Array.Empty<MentionType>(), Array.Empty<Snowflake>(), Array.Empty<Snowflake>());
|
|
||||||
|
|
||||||
private readonly IDiscordRestChannelAPI _channelApi;
|
private readonly IDiscordRestChannelAPI _channelApi;
|
||||||
private readonly IDiscordRestGuildScheduledEventAPI _eventApi;
|
private readonly IDiscordRestGuildScheduledEventAPI _eventApi;
|
||||||
private readonly IDiscordRestGuildAPI _guildApi;
|
private readonly IDiscordRestGuildAPI _guildApi;
|
||||||
|
@ -36,9 +30,6 @@ public sealed class Utility
|
||||||
_guildApi = guildApi;
|
_guildApi = guildApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StaticCallersOnly]
|
|
||||||
public static ILogger<Program>? StaticLogger { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the string mentioning the <see cref="GuildSettings.EventNotificationRole" /> and event subscribers related to
|
/// Gets the string mentioning the <see cref="GuildSettings.EventNotificationRole" /> and event subscribers related to
|
||||||
/// a scheduled
|
/// a scheduled
|
||||||
|
@ -67,8 +58,8 @@ public sealed class Utility
|
||||||
builder.Append($"{Mention.Role(role)} ");
|
builder.Append($"{Mention.Role(role)} ");
|
||||||
}
|
}
|
||||||
|
|
||||||
builder = subscribers.Where(subscriber =>
|
builder = subscribers.Where(
|
||||||
!data.GetOrCreateMemberData(subscriber.User.ID).Roles.Contains(role.Value))
|
subscriber => !data.GetOrCreateMemberData(subscriber.User.ID).Roles.Contains(role.Value))
|
||||||
.Aggregate(builder, (current, subscriber) => current.Append($"{Mention.User(subscriber.User)} "));
|
.Aggregate(builder, (current, subscriber) => current.Append($"{Mention.User(subscriber.User)} "));
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
@ -125,7 +116,7 @@ public sealed class Utility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Result<Snowflake>> GetEmergencyFeedbackChannel(IGuild guild, GuildData data, CancellationToken ct = default)
|
public async Task<Result<Snowflake>> GetEmergencyFeedbackChannel(IGuild guild, GuildData data, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var privateFeedback = GuildSettings.PrivateFeedbackChannel.Get(data.Settings);
|
var privateFeedback = GuildSettings.PrivateFeedbackChannel.Get(data.Settings);
|
||||||
if (!privateFeedback.Empty())
|
if (!privateFeedback.Empty())
|
Reference in a new issue