diff --git a/Geekbot.net/Commands/Emojify.cs b/Geekbot.net/Commands/Emojify.cs index b16432e..855bd65 100644 --- a/Geekbot.net/Commands/Emojify.cs +++ b/Geekbot.net/Commands/Emojify.cs @@ -25,8 +25,14 @@ namespace Geekbot.net.Commands try { var sb = new StringBuilder(); + var emojis = _emojiConverter.textToEmoji(text); + if (emojis.Length > 1999) + { + await ReplyAsync("I can't take that much at once!"); + return; + } await ReplyAsync($"*{Context.User.Username}#{Context.User.Discriminator} said:*"); - await ReplyAsync(_emojiConverter.textToEmoji(text)); + await ReplyAsync(emojis); } catch (Exception e) { diff --git a/Geekbot.net/Commands/Poll.cs b/Geekbot.net/Commands/Poll.cs index 11f6879..ae2ae77 100644 --- a/Geekbot.net/Commands/Poll.cs +++ b/Geekbot.net/Commands/Poll.cs @@ -56,6 +56,12 @@ namespace Geekbot.net.Commands { try { + var currentPoll = GetCurrentPoll(); + if (currentPoll.Question != null && !currentPoll.IsFinshed) + { + await ReplyAsync("You have not finished you last poll yet. To finish it use `!poll end`"); + return; + } var pollList = rawPollString.Split(';').ToList(); if (pollList.Count <= 2) { @@ -121,6 +127,9 @@ namespace Geekbot.net.Commands sb.AppendLine($"{result.VoteCount} - {result.Option}"); } await ReplyAsync(sb.ToString()); + currentPoll.IsFinshed = true; + var pollJson = JsonConvert.SerializeObject(currentPoll); + _redis.HashSet($"{Context.Guild.Id}:Polls", new HashEntry[] {new HashEntry(Context.Channel.Id, pollJson)}); } catch (Exception e) { @@ -147,13 +156,17 @@ namespace Geekbot.net.Commands var results = new List(); foreach (var r in message.Reactions) { - var option = int.Parse(r.Key.Name.ToCharArray()[0].ToString()); - var result = new PollResult() + try { - Option = poll.Options[option - 1], - VoteCount = r.Value.ReactionCount - }; - results.Add(result); + var option = int.Parse(r.Key.Name.ToCharArray()[0].ToString()); + var result = new PollResult() + { + Option = poll.Options[option - 1], + VoteCount = r.Value.ReactionCount + }; + results.Add(result); + } + catch {} } results.Sort((x,y) => y.VoteCount.CompareTo(x.VoteCount)); return results; diff --git a/Geekbot.net/Commands/Quote.cs b/Geekbot.net/Commands/Quote.cs index ca2d134..d6eae26 100644 --- a/Geekbot.net/Commands/Quote.cs +++ b/Geekbot.net/Commands/Quote.cs @@ -55,6 +55,11 @@ namespace Geekbot.net.Commands await ReplyAsync("You can't save your own quotes..."); return; } + if (user.IsBot) + { + await ReplyAsync("You can't save quotes by a bot..."); + return; + } var lastMessage = await getLastMessageByUser(user); var quote = createQuoteObject(lastMessage); var quoteStore = JsonConvert.SerializeObject(quote); @@ -81,6 +86,11 @@ namespace Geekbot.net.Commands await ReplyAsync("You can't save your own quotes..."); return; } + if (message.Author.IsBot) + { + await ReplyAsync("You can't save quotes by a bot..."); + return; + } var quote = createQuoteObject(message); var quoteStore = JsonConvert.SerializeObject(quote); redis.SetAdd($"{Context.Guild.Id}:Quotes", quoteStore); diff --git a/Geekbot.net/Lib/EmojiConverter.cs b/Geekbot.net/Lib/EmojiConverter.cs index 8d6e80b..4cf7a23 100644 --- a/Geekbot.net/Lib/EmojiConverter.cs +++ b/Geekbot.net/Lib/EmojiConverter.cs @@ -61,10 +61,10 @@ namespace Geekbot.net.Lib ['2'] = ":two:", ['3'] = ":three:", ['4'] = ":four:", - ['5'] = ":five", - ['6'] = ":six", + ['5'] = ":five:", + ['6'] = ":six:", ['7'] = ":seven:", - ['8'] = ":eight", + ['8'] = ":eight:", ['9'] = ":nine:", [' '] = " " };