Created
June 18, 2012 00:10
-
-
Save Bakies/2946130 to your computer and use it in GitHub Desktop.
Python connect to IRC
This file contains 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
import socket, string, time, thread | |
SERVER = '' | |
PORT = 6667 | |
NICKNAME = '' | |
CHANNEL = '' | |
def main(): | |
global IRC | |
IRC = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
IRC.connect((SERVER, PORT)) | |
thread.start_new_thread(Listener(),("Thread No:1",2)) | |
def send_data(command): | |
IRC.send(command + '\n') | |
def Listener(): | |
send_data('USER Blah') | |
send_data('NICK Blah') | |
while (1): | |
buffer = IRC.recv(1024) | |
msg = string.split(buffer) | |
if msg[0] == "PING": | |
print 'Pinged!' | |
IRC.send("PONG %s" % msg[1] + '\n') | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice