@Override public void chatMessageReceived(ChatMessage received) throws SkypeException { String msg = received.getContent(); Pattern pattern = Pattern.compile("http://(www\\.){0,1}netpincer.*NPsession.*"); Matcher matcher = pattern.matcher(msg); if (matcher.find()) { received .getChat() .send("Netpincer session detected: Looking for " + getRandomThing() + "... (bandit)"); } }
/** * This is the main method of this class. For every message user sends it checks if it is * "!addlister" and if it then it clears the message from skype and adds one {@link * GroupChatListener listener} for this specific chat. * * <p>Also this method checks if user has activated edit lister. If he has then it also registers * and one {@link GroupChatEditListener editListener} for the specific chat. * * @see com.skype.ChatMessageListener#chatMessageSent(com.skype.ChatMessage) */ @Override public void chatMessageSent(ChatMessage sent) throws SkypeException { if (!sent.getContent().equalsIgnoreCase("!addlistener")) return; Chat chat = sent.getChat(); if (!registeredChats.contains(chat)) { sent.setContent(""); GroupChatListener group = new GroupChatListener(chat); Skype.addChatMessageListener(group); // System.out.println(chat.getWindowTitle()); if (Config.EnableEdits) Skype.addChatMessageEditListener(group.getEditListener()); registeredChats.add(chat); } }
public static void runCommand(ChatMessage chatMessage) throws SkypeException { String message = chatMessage.getContent(); String[] messageArray = message.split(" "); String sentCommand = messageArray[0].replace("!", "").toLowerCase(); if (System.currentTimeMillis() - lastCalled < 1000) { return; } if (!message.startsWith("!")) { return; } if (commandMap.containsKey(sentCommand)) { SkypeCommand command = commandMap.get(sentCommand); if (messageArray.length >= command.getRequiredArgs() + 1) { command.execute(chatMessage, messageArray); } else { chatMessage.getChat().send(command.getUsage()); } lastCalled = System.currentTimeMillis(); } }