Java IRC bot
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.

SnippetsCommand.java 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package com.md87.charliebravo.commands;
  6. import com.md87.charliebravo.Command;
  7. import com.md87.charliebravo.InputHandler;
  8. import com.md87.charliebravo.Response;
  9. /**
  10. *
  11. * @author chris
  12. */
  13. public class SnippetsCommand implements Command {
  14. public void execute(InputHandler handler, Response response, String line) throws Exception {
  15. final StringBuilder builder = new StringBuilder();
  16. for (String snipp : handler.getSnippets(response.getTarget()).getList()) {
  17. if (builder.length() > 0) {
  18. builder.append(", ");
  19. }
  20. builder.append(snipp);
  21. }
  22. response.setInheritFollows(true);
  23. if (builder.length() == 0) {
  24. response.sendMessage("There are no detected snippets", true);
  25. } else {
  26. response.sendMessage("the following snippets are currently registered: "
  27. + builder.toString());
  28. }
  29. }
  30. }