Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
monitors irc.lfnet.org:6667#bitcoin and extracts user details
################################################################################
# bitmon
# Description: monitors irc.lfnet.org:6667#bitcoin and extracts user details
# Author: Brendan Coles <bcoles@gmail.com>
# 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
You can’t perform that action at this time.