jabber bot на python

Discussion in 'PHP' started by s.jealousy, 28 May 2011.

  1. s.jealousy

    s.jealousy New Member

    Joined:
    26 May 2011
    Messages:
    2
    Likes Received:
    0
    Reputations:
    0
    Не пинайте сильно, я питон начала учить недавно.
    Вопрос в общем вот в чем. Нужен простенький ботик, который для начала будет хотя бы заходить в сеть. Нашла в сети полно исходников. Но проблема в том что получаю ошибку "/usr/lib/python2.6/dist-packages/xmpp/auth.py:24: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
    import sha,base64,random,dispatcher,re
    /usr/lib/python2.6/dist-packages/xmpp/auth.py:26: DeprecationWarning: the md5 module is deprecated; use hashlib instead
    import md5
    "
    Смысл я поняла, что одни модули устарели и вместо них нужно использовать другие, вот только как?
    Вот один из исходников:
    Code:
    import sys, xmpp
    
    
    class JabberBot:
     def __init__ (self, jid, password):
        jid = xmpp.JID(jid)
        self.user, self.server, self.password = jid.getNode(), jid.getDomain(), password
        self.connect()
        self.auth()
    
    
    
     def connect(self):
        self.conn = xmpp.Client(self.server, debug = [])
        conres = self.conn.connect()
    
        if not conres:
            print "Unable to connect to server %s!" % server
            sys.exit(1)
    
        if conres <> 'tls':
            print "Warning: unable to estabilish secure connection - TLS failed!"
    
        def auth(self):
            authres = self.conn.auth(self.user, self.password)
    
        if not authres:
            print "Unable to authorize on %s - check login/password." % server
            sys.exit(1)
    
        if authres <> 'sasl':
            print """Warning: unable to perform SASL auth os %s.
                   Old authentication method used!""" % server
    
        def register_handler(self, name, handler):
            self.conn.RegisterHandler(name, handler)
    
        def step_on(self):
            try:
                self.conn.Process(1)
            except KeyboardInterrupt: return 0
            return 1
    
        def start(self):
            self.conn.sendInitPresence()
            print 'Bot started!'
            while self.step_on(): pass
     
  2. Gifts

    Gifts Green member

    Joined:
    25 Apr 2008
    Messages:
    2,494
    Likes Received:
    807
    Reputations:
    614
    s.jealousy на варнинги DeprecationWarning можно не обращать внимание.

    В качестве либы для работы с джаббером рекомендую SleekXMPP
     
    _________________________
  3. s.jealousy

    s.jealousy New Member

    Joined:
    26 May 2011
    Messages:
    2
    Likes Received:
    0
    Reputations:
    0
    а почему xmpp? И как игнорировать эти варнинги?