GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


gentoogamer Bot source code by gaminggeek
import org.jibble.pircbot.*;
import com.google.soap.search.*;

public class gentoogamer extends PircBot {
        
    private static final String googleKey = 
    "#######################";
        
    public gentoogamer() {
        this.setName("gentoogamer");
        }
    protected void onJoin(String channel, String sender, String login, String hostname) {
    if(!(sender.equalsIgnoreCase(getNick()))){ 
      sendMessage(channel, "Hello " +sender);
      }
    }
    public void onMessage(String channel, String sender,
                       String login, String hostname, String message) {
        if (message.equalsIgnoreCase("!time")) {
            String time = new java.util.Date().toString();
            sendMessage(channel, sender + ": Gaminggeek makes it " + time);
    
        }if (message.equalsIgnoreCase("Hi")) {
            sendMessage(channel, sender + ": Hello, how are you? ");

    }if (message.equalsIgnoreCase("bye")) {
            sendMessage(channel, "see-ya later ");

    }if (message.equalsIgnoreCase("fuck")) {
            sendMessage(channel, sender + ": Same to you buddy! ");

    }if (message.equalsIgnoreCase("shit")) {
            sendAction(channel, "deficates all over the potty mouths's face");
        sendAction(channel, "then beats the ''shit'' out of the potty mouth");
    
    }if (message.equalsIgnoreCase("!op")) {
            sendMessage(channel, sender + ": the ops are : gaminggeek ");

    }if (message.equalsIgnoreCase("lol")) {
            sendMessage(channel, "lol ");

    }if (message.equalsIgnoreCase("how are you?")) {
            sendMessage(channel, "I am good and you? ");

    }if (message.equalsIgnoreCase("good")) {
            sendMessage(channel, "Thats good to hear ");

    }if (message.equalsIgnoreCase("fine")) {
            sendMessage(channel, "ah ok just fine?");
        
    }if (message.equalsIgnoreCase("yes")) {
            sendMessage(channel, "Thats nice to know");
        
    }if (message.equalsIgnoreCase("gentoogamer: shut up")) {
            sendMessage(channel, "no you can't make me!!");
        
    }if (message.equalsIgnoreCase("gentoogamer, shut up")) {
            sendMessage(channel, "no you can't make me!!");
        
    }if (message.equalsIgnoreCase("gentoogamer shut up")) {
            sendMessage(channel, "no you can't make me!!");
        
    }if (message.equalsIgnoreCase("bad")) {
            sendMessage(channel, "Awwww Whats Up?");

    }if(message.equalsIgnoreCase("!mute")&&sender.equals("gaminggeek")) {
     sendMessage(channel, "sorry not implemented");
    
//    }if (message.startsWith("hey")) {
//    sendMessage(channel, message.substring(0).substring(message.indexOf("hey ")));
    
    }if (message.equalsIgnoreCase("!code")) {
            sendNotice(channel, sender + " is posting some code peoples");

    }if(message.equalsIgnoreCase("!die")&&sender.equals("gaminggeek")) {
            partChannel(channel, "Gaminggeek killed me");
            quitServer("Gaminggeek killed me");
            dispose();
            System.exit(0);
    
    }if(message.startsWith("!do")) {
    sendAction(channel, message.substring(1).substring(message.indexOf(" ")));
        
    }if (message.equalsIgnoreCase("!tester")) {
        sendNotice(channel, "*TAP* *TAP* is this thing on?");
        
    }if (message.equalsIgnoreCase("!banana")) {
    ;sendAction(channel, " wacks bill gates to the inch of his life with a banana, kicks him hard in balls and then kills him.");
        
    //public void onMessage(String channel, String sender, String login,
    //String hostname, String message) {
    
    message = message.toLowerCase().trim( );
    if (message.startsWith("!google ")) {
    String searchTerms = message.substring(8);
     
    String result = null;
    try { GoogleSearch search = new GoogleSearch( );
    search.setKey(googleKey); 
    search.setQueryString(searchTerms);
    search.setMaxResults(1); 
    GoogleSearchResult searchResult = search.doSearch( ); 
    GoogleSearchResultElement[] elements = 
        searchResult.getResultElements( ); 
    if (elements.length == 1) { 
       GoogleSearchResultElement element = elements[0]; 
       // Remove all HTML tags from the title. 
       String title = element.getTitle( ).replaceAll("<.*?>", 
    ""); 
    result = element.getURL( ) + " (" + title + ")"; 
    if (!element.getCachedSize( ).equals("0")) { 
    result = result + " - " + element.getCachedSize( );
    } 
    } 
} 
    catch (GoogleSearchFault e) { 
      // Something went wrong. Say why. 
      result = "Unable to perform your search: " + e; 
    }
    if (result == null) {
      // No results were found for the search terms.
      result = "I could not find anything on Google.";
    }
     // Send the result to the channel. 
     sendMessage(channel, sender + ": " + result); 
     }
      }
   }
}