10.07.2015 Views

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

Lotus Instant Messaging/ Web Conferencing ... - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

extends SametimeBotThe class then overrides the four methods that are defined in the parent classwith application-specific values (see Example 3-13).Example 3-13 Class specific method overridesprotected String getWELCOME_TEXT(){return "welcome to the FAQ Bot.";}protected String getSERVER(){return "itsotest-st31.cam.itso.ibm.com";}protected String getAPP_NAME(){return "FAQ Bot";}protected String getAPP_PASSWORD(){return "mybotpassword";}We then come to the application-specific logic section of the bot. TheSametimeBot class defines an abstract doTextReceived() method(Example 3-14). It takes an ImEvent object (from the textReceived() method) andthe text the user sent as parameters. This method is then overridden in theFAQBot subclass and any other classes created that extend SametimeBot.Example 3-14 doTextReceived() methodprotected String doTextReceived(ImEvent event, String receivedText){Im im = event.getIm();String returnText = "";System.out.println(this.getServletName() + ": " +im.getPartner().getDisplayName() + " is requesting : " +receivedText);returnText = replaceSubString(receivedText, "?", "");returnText = replaceSubString(returnText, "'", "");return questionSearch(returnText.toUpperCase().trim());Chapter 3. Sametime Bots 67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!