Python:Vandal Bazooka/Irc.py

From Botwiki

Jump to: navigation, search
#!/usr/bin/python
# -*- coding: utf-8  -*-
"""
irc.py - IRC File
Author: Filnik, 2007
Source: Some code stolen from: http://www.devshed.com/c/a/Python/Python-and-IRC/3/
About: http://botwiki.sno.cc/wiki/Botwiki:Vandal_Bazooka
License: Distributed under the terms of the MIT license.
Version: 1.05
"""
import socket
import config
 
docstring = \
"""Welcomed to the VandalBazooka's Tool! This is the IRC program that is used
to take the real-time list from the official Wikimedia's Bot. Don't worry
about this script, let it in background untill you want to close (rember to
close also this script and not only the parser, otherwise you can have problems
further!).
 
Good Patrolling, Filnik
 
----------------------------------> START <------------------------------------
"""
 
print docstring
network = config.network
nick = config.nick
channel = config.channel
port = 6667
irc = socket.socket (socket.AF_INET, socket.SOCK_STREAM)
irc.connect ((network, port ))
print irc.recv (4096)
irc.send ('NICK %s\r\n' % nick)
irc.send ('USER %s %s %s :AntiVandalIRCBot written by Filnik\r\n' % (nick, nick, nick))
irc.send ('JOIN %s\r\n' % channel)
#irc.send ('PRIVMSG :Hello Filnik.\r\n' % channel)
while 1:
    data = irc.recv (4096)
    if data.find('PING') != -1:
        irc.send('PONG '+ data.split()[1] + '\r\n')
    print data
    ircchannel = channel.split('#')
    rightparser = ircchannel[1] 
    if 'http://' + rightparser + '.org' in data:
         try:
 
            rock = file('VandalData.txt', 'a')
            rock.write(data.decode('Latin-1') + '\n')
            rock.close()
            """
            import codecs
            f = codecs.open('VandalData.txt', 'a', 'Latin-1')
            f.write(data + '\n')
            f.close()"""
            data = ''
         except:
            pass
Personal tools