From 2a554925c354b63370ba718dc49a958e447ab6d4 Mon Sep 17 00:00:00 2001 From: Madpeter Date: Sun, 26 Apr 2020 00:26:14 +0100 Subject: [PATCH] New command: GetLastCommands --- Core/Commands/Self/GetLastCommands.cs | 29 +++++++++++++++++++++++++++ Core/bottypes/CommandsBot.cs | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Core/Commands/Self/GetLastCommands.cs diff --git a/Core/Commands/Self/GetLastCommands.cs b/Core/Commands/Self/GetLastCommands.cs new file mode 100644 index 0000000..9aa170d --- /dev/null +++ b/Core/Commands/Self/GetLastCommands.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BSB.Commands.Self +{ + public class GetLastCommands : CoreCommand + { + public override string[] ArgTypes { get { return new[] { "Mixed" }; } } + public override string[] ArgHints { get { return new[] { "Smart reply [Channel|Avatar|http url]", }; } } + public override int MinArgs { get { return 1; } } + public override string Helpfile + { + get + { + return ""; + } + } + + public override bool CallFunction(string[] args) + { + if (base.CallFunction(args) == true) + { + return bot.GetCommandsInterface.SmartCommandReply(args[0], String.Join(',',bot.GetLastCommands(5)), CommandName); + } + return false; + } + } +} diff --git a/Core/bottypes/CommandsBot.cs b/Core/bottypes/CommandsBot.cs index e6a6a7e..2d681d1 100644 --- a/Core/bottypes/CommandsBot.cs +++ b/Core/bottypes/CommandsBot.cs @@ -34,7 +34,7 @@ namespace BSB.bottypes int loop = 0; while((loop < CommandHistory.Count) && (loop < amount)) { - commands.Add(CommandHistory.Keys.ElementAt(CommandHistory.Count - loop)); + commands.Add(CommandHistory.Keys.ElementAt(CommandHistory.Count - loop - 1)); loop++; } return commands.ToArray();