mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18: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.LeftGuild += Client_LeftGuild;
|
||||
|
||||
// _ = Client.SetStatusAsync(UserStatus.Online);
|
||||
Log.Information("Shard {ShardId} logged in", Client.ShardId);
|
||||
}
|
||||
|
||||
|
@@ -44,12 +44,12 @@ public static class QuoteExtensions
|
||||
var rngk = new NadekoRandom();
|
||||
return (await quotes.AsQueryable()
|
||||
.Where(q => q.GuildId == guildId
|
||||
&& q.Keyword == keyword
|
||||
&& EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%")
|
||||
// && q.Text.Contains(text, StringComparison.OrdinalIgnoreCase)
|
||||
)
|
||||
.ToListAsync()).OrderBy(_ => rngk.Next())
|
||||
.FirstOrDefault();
|
||||
&& (keyword == null || q.Keyword == keyword)
|
||||
&& (EF.Functions.Like(q.Text.ToUpper(), $"%{text.ToUpper()}%")
|
||||
|| EF.Functions.Like(q.AuthorName, text)))
|
||||
.ToListAsync())
|
||||
.OrderBy(_ => rngk.Next())
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static void RemoveAllByKeyword(this DbSet<Quote> quotes, ulong guildId, string keyword)
|
||||
|
@@ -335,6 +335,7 @@ public partial class Administration
|
||||
{
|
||||
try
|
||||
{
|
||||
await _client.SetStatusAsync(UserStatus.DoNotDisturb);
|
||||
await ReplyConfirmLocalizedAsync(strs.shutting_down);
|
||||
}
|
||||
catch
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#nullable disable
|
||||
#nullable disable warnings
|
||||
using NadekoBot.Common.Yml;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
@@ -134,30 +134,40 @@ public partial class Utility
|
||||
.WithFooter(
|
||||
GetText(strs.created_by($"{data.AuthorName} ({data.AuthorId})"))));
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async partial Task QuoteSearch(string keyword, [Leftover] string text)
|
||||
private async Task QuoteSearchinternalAsync(string? keyword, string textOrAuthor)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text))
|
||||
if (string.IsNullOrWhiteSpace(textOrAuthor))
|
||||
return;
|
||||
|
||||
keyword = keyword.ToUpperInvariant();
|
||||
keyword = keyword?.ToUpperInvariant();
|
||||
|
||||
Quote keywordquote;
|
||||
Quote quote;
|
||||
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;
|
||||
|
||||
await ctx.Channel.SendMessageAsync($"`#{keywordquote.Id}` 💬 "
|
||||
+ keyword.ToLowerInvariant()
|
||||
await ctx.Channel.SendMessageAsync($"`#{quote.Id}` 💬 "
|
||||
+ 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]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async partial Task QuoteId(int id)
|
||||
|
@@ -601,9 +601,12 @@ quoteshow:
|
||||
args:
|
||||
- "123"
|
||||
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:
|
||||
- "keyword text"
|
||||
- """find this long text"""
|
||||
- "AuthorName"
|
||||
- "keyword some text"
|
||||
- "keyword AuthorName"
|
||||
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."
|
||||
args:
|
||||
|
Reference in New Issue
Block a user