UnhelpfulBotCommand.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Text.Json;
  2. using Microsoft.AspNetCore.Http;
  3. using SlackAPI;
  4. using sera_slackbot.Library;
  5. namespace sera_slackbot.Commands
  6. {
  7. public class UnhelpfulBotCommand : IBotCommand
  8. {
  9. private string channelId;
  10. private string userId;
  11. private string message;
  12. public UnhelpfulBotCommand()
  13. {
  14. }
  15. public void ExtractValidData(JsonElement slackEvent)
  16. {
  17. this.channelId = slackEvent.GetProperty("channel").ToString();
  18. this.userId = slackEvent.GetProperty("user").ToString();
  19. }
  20. public bool WillTrigger(JsonElement slackEvent)
  21. {
  22. return true;
  23. }
  24. public dynamic Run(SlackClient client)
  25. {
  26. message = $"I'm sorry, \u003C@{userId}\u003E, I don't understand.";
  27. client.PostMessage(response => { }, channelId, message);
  28. return new
  29. {
  30. code = StatusCodes.Status200OK,
  31. body = ""
  32. };
  33. }
  34. }
  35. }