EG Information
Training Missions
Knowledge Bank
|
|
Enigma Group's Code Bank
JavaBoBy: ishkur88 - Date Submitted: 2008-09-13 12:57:38 package ircbot; /** * JavaBot (version 1.2) * * MIT License, dydx (Josh Sandlin) <dydx@thenullbyte.org> * */ import java.io.*; import java.net.*; import java.util.regex.*; import java.util.Date; public class Main { { //connection variables String server = "irc.snappeh.com"; String channel = "#enigmagroup"; int port = 6667; //for security try { //our socket we're connected with //out output stream //our input stream //authenticate with the server bw.write( "NICK " + nick + "n" ); bw.write( "USER " + login + " thenullbyte.org JB: Java Botn" ); bw.flush(); //join a channel bw.write( "JOIN " + channel + "n" ); bw.write( "PRIVMSG " + channel + " :Whats up everybody?n" ); bw.flush(); System. out. println( "Successfully connected to IRC" ); while( ( currLine = br.readLine() ) != null ) { //checks for PING, if one is found; return a PONG Pattern pingRegex = Pattern.compile( "^PING", Pattern.CASE_INSENSITIVE ); Matcher ping = pingRegex.matcher( currLine ); if( ping.find() ) { bw.write( "PONG " + channel + "n" ); bw.flush(); } //check for ownership Pattern checkOwner = Pattern.compile( "^:"+owner, Pattern.CASE_INSENSITIVE ); Matcher ownership = checkOwner.matcher( currLine ); //!exit - quit current irc room Pattern exitRegex = Pattern.compile( "!exit", Pattern.CASE_INSENSITIVE ); Matcher exit = exitRegex.matcher( currLine ); if( exit.find() && ownership.find() ) { bw.write( "PRIVMSG " + channel + " :Bye Byen" ); bw.write( "PART " + channel + "n" ); bw.flush(); irc.close(); } //!time - return current time Pattern timeRegex = Pattern.compile( "!time", Pattern.CASE_INSENSITIVE ); Matcher time = timeRegex.matcher( currLine ); if( time.find() && ownership.find() ) { bw.write( "PRIVMSG " + channel + " :" + d +"n" ); bw.flush(); } //!sayhi - shows a little message saying hello Pattern helloRegex = Pattern.compile( "!sayhi", Pattern.CASE_INSENSITIVE ); Matcher hello = helloRegex.matcher( currLine ); if( hello.find() && ownership.find() ) { bw.write( "PRIVMSG " + channel + " :Hi, I'm a JavaBot. I was coded by dydx in Java!n"); bw.flush(); } //!join <room> - changes to a new room and sets the variables accordingly Pattern joinRegex = Pattern.compile( "!join", Pattern.CASE_INSENSITIVE ); Matcher join = joinRegex.matcher( currLine ); if( join.find() && ownership.find() ) { String[] token = currLine. split( " " ); bw.write( "PRIVMSG " + channel + " :Im going over to " + token[4] + "n" ); bw.write( "PART " + channel + "n" ); channel = token[4]; bw.write( "JOIN " + channel + "n" ); bw.flush(); } //just to be mean ;) Pattern howDoI = Pattern.compile( "how do i", Pattern.CASE_INSENSITIVE ); Matcher how = howDoI.matcher( currLine ); if( how.find() ) { bw.write( "PRIVMSG " + channel + " :just fucking google it...n" ); bw.flush(); } Pattern whyRegex = Pattern.compile( "why", Pattern.CASE_INSENSITIVE ); Matcher why = whyRegex.matcher( currLine ); if( why.find() ) { bw.write( "PRIVMSG " + channel + " :DONT ASK QUESTIONS!n" ); bw.flush(); } } System. err. println( "No such host" ); System. err. println( "There was an error connecting to the host" ); } } }
|
| Return to
java category list |
|
|
Who's Online
483 Guests, 101 Users ckryptix, Ios, viper0i0, Diznablo, rabbidmind, asapong, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nicid1, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019, Jakabo |
| |
|
|
|
|
|