-
-
Save shinohai/f3c4528d987b9890e056 to your computer and use it in GitHub Desktop.
monitors irc.lfnet.org:6667#bitcoin and extracts user details
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
################################################################################ | |
# bitmon | |
# Description: monitors irc.lfnet.org:6667#bitcoin and extracts user details | |
# Author: Brendan Coles <[email protected]> | |
# Version: 0.1-20110520 | |
################################################################################ | |
import socket, string | |
botname = 'u1rt6zQzvGpS1Zz' # change this | |
channel = '#bitcoin' | |
network = 'irc.lfnet.org' | |
port = 6667 | |
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) | |
irc.connect ( ( network, port ) ) | |
irc.send ( 'NICK %s\r\n' % (botname)) | |
irc.send ( 'USER %s 8 * : %s\r\n' % (botname, botname)) | |
irc.send ( 'JOIN %s\r\n' % (channel) ) | |
while (1): | |
data = irc.recv ( 4096 ) | |
msg = string.split(data) | |
# Respond to PING X request with PONG X | |
if msg[0] == 'PING': | |
irc.send ( 'PONG ' + msg[1] + '\r\n' ) | |
# Send WHO request to each NICK that joins the channel | |
if msg [1] == 'JOIN': | |
message = ':'.join ( data.split ( ':' ) [ 2: ] ) | |
nick = msg[0][:string.find(msg[0],"!")] | |
irc.send ( 'WHO %s\r\n' % (nick)) | |
# Write WHO data to file | |
if msg [1] == '352': | |
user = string.join(string.split(data[:string.find(data,"\n")])[4:]) | |
print user | |
filetxt = open('users.txt', 'a+') | |
filetxt.write(user+"\n") | |
filetxt.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment