mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Bot will now 'try' to set status to invisible before going offline when '.die' command is used, but it doesn't seem to have (much/any) effect. .qsearch is more powerful
This commit is contained in:
@@ -261,6 +261,7 @@ public sealed class Bot
|
|||||||
Client.JoinedGuild += Client_JoinedGuild;
|
Client.JoinedGuild += Client_JoinedGuild;
|
||||||
Client.LeftGuild += Client_LeftGuild;
|
Client.LeftGuild += Client_LeftGuild;
|
||||||
|
|
||||||
|
// _ = Client.SetStatusAsync(UserStatus.Online);
|
||||||
Log.Information("Shard {ShardId} logged in", Client.ShardId);
|
Log.Information("Shard {ShardId} logged in", Client.ShardId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,12 +44,12 @@ public static class QuoteExtensions
|
|||||||
var rngk = new NadekoRandom();
|
var rngk = new NadekoRandom();
|
||||||
return (await quotes.AsQueryable()
|
return (await quotes.AsQueryable()
|
||||||
.Where(q => q.GuildId == guildId
|
.Where(q => q.GuildId == guildId
|
||||||
&& q.Keyword == keyword
|
&& (keyword == null || q.Keyword == keyword)
|
||||||
&& EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%")
|
&& (EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%")
|
||||||
// && q.Text.Contains(text, StringComparison.OrdinalIgnoreCase)
|
|| EF.Functions.Like(q.AuthorName, text)))
|
||||||
)
|
.ToListAsync())
|
||||||
.ToListAsync()).OrderBy(_ => rngk.Next())
|
.OrderBy(_ => rngk.Next())
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RemoveAllByKeyword(this DbSet<Quote> quotes, ulong guildId, string keyword)
|
public static void RemoveAllByKeyword(this DbSet<Quote> quotes, ulong guildId, string keyword)
|
||||||
|
@@ -335,6 +335,7 @@ public partial class Administration
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
await _client.SetStatusAsync(UserStatus.DoNotDisturb);
|
||||||
await ReplyConfirmLocalizedAsync(strs.shutting_down);
|
await ReplyConfirmLocalizedAsync(strs.shutting_down);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#nullable disable
|
#nullable disable warnings
|
||||||
using NadekoBot.Common.Yml;
|
using NadekoBot.Common.Yml;
|
||||||
using NadekoBot.Db;
|
using NadekoBot.Db;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
@@ -134,30 +134,40 @@ public partial class Utility
|
|||||||
.WithFooter(
|
.WithFooter(
|
||||||
GetText(strs.created_by($"{data.AuthorName} ({data.AuthorId})"))));
|
GetText(strs.created_by($"{data.AuthorName} ({data.AuthorId})"))));
|
||||||
|
|
||||||
[Cmd]
|
private async Task QuoteSearchinternalAsync(string? keyword, string textOrAuthor)
|
||||||
[RequireContext(ContextType.Guild)]
|
|
||||||
public async partial Task QuoteSearch(string keyword, [Leftover] string text)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text))
|
if (string.IsNullOrWhiteSpace(textOrAuthor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
keyword = keyword.ToUpperInvariant();
|
keyword = keyword?.ToUpperInvariant();
|
||||||
|
|
||||||
Quote keywordquote;
|
Quote quote;
|
||||||
await using (var uow = _db.GetDbContext())
|
await using (var uow = _db.GetDbContext())
|
||||||
{
|
{
|
||||||
keywordquote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, text);
|
quote = await uow.Quotes.SearchQuoteKeywordTextAsync(ctx.Guild.Id, keyword, textOrAuthor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keywordquote is null)
|
if (quote is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await ctx.Channel.SendMessageAsync($"`#{keywordquote.Id}` 💬 "
|
await ctx.Channel.SendMessageAsync($"`#{quote.Id}` 💬 "
|
||||||
+ keyword.ToLowerInvariant()
|
+ quote.Keyword.ToLowerInvariant()
|
||||||
+ ": "
|
+ ": "
|
||||||
+ keywordquote.Text.SanitizeAllMentions());
|
+ quote.Text.SanitizeAllMentions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[Priority(0)]
|
||||||
|
public partial Task QuoteSearch(string textOrAuthor)
|
||||||
|
=> QuoteSearchinternalAsync(null, textOrAuthor);
|
||||||
|
|
||||||
|
[Cmd]
|
||||||
|
[RequireContext(ContextType.Guild)]
|
||||||
|
[Priority(1)]
|
||||||
|
public partial Task QuoteSearch(string keyword, [Leftover] string textOrAuthor)
|
||||||
|
=> QuoteSearchinternalAsync(keyword, textOrAuthor);
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
[RequireContext(ContextType.Guild)]
|
[RequireContext(ContextType.Guild)]
|
||||||
public async partial Task QuoteId(int id)
|
public async partial Task QuoteId(int id)
|
||||||
|
@@ -601,9 +601,12 @@ quoteshow:
|
|||||||
args:
|
args:
|
||||||
- "123"
|
- "123"
|
||||||
quotesearch:
|
quotesearch:
|
||||||
desc: "Shows a random quote for a keyword that contains any text specified in the search."
|
desc: "Shows a random quote given a search query. Partially matches in several ways: 1) Only content of any quote, 2) only by author, 3) keyword and content, 3) or keyword and author"
|
||||||
args:
|
args:
|
||||||
- "keyword text"
|
- """find this long text"""
|
||||||
|
- "AuthorName"
|
||||||
|
- "keyword some text"
|
||||||
|
- "keyword AuthorName"
|
||||||
quoteid:
|
quoteid:
|
||||||
desc: "Displays the quote with the specified ID number. Quote ID numbers can be found by typing `{0}liqu [num]` where `[num]` is a number of a page which contains 15 quotes."
|
desc: "Displays the quote with the specified ID number. Quote ID numbers can be found by typing `{0}liqu [num]` where `[num]` is a number of a page which contains 15 quotes."
|
||||||
args:
|
args:
|
||||||
|
Reference in New Issue
Block a user