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.

85 lines
2.1KB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // Copyright © 2016 Project Golan
  4. //
  5. // See "LICENSE" for more information.
  6. //
  7. //-----------------------------------------------------------------------------
  8. //
  9. // Admin commands module.
  10. // %kill, %msg, %action
  11. //
  12. //-----------------------------------------------------------------------------
  13. using System;
  14. using System.Linq;
  15. namespace ProjectGolan.Vrobot3.Modules
  16. {
  17. //
  18. // Mod_Admin
  19. //
  20. public class Mod_Admin : IBotModule
  21. {
  22. //
  23. // Mod_Admin constructor
  24. //
  25. public Mod_Admin(Bot bot) :
  26. base(bot)
  27. {
  28. commands["kill"] = new BotCommandStructure{
  29. cmd = cmdKill,
  30. role = BotRole.Admin,
  31. help = "Kills all bot instances.\n" +
  32. "Syntax: %kill"
  33. };
  34. commands["msg"] = new BotCommandStructure{
  35. cmd = cmdMsg,
  36. role = BotRole.Admin,
  37. help = "Sends a message.\n" +
  38. "Syntax: %msg channel, msg\n" +
  39. "Example: %msg #general, ur all dumb"
  40. };
  41. commands["action"] = new BotCommandStructure{
  42. cmd = cmdAction,
  43. role = BotRole.Admin,
  44. help = "Sends an action.\n" +
  45. "Syntax: %action channel, msg\n" +
  46. "Example: %action #general, explodes violently"
  47. };
  48. postSetup();
  49. }
  50. //
  51. // cmdKill
  52. //
  53. public void cmdKill(User usr, Channel channel, String msg)
  54. {
  55. Console.WriteLine("{0}: Killing all instances.", bot.info.serverName);
  56. Program.Instance.end();
  57. }
  58. //
  59. // cmdMsg
  60. //
  61. public void cmdMsg(User usr, Channel channel, String msg)
  62. {
  63. var args = Utils.GetArguments(msg, commands["msg"].help, 2, 2);
  64. bot.message(ulong.Parse(args[0]), args[1].Trim());
  65. }
  66. //
  67. // cmdAction
  68. //
  69. public void cmdAction(User usr, Channel channel, String msg)
  70. {
  71. var args = Utils.GetArguments(msg, commands["action"].help, 2, 2);
  72. bot.action(ulong.Parse(args[0]), args[1].Trim());
  73. }
  74. }
  75. }