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

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