Purple exclamation mark.svg Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.

Red exclamation mark.svg UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.

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
Share