From f06ab16a2ff68c5e82be2bd1c250c0ecf98e8302 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 29 Feb 2016 03:48:31 +0100 Subject: [PATCH] just in case --- NadekoBot/Commands/TriviaCommand.cs | 7 ++- .../Commands/TriviaCommand.cs~RF13c91205.TMP | 53 ++++++++++++++++++ NadekoBot/bin/Debug/Discord.Net.Audio.dll | Bin 65536 -> 65536 bytes NadekoBot/bin/Debug/Discord.Net.Commands.dll | Bin 40448 -> 40448 bytes NadekoBot/bin/Debug/Discord.Net.Modules.dll | Bin 35328 -> 35328 bytes NadekoBot/bin/Debug/Discord.Net.dll | Bin 311808 -> 311808 bytes NadekoBot/bin/Debug/data/nadekobot.sqlite | Bin 8517632 -> 8525824 bytes 7 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 NadekoBot/Commands/TriviaCommand.cs~RF13c91205.TMP diff --git a/NadekoBot/Commands/TriviaCommand.cs b/NadekoBot/Commands/TriviaCommand.cs index d9e00884..2ed0a84e 100644 --- a/NadekoBot/Commands/TriviaCommand.cs +++ b/NadekoBot/Commands/TriviaCommand.cs @@ -12,9 +12,12 @@ namespace NadekoBot.Commands { public override Func DoFunc() => async e => { TriviaGame trivia; - if (!runningTrivias.TryGetValue(e.Server, out trivia)) { - if(runningTrivias.TryAdd(e.Server, new TriviaGame(e))) + if (!runningTrivias.TryGetValue(e.Server, out trivia)) { + var triviaGame = new TriviaGame(e); + if (runningTrivias.TryAdd(e.Server, triviaGame)) await e.Channel.SendMessage("**Trivia game started!**\nFirst player to get to 10 points wins! You have 30 seconds per question.\nUse command `tq` if game was started by accident.**"); + else + await triviaGame.StopGame(); } else await e.Channel.SendMessage("Trivia game is already running on this server.\n" + trivia.CurrentQuestion); }; diff --git a/NadekoBot/Commands/TriviaCommand.cs~RF13c91205.TMP b/NadekoBot/Commands/TriviaCommand.cs~RF13c91205.TMP new file mode 100644 index 00000000..d9e00884 --- /dev/null +++ b/NadekoBot/Commands/TriviaCommand.cs~RF13c91205.TMP @@ -0,0 +1,53 @@ +using System; +using System.Threading.Tasks; +using Discord.Commands; +using NadekoBot.Extensions; +using System.Collections.Concurrent; +using Discord; +using TriviaGame = NadekoBot.Classes.Trivia.TriviaGame; + +namespace NadekoBot.Commands { + class Trivia : DiscordCommand { + public static ConcurrentDictionary runningTrivias = new ConcurrentDictionary(); + + public override Func DoFunc() => async e => { + TriviaGame trivia; + if (!runningTrivias.TryGetValue(e.Server, out trivia)) { + if(runningTrivias.TryAdd(e.Server, new TriviaGame(e))) + await e.Channel.SendMessage("**Trivia game started!**\nFirst player to get to 10 points wins! You have 30 seconds per question.\nUse command `tq` if game was started by accident.**"); + } else + await e.Channel.SendMessage("Trivia game is already running on this server.\n" + trivia.CurrentQuestion); + }; + + public override void Init(CommandGroupBuilder cgb) { + cgb.CreateCommand("t") + .Description("Starts a game of trivia.") + .Alias("-t") + .Do(DoFunc()); + + cgb.CreateCommand("tl") + .Description("Shows a current trivia leaderboard.") + .Alias("-tl") + .Alias("tlb") + .Alias("-tlb") + .Do(async e=> { + TriviaGame trivia; + if (runningTrivias.TryGetValue(e.Server, out trivia)) + await e.Channel.SendMessage(trivia.GetLeaderboard()); + else + await e.Channel.SendMessage("No trivia is running on this server."); + }); + + cgb.CreateCommand("tq") + .Description("Quits current trivia after current question.") + .Alias("-tq") + .Do(async e=> { + TriviaGame trivia; + if (runningTrivias.TryGetValue(e.Server, out trivia)) { + await trivia.StopGame(); + } else + await e.Channel.SendMessage("No trivia is running on this server."); + }); + } + } +} diff --git a/NadekoBot/bin/Debug/Discord.Net.Audio.dll b/NadekoBot/bin/Debug/Discord.Net.Audio.dll index 3c1178d6d2b793d2266af432c2e3c18dc7c71361..e77213cc00178dea915687e357aee92d7b947d63 100644 GIT binary patch delta 66 zcmV-I0KNZ!fCPYm1dxaVx~{Q``q>aqGON2^Ysf^3I^lPpZP&uHl-h_I0=lk~9`za! Y9m5a&lB%9WwJ5hWEQRhHvq<&03OT7DVgLXD delta 66 zcmV-I0KNZ!fCPYm1dxaVVhyp1`q>c2nh=DfWHmvR8_43u=KPbhl-h_I0%8r59`za! Yb-WzA*%U8DfGLR%Hw)wMvq<&03h*2rD*ylh diff --git a/NadekoBot/bin/Debug/Discord.Net.Commands.dll b/NadekoBot/bin/Debug/Discord.Net.Commands.dll index 51d3973bac10c7fb0ba6f122ba003e97e663bad5..5f43c5bf4c194efbfe30464151b08dd75a95fecf 100644 GIT binary patch delta 87 zcmZqJ!_=^cX+j6n&UG8R%o+vuvefoHtDNY+L!fc(A8)S2%@-OKgmiYUyBx*<1WZ6I p!^ptEu?dK$FfarKy99p|Xnw=Lkjr(ZXXK@?CqG`?EHmW^Cji#JA*TQU delta 87 zcmZqJ!_=^cX+j5667R+?vqphA^14rcJ&AW*%yYBG^-N9j<_nDqLOMyjm%|uoH;;T$G{L2>=GOw=U()_>6QERKPI!|7e+U4-cT374FK{}B0K;9 delta 87 zcmZpe!qhN@X+j5667R+?rhI|j2`p=hpMUh6b70a>?kBZ3HqXg_!KahNdpV2&2$+Ca phLM3`&Kw}FV_*mhb_uTizUEh0?E}ZHv+}0w+2&oic|%-6Of1kxUPYUg^B@%iUNg-1GS0-nmiC$eAodddM-nh8~Dhto4c>K nG(7~wdIGqvm-@E^8W5&5WAXIN(MP9f$X*`pKCZVUxCGn@qOK(F delta 81 zcmV-X0IvUlgcE>-6Of1kVhw?cg^B@%iUNg-1GS0-nmiEBf0kwevHV1iaSGbBbV|Lq nG(7~wdIDk%m-@E^8W3eto~XBtDM-5**A)>RI1INWxCGn@HNYSo diff --git a/NadekoBot/bin/Debug/data/nadekobot.sqlite b/NadekoBot/bin/Debug/data/nadekobot.sqlite index a1ab4f5c35589330d2db401d64874949f60307e2..a956a5a4775ebf815543fd38306b0a013dfee5f6 100644 GIT binary patch delta 5251 zcmbuDd2AHt8OG z05fFC(MS;qRY#;mDQTLck*f5cT_p+a!+zZ*|^xi{Pvmd#dO+W?;SO69R2gm@KAPYDF_vV0HkO%U?B2WMpgF;XQia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