Skip to content

Instantly share code, notes, and snippets.

@Bakies
Created June 18, 2012 00:10
Show Gist options
  • Save Bakies/2946130 to your computer and use it in GitHub Desktop.
Save Bakies/2946130 to your computer and use it in GitHub Desktop.
Python connect to IRC
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()
@securityh1
Copy link

weird but the msg received doesn't come with PING

@nezu-lab
Copy link

nezu-lab commented Dec 1, 2020

nice

@krootca
Copy link

krootca commented Jan 22, 2022

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment