mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Bugfixes:
- Do not call RemoveUnbanAsync in guild tick loop if the user is not banned - Fix !clear message logs being reversed - Do not process MessageReceivedEvents by webhooks Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
f6f5543972
commit
4cc00e01da
4 changed files with 11 additions and 16 deletions
11
Boyfriend.cs
11
Boyfriend.cs
|
@ -31,18 +31,14 @@ public static class Boyfriend {
|
||||||
(new Game("UNDEAD CORPORATION - Everything will freeze", ActivityType.Listening), new TimeSpan(0, 3, 18)),
|
(new Game("UNDEAD CORPORATION - Everything will freeze", ActivityType.Listening), new TimeSpan(0, 3, 18)),
|
||||||
(new Game("Splatoon 3 - Candy-Coated Rocks", ActivityType.Listening), new TimeSpan(0, 2, 39)),
|
(new Game("Splatoon 3 - Candy-Coated Rocks", ActivityType.Listening), new TimeSpan(0, 2, 39)),
|
||||||
(new Game("RetroSpecter - Overtime", ActivityType.Listening), new TimeSpan(0, 4, 33)),
|
(new Game("RetroSpecter - Overtime", ActivityType.Listening), new TimeSpan(0, 4, 33)),
|
||||||
(new Game("beatMARIO - Night of Knights", ActivityType.Listening), new TimeSpan(0, 4, 10))
|
(new Game("SOOOO - Happppy song", ActivityType.Listening), new TimeSpan(0, 5, 24))
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly DiscordSocketClient Client = new(Config);
|
public static readonly DiscordSocketClient Client = new(Config);
|
||||||
|
|
||||||
private static readonly List<Task> GuildTickTasks = new();
|
private static readonly List<Task> GuildTickTasks = new();
|
||||||
|
|
||||||
public static void Main() {
|
private static async Task Main() {
|
||||||
InitAsync().GetAwaiter().GetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task InitAsync() {
|
|
||||||
var token = (await File.ReadAllTextAsync("token.txt")).Trim();
|
var token = (await File.ReadAllTextAsync("token.txt")).Trim();
|
||||||
|
|
||||||
Client.Log += Log;
|
Client.Log += Log;
|
||||||
|
@ -149,7 +145,8 @@ public static class Boyfriend {
|
||||||
|
|
||||||
foreach (var mData in data.MemberData.Values) {
|
foreach (var mData in data.MemberData.Values) {
|
||||||
var user = guild.GetUser(mData.Id);
|
var user = guild.GetUser(mData.Id);
|
||||||
if (now >= mData.BannedUntil) _ = guild.RemoveBanAsync(mData.Id);
|
if (now >= mData.BannedUntil && await guild.GetBanAsync(mData.Id) is not null)
|
||||||
|
_ = guild.RemoveBanAsync(mData.Id);
|
||||||
if (!mData.IsInGuild) continue;
|
if (!mData.IsInGuild) continue;
|
||||||
if (mData.MutedUntil is null
|
if (mData.MutedUntil is null
|
||||||
&& ulong.TryParse(config["StarterRole"], out var starterRoleId)
|
&& ulong.TryParse(config["StarterRole"], out var starterRoleId)
|
||||||
|
|
|
@ -8,7 +8,6 @@ using Discord.WebSocket;
|
||||||
namespace Boyfriend;
|
namespace Boyfriend;
|
||||||
|
|
||||||
public sealed class CommandProcessor {
|
public sealed class CommandProcessor {
|
||||||
private static readonly string Mention = $"<@{Boyfriend.Client.CurrentUser.Id}>";
|
|
||||||
private static readonly TimeSpan Infinity = TimeSpan.FromMilliseconds(-1);
|
private static readonly TimeSpan Infinity = TimeSpan.FromMilliseconds(-1);
|
||||||
|
|
||||||
public static readonly ICommand[] Commands = {
|
public static readonly ICommand[] Commands = {
|
||||||
|
@ -58,9 +57,10 @@ public sealed class CommandProcessor {
|
||||||
|
|
||||||
private async Task RunCommandOnLine(string line, string cleanLine, string prefix) {
|
private async Task RunCommandOnLine(string line, string cleanLine, string prefix) {
|
||||||
var prefixed = line.StartsWith(prefix);
|
var prefixed = line.StartsWith(prefix);
|
||||||
if (!prefixed && !line.StartsWith(Mention)) return;
|
var mention = Boyfriend.Client.CurrentUser.Mention;
|
||||||
|
if (!prefixed && !line.StartsWith(mention)) return;
|
||||||
foreach (var command in Commands) {
|
foreach (var command in Commands) {
|
||||||
var lineNoMention = line.Remove(0, prefixed ? prefix.Length : Mention.Length);
|
var lineNoMention = line.Remove(0, prefixed ? prefix.Length : mention.Length);
|
||||||
if (!command.Aliases.Contains(lineNoMention.Trim().Split()[0])) continue;
|
if (!command.Aliases.Contains(lineNoMention.Trim().Split()[0])) continue;
|
||||||
|
|
||||||
var args = lineNoMention.Trim().Split().Skip(1).ToArray();
|
var args = lineNoMention.Trim().Split().Skip(1).ToArray();
|
||||||
|
|
|
@ -17,7 +17,7 @@ public sealed class ClearCommand : ICommand {
|
||||||
var messages = await channel.GetMessagesAsync((int)(toDelete + 1)).FlattenAsync();
|
var messages = await channel.GetMessagesAsync((int)(toDelete + 1)).FlattenAsync();
|
||||||
|
|
||||||
var user = (SocketGuildUser)cmd.Context.User;
|
var user = (SocketGuildUser)cmd.Context.User;
|
||||||
var msgArray = messages.ToArray();
|
var msgArray = messages.Reverse().ToArray();
|
||||||
await channel.DeleteMessagesAsync(msgArray, Utils.GetRequestOptions(user.ToString()!));
|
await channel.DeleteMessagesAsync(msgArray, Utils.GetRequestOptions(user.ToString()!));
|
||||||
|
|
||||||
foreach (var msg in msgArray.Where(m => !m.Author.IsBot))
|
foreach (var msg in msgArray.Where(m => !m.Author.IsBot))
|
||||||
|
|
|
@ -83,16 +83,14 @@ public static class EventHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Task MessageReceivedEvent(IDeletable messageParam) {
|
private static Task MessageReceivedEvent(IDeletable messageParam) {
|
||||||
if (messageParam is not SocketUserMessage message) return Task.CompletedTask;
|
if (messageParam is not SocketUserMessage message || message.Author.IsWebhook) return Task.CompletedTask;
|
||||||
|
|
||||||
_ = message.CleanContent.ToLower() switch {
|
_ = message.CleanContent.ToLower() switch {
|
||||||
"whoami" => message.ReplyAsync("`nobody`"),
|
"whoami" => message.ReplyAsync("`nobody`"),
|
||||||
"сука !!" => message.ReplyAsync("`root`"),
|
"сука !!" => message.ReplyAsync("`root`"),
|
||||||
"воооо" => message.ReplyAsync("`removing /...`"),
|
"воооо" => message.ReplyAsync("`removing /...`"),
|
||||||
"op ??" => message.ReplyAsync(
|
"++++" => message.ReplyAsync("#"),
|
||||||
"некоторые пасхальные цитаты которые вы могли найти были легально взяты у <@573772175572729876>"),
|
_ => new CommandProcessor(message).HandleCommandAsync()
|
||||||
"++++" => message.ReplyAsync("#"),
|
|
||||||
_ => new CommandProcessor(message).HandleCommandAsync()
|
|
||||||
};
|
};
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue