March 17, 20187 yr Hi, I noticed when i am trying to search for multi word sentences from chatbox e.g. "has happened", it doesn't compute. Thanks to some of the comments in this forums, I understand that rsns use non breaking linebreak, what about inside the chatbox?
March 17, 20187 yr What are you using to search the chatbox? You can use OnMessage to do something whenever the message you want has appeared in the chatbox.
March 17, 20187 yr Author 10 minutes ago, d0zza said: What are you using to search the chatbox? You can use OnMessage to do something whenever the message you want has appeared in the chatbox. Thanks for your reply. Would that method overwrite work for searching substrings with spaces? I am using getChatbox().contains()
March 17, 20187 yr 15 minutes ago, Thanfor said: Thanks for your reply. Would that method overwrite work for searching substrings with spaces? I am using getChatbox().contains() contains method in Chatbox checks for MessegeType instances You want to use the message listener and then do a contains method that checks for sub strings equaling "has happened". You may encounter issues (depending on the method) with, exact phrases though. ("has happened" vs "has happened.")
March 17, 20187 yr 23 minutes ago, Thanfor said: Thanks for your reply. Would that method overwrite work for searching substrings with spaces? I am using getChatbox().contains() Spaces don't need any work for the chatbox, only for player names. Like dreameo said, use the message listener that is part of the osbot api.
March 17, 20187 yr Here is how you would go about doing this. If a player (anyone) types "noob" or "nub" your bot will then reply "im not a noob you are!". public void onMessage(Message message) throws java.lang.InterruptedException { if(message.getType() == Message.MessageType.PLAYER) { if (message.getMessage().contains("noob") || message.getMessage().contains("nub")) { getKeyboard().typeString("im not a noob you are!"); } } } Edited March 17, 20187 yr by DeadPk3r
March 17, 20187 yr And if you want to get recent messages from the chatbox after a while, here is what you will want to do. You add this to your class implements MessageListener and this is the code getChatbox().getMessages(MessageType.PLAYER).get(0).contains("noob") Gets the last player message sent containing noob. I find it useful because I have a message tracking system inside my script.
Create an account or sign in to comment