mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
Merge branch 'v4' into v5
This commit is contained in:
@@ -5,16 +5,12 @@
|
|||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<IncludeBuildOutput>false</IncludeBuildOutput>
|
<IncludeBuildOutput>false</IncludeBuildOutput>
|
||||||
<IsRoslynComponent>true</IsRoslynComponent>
|
<IsRoslynComponent>true</IsRoslynComponent>
|
||||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<RootNamespace>NadekoBot.Generators</RootNamespace>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" PrivateAssets="all" GeneratePathProperty="true" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" PrivateAssets="all" GeneratePathProperty="true" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
@@ -65,7 +65,10 @@ public partial class Administration
|
|||||||
_localization.SetGuildCulture(ctx.Guild, ci);
|
_localization.SetGuildCulture(ctx.Guild, ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
await ReplyConfirmLocalizedAsync(strs.lang_set(Format.Bold(ci.ToString()), Format.Bold(ci.NativeName)));
|
var nativeName = ci.NativeName;
|
||||||
|
if (ci.Name == "ts-TS")
|
||||||
|
nativeName = _supportedLocales[ci.Name];
|
||||||
|
await ReplyConfirmLocalizedAsync(strs.lang_set(Format.Bold(ci.ToString()), Format.Bold(nativeName)));
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
@@ -284,6 +284,24 @@ public partial class Xp
|
|||||||
await ReplyErrorLocalizedAsync(strs.club_admin_perms);
|
await ReplyErrorLocalizedAsync(strs.club_admin_perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[Priority(1)]
|
||||||
|
public Task ClubReject(IUser user)
|
||||||
|
=> ClubReject(user.ToString());
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[Priority(0)]
|
||||||
|
public async Task ClubReject([Leftover] string userName)
|
||||||
|
{
|
||||||
|
var result = _service.RejectApplication(ctx.User.Id, userName, out var discordUser);
|
||||||
|
if (result == ClubDenyResult.Rejected)
|
||||||
|
await ReplyConfirmLocalizedAsync(strs.club_rejected(Format.Bold(discordUser.ToString())));
|
||||||
|
else if(result == ClubDenyResult.NoSuchApplicant)
|
||||||
|
await ReplyErrorLocalizedAsync(strs.club_accept_invalid_applicant);
|
||||||
|
else if(result == ClubDenyResult.NotOwnerOrAdmin)
|
||||||
|
await ReplyErrorLocalizedAsync(strs.club_admin_perms);
|
||||||
|
}
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
public async Task ClubLeave()
|
public async Task ClubLeave()
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,6 @@ public class ClubService : INService, IClubService
|
|||||||
_httpFactory = httpFactory;
|
_httpFactory = httpFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<ClubCreateResult> CreateClubAsync(IUser user, string clubName)
|
public async Task<ClubCreateResult> CreateClubAsync(IUser user, string clubName)
|
||||||
{
|
{
|
||||||
if (!CheckClubName(clubName))
|
if (!CheckClubName(clubName))
|
||||||
@@ -143,7 +142,7 @@ public class ClubService : INService, IClubService
|
|||||||
|
|
||||||
//user banned or a member of a club, or already applied,
|
//user banned or a member of a club, or already applied,
|
||||||
// or doesn't min minumum level requirement, can't apply
|
// or doesn't min minumum level requirement, can't apply
|
||||||
if (du.Club is not null)
|
if (du.ClubId is not null)
|
||||||
return ClubApplyResult.AlreadyInAClub;
|
return ClubApplyResult.AlreadyInAClub;
|
||||||
|
|
||||||
if (club.Bans.Any(x => x.UserId == du.Id))
|
if (club.Bans.Any(x => x.UserId == du.Id))
|
||||||
@@ -190,6 +189,26 @@ public class ClubService : INService, IClubService
|
|||||||
return ClubAcceptResult.Accepted;
|
return ClubAcceptResult.Accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser)
|
||||||
|
{
|
||||||
|
discordUser = null;
|
||||||
|
using var uow = _db.GetDbContext();
|
||||||
|
var club = uow.Clubs.GetByOwnerOrAdmin(clubOwnerUserId);
|
||||||
|
if (club is null)
|
||||||
|
return ClubDenyResult.NotOwnerOrAdmin;
|
||||||
|
|
||||||
|
var applicant =
|
||||||
|
club.Applicants.FirstOrDefault(x => x.User.ToString().ToUpperInvariant() == userName.ToUpperInvariant());
|
||||||
|
if (applicant is null)
|
||||||
|
return ClubDenyResult.NoSuchApplicant;
|
||||||
|
|
||||||
|
club.Applicants.Remove(applicant);
|
||||||
|
|
||||||
|
discordUser = applicant.User;
|
||||||
|
uow.SaveChanges();
|
||||||
|
return ClubDenyResult.Rejected;
|
||||||
|
}
|
||||||
|
|
||||||
public ClubInfo GetClubWithBansAndApplications(ulong ownerUserId)
|
public ClubInfo GetClubWithBansAndApplications(ulong ownerUserId)
|
||||||
{
|
{
|
||||||
using var uow = _db.GetDbContext();
|
using var uow = _db.GetDbContext();
|
||||||
|
@@ -13,6 +13,7 @@ public interface IClubService
|
|||||||
bool GetClubByName(string clubName, out ClubInfo club);
|
bool GetClubByName(string clubName, out ClubInfo club);
|
||||||
ClubApplyResult ApplyToClub(IUser user, ClubInfo club);
|
ClubApplyResult ApplyToClub(IUser user, ClubInfo club);
|
||||||
ClubAcceptResult AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser);
|
ClubAcceptResult AcceptApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser);
|
||||||
|
ClubDenyResult RejectApplication(ulong clubOwnerUserId, string userName, out DiscordUser discordUser);
|
||||||
ClubInfo? GetClubWithBansAndApplications(ulong ownerUserId);
|
ClubInfo? GetClubWithBansAndApplications(ulong ownerUserId);
|
||||||
ClubLeaveResult LeaveClub(IUser user);
|
ClubLeaveResult LeaveClub(IUser user);
|
||||||
bool SetDescription(ulong userId, string? desc);
|
bool SetDescription(ulong userId, string? desc);
|
||||||
|
@@ -6,3 +6,10 @@ public enum ClubAcceptResult
|
|||||||
NotOwnerOrAdmin,
|
NotOwnerOrAdmin,
|
||||||
NoSuchApplicant,
|
NoSuchApplicant,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ClubDenyResult
|
||||||
|
{
|
||||||
|
Rejected,
|
||||||
|
NoSuchApplicant,
|
||||||
|
NotOwnerOrAdmin
|
||||||
|
}
|
@@ -29,7 +29,7 @@
|
|||||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||||
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
|
<PackageReference Include="CoreCLR-NCalc" Version="2.2.110" />
|
||||||
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
<PackageReference Include="Google.Apis.Urlshortener.v1" Version="1.41.1.138" />
|
||||||
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.60.0.2945" />
|
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.62.1.3205" />
|
||||||
<PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084" />
|
<PackageReference Include="Google.Apis.Customsearch.v1" Version="1.49.0.2084" />
|
||||||
<PackageReference Include="Google.Protobuf" Version="3.22.1" />
|
<PackageReference Include="Google.Protobuf" Version="3.22.1" />
|
||||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.52.0" />
|
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.52.0" />
|
||||||
|
@@ -57,7 +57,7 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
|
|||||||
return (await query.ExecuteAsync()).Items.Select(i => i.Id.PlaylistId);
|
return (await query.ExecuteAsync()).Items.Select(i => i.Id.PlaylistId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<string>> GetRelatedVideosAsync(string id, int count = 1, string user = null)
|
public async Task<IEnumerable<string>> GetRelatedVideosAsync(string id, int count = 2, string user = null)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(id))
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
throw new ArgumentNullException(nameof(id));
|
throw new ArgumentNullException(nameof(id));
|
||||||
@@ -67,10 +67,14 @@ public sealed partial class GoogleApiService : IGoogleApiService, INService
|
|||||||
|
|
||||||
var query = _yt.Search.List("snippet");
|
var query = _yt.Search.List("snippet");
|
||||||
query.MaxResults = count;
|
query.MaxResults = count;
|
||||||
query.RelatedToVideoId = id;
|
query.Q = id;
|
||||||
|
// query.RelatedToVideoId = id;
|
||||||
query.Type = "video";
|
query.Type = "video";
|
||||||
query.QuotaUser = user;
|
query.QuotaUser = user;
|
||||||
return (await query.ExecuteAsync()).Items.Select(i => "https://www.youtube.com/watch?v=" + i.Id.VideoId);
|
// bad workaround as there's no replacement for related video querying right now.
|
||||||
|
// Query youtube with the id of the video, take a second video in the results
|
||||||
|
// skip the first one as that's probably the same video.
|
||||||
|
return (await query.ExecuteAsync()).Items.Select(i => "https://www.youtube.com/watch?v=" + i.Id.VideoId).Skip(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<string>> GetVideoLinksByKeywordAsync(string keywords, int count = 1)
|
public async Task<IEnumerable<string>> GetVideoLinksByKeywordAsync(string keywords, int count = 1)
|
||||||
|
@@ -1116,6 +1116,8 @@ clubapply:
|
|||||||
- clubapply
|
- clubapply
|
||||||
clubaccept:
|
clubaccept:
|
||||||
- clubaccept
|
- clubaccept
|
||||||
|
clubreject:
|
||||||
|
- clubreject
|
||||||
clubleave:
|
clubleave:
|
||||||
- clubleave
|
- clubleave
|
||||||
clubdisband:
|
clubdisband:
|
||||||
|
@@ -1929,6 +1929,10 @@ clubaccept:
|
|||||||
desc: "Accept a user who applied to your club."
|
desc: "Accept a user who applied to your club."
|
||||||
args:
|
args:
|
||||||
- "user#1337"
|
- "user#1337"
|
||||||
|
clubreject:
|
||||||
|
desc: "Reject a user who applied to your club."
|
||||||
|
args:
|
||||||
|
- "user#1337"
|
||||||
clubleave:
|
clubleave:
|
||||||
desc: "Leaves the club you're currently in."
|
desc: "Leaves the club you're currently in."
|
||||||
args:
|
args:
|
||||||
|
@@ -847,6 +847,7 @@
|
|||||||
"club_not_exists": "That club doesn't exist.",
|
"club_not_exists": "That club doesn't exist.",
|
||||||
"club_applied": "You've applied for membership in {0} club.",
|
"club_applied": "You've applied for membership in {0} club.",
|
||||||
"club_accepted": "Accepted user {0} to the club.",
|
"club_accepted": "Accepted user {0} to the club.",
|
||||||
|
"club_rejected": "The application by {0} has been rejected.",
|
||||||
"club_accept_invalid_applicant": "That user has not applied to your club.",
|
"club_accept_invalid_applicant": "That user has not applied to your club.",
|
||||||
"club_left": "You've left the club.",
|
"club_left": "You've left the club.",
|
||||||
"club_not_in_a_club": "You are not in a club.",
|
"club_not_in_a_club": "You are not in a club.",
|
||||||
|
Reference in New Issue
Block a user