Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2013
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf8 -*-
  3.  
  4. try:
  5.     from twisted.words.protocols import oscar
  6.     from twisted.internet import protocol, reactor
  7. except:
  8.     print 'Import Twisted error!'
  9.  
  10. import os
  11. import datetime
  12.  
  13. SN = '653470894'
  14. PASS =  '###'
  15. hostport = ('login.icq.com', 5238)
  16. icqMode = 1
  17. SendTo = '163797502'
  18.  
  19. class Bot(oscar.BOSConnection):
  20.     capabilities = [oscar.CAP_CHAT]
  21.    
  22.     def initDone(self):
  23.         print "Connection (%s) to server: %s:%s" % (SN, hostport[0], hostport[1])
  24.         self.requestSelfInfo().addCallback(self.gotSelfInfo)
  25.         self.requestSSI().addCallback(self.gotBuddyList)
  26.    
  27.     def gotSelfInfo(self, user):
  28.         self.name = user.name
  29.    
  30.     def gotBuddyList(self, l):
  31.         self.activateSSI()
  32.         self.setProfile("""ICQ Gateway by KorP""")
  33.         self.setIdleTime(0)
  34.         self.clientReady()
  35.    
  36.     def receiveMessage(self, user, multiparts, flags):
  37.         print datetime.datetime.now()
  38.         print user
  39.         msg = 'test'
  40.         self.sendMessage(SendTo, msg)
  41.    
  42. class BotAuth(oscar.OscarAuthenticator):
  43.     print 'Start ICQ connect'
  44.     print 'pid:', os.getpid()
  45.     BOSClass = Bot
  46.  
  47. if __name__ == "__main__":
  48.     protocol.ClientCreator(reactor, BotAuth, SN, PASS, icq=icqMode).connectTCP(*hostport)
  49.     reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement