Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bcoles
Created May 20, 2011 10:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bcoles/982695 to your computer and use it in GitHub Desktop.
Save bcoles/982695 to your computer and use it in GitHub Desktop.
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