vrobot3 is a chat bot for IRC and Discord.
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.

123 lines
2.8KB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // Copyright © 2016 Project Golan
  4. //
  5. // See "LICENSE" for more information.
  6. //
  7. //-----------------------------------------------------------------------------
  8. //
  9. // Base module classes.
  10. //
  11. //-----------------------------------------------------------------------------
  12. using System;
  13. using System.Collections.Generic;
  14. namespace ProjectGolan.Vrobot3
  15. {
  16. namespace Modules.EventType
  17. {
  18. public delegate void OnMessage(User usr, Channel channel, String msg);
  19. public delegate void OnSeen(User usr, Channel channel);
  20. }
  21. //
  22. // BotModuleRequiresAudioAttribute
  23. //
  24. public class BotModuleRequiresAudioAttribute : Attribute
  25. {
  26. public override String ToString() => "Bot Module Requires Audio";
  27. }
  28. //
  29. // BotModuleDisabledAttribute
  30. //
  31. public class BotModuleDisabledAttribute : Attribute
  32. {
  33. public override String ToString() => "Bot Module Disabled";
  34. }
  35. //
  36. // BotModuleDiscordAttribute
  37. //
  38. public class BotModuleDiscordAttribute : Attribute
  39. {
  40. public override String ToString() => "Bot Module is Discord only";
  41. }
  42. //
  43. // BotModuleIRCAttribute
  44. //
  45. public class BotModuleIRCAttribute : Attribute
  46. {
  47. public override String ToString() => "Bot Module is IRC only";
  48. }
  49. //
  50. // BotRole
  51. //
  52. // Used for command role-checking.
  53. //
  54. public enum BotRole
  55. {
  56. User,
  57. HalfAdmin,
  58. Admin
  59. }
  60. //
  61. // BotCommandStructure
  62. //
  63. // Used for registering commands in a module.
  64. //
  65. public class BotCommandStructure
  66. {
  67. public BotCommand cmd;
  68. public String help;
  69. public bool hidden;
  70. public BotRole role;
  71. public Type mod;
  72. }
  73. //
  74. // IBotModule
  75. //
  76. // Base module class. Inherit this for your modules.
  77. //
  78. public abstract class IBotModule
  79. {
  80. //
  81. // Events
  82. //
  83. public struct Events
  84. {
  85. public event Modules.EventType.OnMessage onCmdMessage;
  86. public event Modules.EventType.OnMessage onMessage;
  87. public event Modules.EventType.OnSeen onSeen;
  88. public void raiseOnCmdMessage(User usr, Channel channel, String msg) =>
  89. onCmdMessage?.Invoke(usr, channel, msg);
  90. public void raiseOnMessage(User usr, Channel channel, String msg) =>
  91. onMessage?.Invoke(usr, channel, msg);
  92. public void raiseOnSeen(User usr, Channel channel) =>
  93. onSeen?.Invoke(usr, channel);
  94. }
  95. protected void postSetup()
  96. {
  97. foreach(var kvp in commands)
  98. kvp.Value.mod = this.GetType();
  99. }
  100. protected IBotModule(Bot bot) {this.bot = bot;}
  101. public CommandDict commands = new CommandDict();
  102. public Events events;
  103. protected Bot bot;
  104. }
  105. }
  106. // EOF