The easy to use and full featured Irc Bot everyone is talking about!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Decide.cs 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Newtonsoft.Json.Linq;
  5. namespace Combot.Modules.Plugins
  6. {
  7. public class Decide : Module
  8. {
  9. public override void Initialize()
  10. {
  11. Bot.CommandReceivedEvent += HandleCommandEvent;
  12. }
  13. public override void ParseCommand(CommandMessage command)
  14. {
  15. Command foundCommand = Commands.Find(c => c.Triggers.Contains(command.Command));
  16. switch (foundCommand.Name)
  17. {
  18. case "Decide":
  19. string options = command.Arguments["Options"].ToString();
  20. List<string> optionList = options.Split(new[] {" or "}, StringSplitOptions.RemoveEmptyEntries).ToList();
  21. if (optionList.Count > 1)
  22. {
  23. Random rand = new Random();
  24. int choiceIndex = rand.Next(0, optionList.Count);
  25. JArray prefixes = (JArray)GetOptionValue("Choice Prefixes");
  26. int prefixIndex = rand.Next(0, prefixes.Count);
  27. SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("{0} {1}", prefixes[prefixIndex], optionList[choiceIndex]));
  28. }
  29. else
  30. {
  31. Random rand = new Random();
  32. JArray answers = (JArray)GetOptionValue("Choice Answers");
  33. int answerIndex = rand.Next(0, answers.Count);
  34. SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("{0}", answers[answerIndex]));
  35. }
  36. break;
  37. }
  38. }
  39. }
  40. }