The easy to use and full featured Irc Bot everyone is talking about!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

About.cs 4.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.Reflection;
  3. namespace Combot.Modules.Plugins
  4. {
  5. public class About : Module
  6. {
  7. public override void Initialize()
  8. {
  9. Bot.CommandReceivedEvent += HandleCommandEvent;
  10. }
  11. public override void ParseCommand(CommandMessage command)
  12. {
  13. Command foundCommand = Commands.Find(c => c.Triggers.Contains(command.Command));
  14. switch (foundCommand.Name)
  15. {
  16. case "About":
  17. string ownerNum = " is";
  18. if (Bot.ServerConfig.Owners.Count > 1)
  19. {
  20. ownerNum = "s are";
  21. }
  22. string aboutMessage = string.Format("Combot v{0} is created by Uncled1023. My current owner{1} {2}.", Assembly.GetExecutingAssembly().GetName().Version, ownerNum, string.Join(", ", Bot.ServerConfig.Owners));
  23. SendResponse(command.MessageType, command.Location, command.Nick.Nickname, aboutMessage);
  24. break;
  25. case "Source":
  26. SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("You can find my source code here: {0}", GetOptionValue("Source Code")));
  27. break;
  28. case "Uptime":
  29. DateTime now = DateTime.Now;
  30. int days = now.Subtract(Bot.ConnectionTime).Days;
  31. int hours = now.Subtract(Bot.ConnectionTime).Hours;
  32. int minutes = now.Subtract(Bot.ConnectionTime).Minutes;
  33. int seconds = now.Subtract(Bot.ConnectionTime).Seconds;
  34. string uptime = string.Empty;
  35. if (days > 0)
  36. {
  37. string plural = (days > 1) ? "s" : string.Empty;
  38. uptime += string.Format("{0} day{1}, ", days, plural);
  39. }
  40. if (hours > 0)
  41. {
  42. string plural = (hours > 1) ? "s" : string.Empty;
  43. uptime += string.Format("{0} hour{1}, ", hours, plural);
  44. }
  45. if (minutes > 0)
  46. {
  47. string plural = (minutes > 1) ? "s" : string.Empty;
  48. uptime += string.Format("{0} minute{1}, ", minutes, plural);
  49. }
  50. if (seconds > 0)
  51. {
  52. string plural = (seconds > 1) ? "s" : string.Empty;
  53. uptime += string.Format("{0} second{1}", seconds, plural);
  54. }
  55. SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("I have been connected to this server for \u0002{0}\u0002.", uptime.Trim().TrimEnd(',')));
  56. break;
  57. case "Runtime":
  58. DateTime runtimeNow = DateTime.Now;
  59. int totalDays = runtimeNow.Subtract(Bot.LoadTime).Days;
  60. int totalHours = runtimeNow.Subtract(Bot.LoadTime).Hours;
  61. int totalMinutes = runtimeNow.Subtract(Bot.LoadTime).Minutes;
  62. int totalSeconds = runtimeNow.Subtract(Bot.LoadTime).Seconds;
  63. string runtime = string.Empty;
  64. if (totalDays > 0)
  65. {
  66. string plural = (totalDays > 1) ? "s" : string.Empty;
  67. runtime += string.Format("{0} day{1}, ", totalDays, plural);
  68. }
  69. if (totalHours > 0)
  70. {
  71. string plural = (totalHours > 1) ? "s" : string.Empty;
  72. runtime += string.Format("{0} hour{1}, ", totalHours, plural);
  73. }
  74. if (totalMinutes > 0)
  75. {
  76. string plural = (totalMinutes > 1) ? "s" : string.Empty;
  77. runtime += string.Format("{0} minute{1}, ", totalMinutes, plural);
  78. }
  79. if (totalSeconds > 0)
  80. {
  81. string plural = (totalSeconds > 1) ? "s" : string.Empty;
  82. runtime += string.Format("{0} second{1}", totalSeconds, plural);
  83. }
  84. SendResponse(command.MessageType, command.Location, command.Nick.Nickname, string.Format("I have been running for \u0002{0}\u0002.", runtime.Trim().TrimEnd(',')));
  85. break;
  86. }
  87. }
  88. }
  89. }