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.

83 lines
2.2KB

  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. flags = BotCommandFlags.AdminOnly,
  31. help = "Kills all bot instances.\n" +
  32. "Syntax: %kill"
  33. };
  34. commands["msg"] = new BotCommandStructure{
  35. cmd = cmdMsg,
  36. flags = BotCommandFlags.AdminOnly,
  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. flags = BotCommandFlags.AdminOnly,
  44. help = "Sends an action.\n" +
  45. "Syntax: %action channel, msg\n" +
  46. "Example: %action #general, explodes violently"
  47. };
  48. }
  49. //
  50. // cmdKill
  51. //
  52. public void cmdKill(User usr, Channel channel, String msg)
  53. {
  54. Console.WriteLine("{0}: Killing all instances.", bot.info.serverName);
  55. Program.Instance.end();
  56. }
  57. //
  58. // cmdMsg
  59. //
  60. public void cmdMsg(User usr, Channel channel, String msg)
  61. {
  62. var args = Utils.GetArguments(msg, commands["msg"].help, 2, 2);
  63. bot.message(ulong.Parse(args[0]), args[1].Trim());
  64. }
  65. //
  66. // cmdAction
  67. //
  68. public void cmdAction(User usr, Channel channel, String msg)
  69. {
  70. var args = Utils.GetArguments(msg, commands["action"].help, 2, 2);
  71. bot.action(ulong.Parse(args[0]), args[1].Trim());
  72. }
  73. }
  74. }