Created
August 11, 2014 02:28
-
-
Save Pavelovich/e501e8ad92196234b700 to your computer and use it in GitHub Desktop.
Simple IRC bot
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
#!/usr/bin/python | |
import socket | |
import sys | |
server = "chat.freenode.net" | |
channel = "#orain" | |
nick = "Sasha_IRC_bot" | |
irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
print "Connecting to "+ server +"..." | |
irc.connect((server, 6667)) | |
irc.send("nick "+ nick +"\r\n") | |
irc.send("PONG\r\n") | |
irc.send('USER %s %s %s :%s %s\r\n' % (nick, nick, nick, nick, nick[::-1])) | |
irc.send("join "+ channel +"\r\n") | |
while 1: | |
text = irc.recv(2048) | |
print text | |
if "PING" in text: | |
irc.send("PONG\r\n") | |
if text: | |
file = open("irc_log.txt", 'a') | |
file.write(text) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment