Guest User

Untitled

a guest
Aug 21st, 2019
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Override
  2. public void onUpdateReceived(Update update) {
  3. String[] message = update.getMessage().getText().split(" ");
  4. User user = update.getMessage().getFrom();
  5. String answer = "help";
  6. switch (message[0]){
  7. case "/help":
  8. answer = "/shutdown - выключение бота";
  9. break;
  10. case "/shutdown":
  11. if (!isDeveloper(user)){
  12. answer = "Ты не мой создатель." +
  13. "\nКоманды доступны только ему!";
  14. break;
  15. }
  16. Util.shutdown();
  17. answer = "Команда выполнена!";
  18. break;
  19. }
  20. if (answer.equalsIgnoreCase("help")) answer = "Я не знаю такой команды" +
  21. "\nТвой id: "+user.getId()+
  22. "\nТебя зовут: "+user.getFirstName()+" "+user.getLastName()+
  23. "\nТвой ник: "+user.getUserName();
  24. sendMsg(update.getMessage().getChatId().toString(), answer);
  25. log(Level.INFO, "Message: ", Arrays.toString(message));
  26. }
  27.  
  28. ------------------------------------------------------------------------------------
  29. public static void shutdown(){
  30. ShutdownCommand shutdownCommand = new ShutdownCommand();
  31. shutdownCommand.run();
  32. }
  33.  
  34. ------------------------------------------------------------------------------------
  35. public class ShutdownCommand implements Runnable {
  36. @Override
  37. public void run() {
  38. log(Level.WARNING, "Command: ", "shutdown bot");
  39. try {
  40. TimeUnit.SECONDS.sleep(3);
  41. } catch (InterruptedException e) {
  42. e.printStackTrace();
  43. }
  44. System.exit(-1);
  45. }
  46. }
RAW Paste Data