ninjamuffinz Posted February 18, 2016 Share Posted February 18, 2016 Hi guys. I need to listen to the clan chat and private messages that my account receives and act on them. I'm not sure how I can achieve this however. Basically I'd like my bot to join a clan chat, and when another character says a certain phrase it acts on it. Is this even possible? Thanks Quote Link to comment Share on other sites More sharing options...
Explv Posted February 18, 2016 Share Posted February 18, 2016 Hi guys. I need to listen to the clan chat and private messages that my account receives and act on them. I'm not sure how I can achieve this however. Basically I'd like my bot to join a clan chat, and when another character says a certain phrase it acts on it. Is this even possible? Thanks @Override public void onMessage(Message message){ if(message.getType() == Message.MessageType.PLAYER){ String text = message.getMessage(); } } That should get you started 1 Quote Link to comment Share on other sites More sharing options...
ninjamuffinz Posted February 18, 2016 Author Share Posted February 18, 2016 Awesome. Thanks! Will that also work for clan chat messages if I change the type? Quote Link to comment Share on other sites More sharing options...
Explv Posted February 18, 2016 Share Posted February 18, 2016 (edited) Awesome. Thanks! Will that also work for clan chat messages if I change the type? The only MessageTypes available are: GAME PLAYER RECEIVE_TRADE So GAME will include clan chat messages. Edited February 18, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
ninjamuffinz Posted February 18, 2016 Author Share Posted February 18, 2016 Oh I see, is there anyway I can differentiate between clan chat and private chat messages? Thanks for your help. Quote Link to comment Share on other sites More sharing options...
Explv Posted February 18, 2016 Share Posted February 18, 2016 (edited) Oh I see, is there anyway I can differentiate between clan chat and private chat messages? Thanks for your help. I think it might be ID 9 for clan chat: @Override public void onMessage(Message message){ if(message.getTypeId() == 9){ // do something } } Edited February 18, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
ninjamuffinz Posted February 18, 2016 Author Share Posted February 18, 2016 Yes that's perfect! thank you for your help! 1 Quote Link to comment Share on other sites More sharing options...
ninjamuffinz Posted February 18, 2016 Author Share Posted February 18, 2016 Ok so I have another issue. @Override public void onMessage(Message message){ log("Message received."); String messageReceived = message.getMessage(); if(message.getTypeId() == 9){ log("Clan chat message."); if(messageReceived == "/!Test"){ log("Test received.."); getKeyboard().typeString("/Success!", true); } log(messageReceived); } Although it appears in my logger as !Test, the if statement doesn't resolve as true so the code wont execute? Am I missing something. Quote Link to comment Share on other sites More sharing options...
Explv Posted February 18, 2016 Share Posted February 18, 2016 Ok so I have another issue. @Override public void onMessage(Message message){ log("Message received."); String messageReceived = message.getMessage(); if(message.getTypeId() == 9){ log("Clan chat message."); if(messageReceived == "/!Test"){ log("Test received.."); getKeyboard().typeString("/Success!", true); } log(messageReceived); } Although it appears in my logger as !Test, the if statement doesn't resolve as true so the code wont execute? Am I missing something. String values are compared using .equals() not == Also the message will not contain / It should be: if(messageReceived.equals("!Test")){ log("Test received.."); getKeyboard().typeString("/Success!", true); } 1 Quote Link to comment Share on other sites More sharing options...
ninjamuffinz Posted February 18, 2016 Author Share Posted February 18, 2016 (edited) Oh yeah of course! I knew it would be something simple like that! Thanks again! I don't suppose you know how I can grab the message senders character name and store it in a variable? I figured out. Thanks for your help though! Edited February 18, 2016 by ninjamuffinz Quote Link to comment Share on other sites More sharing options...