Created
November 7, 2012 10:19
-
-
Save neuro-sys/4030728 to your computer and use it in GitHub Desktop.
IRC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package irc; | |
| import java.io.*; | |
| import java.net.*; | |
| /** | |
| * Created with IntelliJ IDEA. | |
| * User: JFDEV | |
| * Date: 30.10.2012 | |
| * Time: 17:24 | |
| * To change this template use File | Settings | File Templates. | |
| */ | |
| public class IrcBot { | |
| public static void main (String[] args) { | |
| try { | |
| Socket socket = new Socket("irc.freenode.net", 6667); | |
| BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); | |
| BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); | |
| writer.write("NICK sabribeyler\r\n"); | |
| writer.write("USER foo 8 * : foo\r\n"); | |
| String line = null; | |
| writer.write("JOIN #archlinux-tr\r\n"); | |
| writer.flush(); | |
| while ((line = reader.readLine( )) != null) { | |
| System.out.println(line); | |
| if (line.contains("sabribeyler")) { | |
| writer.write("PRIVMSG #archlinux-tr :foo\r\n"); | |
| writer.flush(); | |
| } | |
| } | |
| } catch (Exception e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment