Bug fixes in polls, emoji stuff and quotes

This commit is contained in:
Runebaas 2017-11-08 19:19:43 +01:00
parent f96954a7e1
commit 0e217b8db1
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
4 changed files with 39 additions and 10 deletions

View file

@ -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)
{

View file

@ -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<PollResult>();
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;

View file

@ -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);

View file

@ -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:",
[' '] = " "
};