From 4c0f814f5767e959efba7a943a20c8907dc09b7b Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 22 Dec 2015 18:01:35 +0100 Subject: [PATCH] Added "@BotMention slm" command - slm shows the last message you were mentioned in. Useful if you don't want to scroll up just to see where is the message you need to read. --- NadekoBot/Modules/Conversations.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/NadekoBot/Modules/Conversations.cs b/NadekoBot/Modules/Conversations.cs index 1c530bf9..9bd00b09 100644 --- a/NadekoBot/Modules/Conversations.cs +++ b/NadekoBot/Modules/Conversations.cs @@ -307,7 +307,6 @@ namespace NadekoBot.Modules */ }); - AliasCommand(CreateCommand(cgb, "save"), "s") .Description("Saves something for the owner in a file.") .Parameter("all", ParameterType.Unparsed) @@ -353,7 +352,28 @@ namespace NadekoBot.Modules string str = Encoding.ASCII.GetString(b); await e.User.Send("```" + (str.Length < 1950 ? str : str.Substring(0, 1950)) + "```"); }); + cgb.CreateCommand("slm") + .Description("Shows the message where you were last mentioned in this channel (checks last 10k messages)") + .Do(async e => { + Message msg; + var msgs = e.Channel.Messages + .Where(m => m.MentionedUsers.Contains(e.User)) + .OrderBy(m => m.Timestamp); + if (msgs.Count() > 0) + msg = msgs.FirstOrDefault(); + else { + var msgsarr = await client.DownloadMessages(e.Channel, 10000); + msg = msgsarr + .Where(m => m.MentionedUsers.Contains(e.User)) + .OrderBy(m => m.Timestamp) + .FirstOrDefault(); + } + if (msg != null) + await e.Send("Last message mentioning you was at " + msg.Timestamp + "\n**Message:** " + msg.RawText); + else + await e.Send("I can't find a message mentioning you."); + }); CreateCommand(cgb, "cs") .Description("Deletes all saves") .Do(async e =>