Ich suche ein Programm, das automatisch alle 59 Minuten einen Beitrag in einem IRC macht. Sinn der Sache ist, dort wird man gekickt, wenn man 60 Minuten idelt. Hättet ihr da eine Idee? Wäre dankbar für eure Hilfe.
![](https://www.winhistory-forum.net/core/images/avatars/d8/225-d8101a9f648eab82ac61ee46040ee8fb2907cbbf.webp)
IRC Bot umgehen
-
-
Schreib dir deinen IRC-Client oder lad dir einen OpenSource-Client runter und bau die Funktion ein
-
Gibts da nicht ne fertige Lösung?
-
Weis nicht. Vielleicht kannste ja irgendwo im Menü von irgendnem Client ne automatische Statusmeldung einschalten, die dann das erledigt oder so
-
IRC Clients zu schreiben ist sehr einfach
das kriegst du auch so hin.
-
Du hast nicht zufällig irgendwo eine Anleitung, oder?
-
Unter .net sind das nur noch ein paar Codezeilen, man muss dann nur noch die jeweiligen Protokolle etwas kennen.
EDIT: Hier mal in verschiedenen Programmiersprachen:
http://www.tutorials.de/forum/c-c-tuto…grammieren.html
http://www.coding-board.de/board/showthread.php?t=1064
http://board.raidrush.ws/showthread.php?t=98318
Das letzte scheint gut zu sein (und nach VB.net portierbar, was das alles sehr erleichtert)
Und noch das: http://www.visual-basic-forum.de/wiki_irc_client.html -
Hm. Hab mal in Java so was Bot-mäßiges geschrieben.
Java
Alles anzeigenpackage bot; import java.io.*; import java.net.*; import java.util.regex.*; public class Bot { private final String server = "irc.euirc.net"; private final int port = 6667; private final String nick = "euterhut"; private final String hostname = "IHaveNoIdeaWhatThisDoes"; private final String servername = "IHaveNoIdeaWhatThisDoes"; private final String realname = "Fritz"; private final String channel = "#kirschmet"; private Socket irc; private BufferedWriter out; private BufferedReader in; private boolean running; private boolean joined; /** * Connect to the given IRC server. **/ private void connect() throws IOException { System.out.println("Connecting..."); irc = new Socket(server, port); out = new BufferedWriter(new OutputStreamWriter(irc.getOutputStream(), "UTF-8")); in = new BufferedReader(new InputStreamReader(irc.getInputStream(), "UTF-8")); out.write("NICK " + nick + "\n"); out.write("USER " + nick + " " + hostname + " " + servername + " " + realname + "\n"); out.flush(); joined = false; running = true; System.out.println("Connected."); } /** * The most important method. Handles PING requests and everything else. **/ private void communicate() throws IOException { // loop forever while(running) { // New message coming in! if(in.ready()) { /* This is called every time a message arrives. */ /* NOTE: Could also be server messages, PINGs etc… */ String line = in.readLine(); // Respond to PING so that we don't get disconnected if(isPing(line)) { doPing(line.substring(5)); } // Join if we haven't joined the channel yet if(!joined && isConnected(line)) { join(); } // Output the line for debugging purposes System.out.println(line); } /* This is called approximately all 100 milliseconds, probably less often. */ /* Adjust to your liking. */ /* Note that it has to be called very often to check for new PING requests. */ wait(100); // SPAM THE CHANNEL FOR GREAT JUSTICE! if(joined) say("Hello!"); } } /** * Super-Awesome waiting method, yeah! */ private void wait(int milliseconds) { try { Thread.sleep(milliseconds); } catch (InterruptedException e) { System.err.println("Sleeping thread interrupted."); } } /** * Determines whether the given message is a confirmation * that you have successfully connected to the IRC server. */ private boolean isConnected(String line) { Pattern p = Pattern.compile("End of /MOTD command.", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(line); return m.find(); } /** * Join the given channel. */ private void join() throws IOException { System.out.println("Joining channel..."); out.write( "JOIN " + channel + "\n" ); out.flush(); joined = true; System.out.println("Joined channel."); } /** * Figure out if an incoming message is a PING request. */ private boolean isPing(String line) { Pattern p = Pattern.compile("^PING", Pattern.CASE_INSENSITIVE); Matcher m = p.matcher(line); return m.find(); } /** * Respond to a PING message. Necessary so you don't get disconnected. */ private void doPing(String receiver) throws IOException { out.write("PONG " + receiver + "\n"); out.flush(); System.out.println("Responded to ping."); } /** * Broadcast a message to the whole channel */ private void say(String msg) throws IOException { System.out.println("Saying '" + msg + "'"); out.write("PRIVMSG " + channel + " :" + msg + "\n"); out.flush(); } /** * The main method. Nothing fancy here... */ public static void main(String[] args) { Bot bot = new Bot(); try { bot.connect(); bot.communicate(); } catch (IOException e) { System.err.println("Error :(\n" + e.getMessage()); } } }
-
ein hoch auf java
-
eudahut
Jetzt mitmachen!
Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!