Re: XMPP xmpppy - User Authorization

Discussion in 'Python' started by James Mills, Nov 5, 2008.

  1. James Mills

    James Mills Guest

    On Wed, Nov 5, 2008 at 11:28 AM, James Mills
    <> wrote:
    > Can anyone shed any light on how I might
    > be able to react to "User Authorization Requests"
    > from other users on an XMPP server/network
    > using teh xmlpp [1] library ?


    [SOLVED}:

    I found out from having a peek at jabberbot [1]
    that it was as simple as parsing the message.

    Here's a code snippet:

    <code>
    def messageHandler(self, cnx, message):
    text = message.getBody()
    user = message.getFrom()

    if text is not None:
    self.env.log.debug("<%s> %s" % (user, text))

    if " " in text:
    command, args = text.split(" ", 1)
    else:
    command, text = text, ""

    command = command.upper()

    if command == "SUBSCRIBE":
    self._client.Roster.Authorize(user)
    reply = "Authorized."
    </code>

    --JamesMills

    --
    --
    -- "Problems are solved by method"
     
    James Mills, Nov 5, 2008
    #1
    1. Advertising

  2. James Mills

    Henson Guest

    In my own bot, using the latest xmpppy, I've been printing everything
    going to the message handler to the screen. I've yet to see a
    'subscribe' string. Has this changed?


    James Mills wrote:
    > On Wed, Nov 5, 2008 at 11:28 AM, James Mills
    > <> wrote:
    > > Can anyone shed any light on how I might
    > > be able to react to "User Authorization Requests"
    > > from other users on an XMPP server/network
    > > using teh xmlpp [1] library ?

    >
    > [SOLVED}:
    >
    > I found out from having a peek at jabberbot [1]
    > that it was as simple as parsing the message.
    >
    > Here's a code snippet:
    >
    > <code>
    > def messageHandler(self, cnx, message):
    > text = message.getBody()
    > user = message.getFrom()
    >
    > if text is not None:
    > self.env.log.debug("<%s> %s" % (user, text))
    >
    > if " " in text:
    > command, args = text.split(" ", 1)
    > else:
    > command, text = text, ""
    >
    > command = command.upper()
    >
    > if command == "SUBSCRIBE":
    > self._client.Roster.Authorize(user)
    > reply = "Authorized."
    > </code>
    >
    > --JamesMills
    >
    > --
    > --
    > -- "Problems are solved by method"
     
    Henson, Dec 14, 2008
    #2
    1. Advertising

  3. James Mills

    James Mills Guest

    On Sun, Dec 14, 2008 at 3:47 PM, Henson <> wrote:
    > In my own bot, using the latest xmpppy, I've been printing everything
    > going to the message handler to the screen. I've yet to see a
    > 'subscribe' string. Has this changed?


    No this hasn't changed. This is the string you need
    to check for. It does work :)

    cheers
    James

    >

    --
    -- "Problems are solved by method"
     
    James Mills, Dec 14, 2008
    #3
  4. James Mills

    Henson Guest

    On Dec 14, 4:23 am, "James Mills" <>
    wrote:
    > On Sun, Dec 14, 2008 at 3:47 PM, Henson <> wrote:
    > > In my own bot, using the latestxmpppy, I've been printing everything
    > > going to the message handler to the screen.  I've yet to see a
    > > 'subscribe' string.  Has this changed?

    >
    > No this hasn't changed. This is the string you need
    > to check for. It does work :)
    >
    > cheers
    > James
    >
    >
    >
    > --
    > -- "Problems are solved by method"


    Found it. To me, the 'subscribe' was coming in through the Presence
    handler, not the Message handler.

    Thanks for the heads up,

    - Henson
     
    Henson, Dec 15, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    457
  2. James Mills

    XMPP xmpppy - User Authorization

    James Mills, Nov 5, 2008, in forum: Python
    Replies:
    0
    Views:
    398
    James Mills
    Nov 5, 2008
  3. Gabriel Rossetti

    Blocking XMPP API?

    Gabriel Rossetti, Jul 9, 2009, in forum: Python
    Replies:
    2
    Views:
    442
    Gabriel Rossetti
    Jul 13, 2009
  4. Astan Chee

    webcam in gtalk/xmpp

    Astan Chee, Sep 15, 2010, in forum: Python
    Replies:
    0
    Views:
    340
    Astan Chee
    Sep 15, 2010
  5. SeanRW
    Replies:
    1
    Views:
    394
    Dominick Baier [DevelopMentor]
    May 25, 2006
Loading...

Share This Page