Advertisement
Guest User

Untitled

a guest
Jul 29th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. package scripts;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.input.Keyboard;
  5. import org.tribot.api2007.Player;
  6. import org.tribot.api2007.Players;
  7. import org.tribot.api2007.types.RSPlayer;
  8. import org.tribot.script.Script;
  9. import org.tribot.script.ScriptManifest;
  10.  
  11. import java.util.ArrayList;
  12.  
  13. @ScriptManifest(authors = {"Me"}, category = "Tools", name = "MyScript", description = "My script")
  14. public class MyScript extends Script {
  15.  
  16. private final int DISTANCE = 10;
  17.  
  18. private Cleverbot cleverBot = new Cleverbot();
  19. private ArrayList<String> messages = new ArrayList<String>();
  20.  
  21. @Override
  22. public void run() {
  23. for (RSPlayer player : Players.getAll()) {
  24. messages.add(player.getChatMessage());
  25. }
  26. while (true) {
  27. sleep(loop());
  28. }
  29. }
  30.  
  31. public int loop() {
  32.  
  33.  
  34. try {
  35. for (RSPlayer player : Players.getAll()) {
  36.  
  37. if (Player.getRSPlayer().getName() != player.getName()) {
  38. String message = player.getChatMessage();
  39. if (!messages.contains(message) && Player.getPosition().distanceTo(player.getPosition()) <= DISTANCE) {
  40. Keyboard.typeSend(reformat(cleverBot.sendMessage(message)));
  41. messages.add(message);
  42. }
  43. }
  44. }
  45. }
  46. catch (Exception e) {
  47. }
  48. return General.random(50, 300);
  49.  
  50. }
  51.  
  52. public static String reformat(String message) {
  53. return message.toLowerCase()
  54. .replaceAll("[.,']", "")
  55. .replaceAll("cleverbot", "noob")
  56. .replaceAll("robot", "noob")
  57. .replaceAll("bot", "noob")
  58. .replaceAll("an ai", "noob")
  59. .replaceAll("human", "noob")
  60. .replaceAll("youre", "ur")
  61. .replaceAll("you", "u")
  62. .replaceAll("why", "y")
  63. .replaceAll("are", "r");
  64. }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement