Advertisement
Guest User

Untitled

a guest
Mar 8th, 2012
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.94 KB | None | 0 0
  1. #!/usr/bin/python
  2. version = '2.1.5'
  3. import sys
  4. import os
  5. import string
  6. import random  
  7. import urllib
  8. import socket
  9. import time
  10. import re
  11. import StringIO
  12. import getpass
  13. import shelve
  14. import traceback
  15. import csv
  16. import pickle
  17. from time import *
  18.  
  19. irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
  20. irc.connect ( ( server, port) )
  21. irc.send ( 'NICK %s\r\n' % myname)
  22. irc.send ( 'USER %s %s %s :%s\r\n' % (identd, identd, identd, real_name))
  23.  
  24. # Here we make sure to process the login and stuff correctly
  25. connected = 0
  26. while True:
  27.    try:
  28.       data = irc.recv ( 4096 )
  29.       raw = data.split()
  30.       print data
  31.       if connected == 2:
  32.          break
  33.       if data.find ( 'PING' ) != -1:
  34.          irc.send( 'PONG ' + data.split() [ 1 ] + '\r\n' )
  35.       if data.find('This nickname is registered and protected.') != -1:
  36.          identify()
  37.       if data.find('End of /MOTD command.') != -1:
  38.          perform()
  39.       def perform():
  40.          irc.send('mode %s +B\r\n' % myname)
  41.          irc.send('mode %s +B\r\n' % myname)
  42.          irc.send('mode %s +B\r\n' % myname)
  43.          irc.send('JOIN %s\r\n' % channels)
  44.          irc.send('JOIN %s\r\n' % channels)
  45.          irc.send('JOIN %s\r\n' % channels)
  46.          connected = connected + 1
  47.       def identify():
  48.          irc.send('privmsg NickServ :Identify %s\r\n' % nickpass)
  49.          irc.send('privmsg NickServ :update\r\n')
  50.          irc.send('JOIN %s\r\n' % channels)
  51.          irc.send('JOIN %s\r\n' % channels)
  52.          irc.send('mode %s +B\r\n' % myname)
  53.          irc.send('mode %s +B\r\n' % myname)
  54.          connected = connected + 1
  55.  
  56. # We are connected, lets fuck up with the messages to suit us :D
  57. message_prefix = "!"
  58.  
  59. def _processMessage(raw):
  60.    sender = raw[0][1:]
  61.    data = {"nick": sender.split("!")[0], "ident": sender.split(sender.split("!")[1].split("@")[0]),
  62.                  "host": sender.split(sender.split("!")[1].split("@")[1]), "type": raw[1], "source": raw[2],
  63.                  "command": raw[3][1:]}
  64.    if len(raw) > 3:
  65.       data["args"] = raw[3:]
  66.    return data
  67.  
  68. while True:
  69.    try:
  70.       data = irc.recv ( 4096 )
  71.       raw = data.split()
  72.       TargetDict = {}
  73.       print data
  74.       if data.find ( 'PING' ) != -1:
  75.          irc.send( 'PONG ' + data.split() [ 1 ] + '\r\n' )
  76.       if data.find(":!elitebnc") != -1:
  77.          if len(raw) != 5:      
  78.             channel = raw[2]
  79.             checksock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  80.             try:
  81.                checksock.connect(('alpdha.elitebnc.net', 1337))
  82.                checksock.shutdown(2)
  83.                alpha = 'Online!';
  84.             except:
  85.                checksock.shutdown(0)
  86.                alpha = 'Offline!';
  87.             irc.send('notice %s :Alpha: %s\r\n' % (nick, alpha))
  88.    except:
  89.       fp = StringIO.StringIO()
  90.       traceback.print_exc(file=fp)
  91.       message = fp.getvalue()
  92.       irc.send('privmsg #Aha2Y :error occured. %s\r\n' % repr(message))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement