Reputation: 31592
I'm using XMPP in Python, and I can send messages, but how can I receive?
Upvotes: 1
Views: 3454
Reputation: 31592
I must register a handler and process:
def messageCB(sess,mess):
print 'MESSAGE'*100
nick=mess.getFrom().getResource()
text=mess.getBody()
#print mess,nick
print text
client.RegisterHandler('message',messageCB)
while 1:
client.Process(1)
Upvotes: 2
Reputation: 31
Good post. I notice this code snippet is also in the logger example in xmpppy sourceforge website.
I wonder if it is possible to reply to incoming messages. The code above only receives and the nickname resource ID does not indicate who the sender is (in terms of JID format, user@server) unless xmpppy can translate that appropriately. So how might one take the received message nd "echo" it back to the sender? Or is that not easily possible with the xmpppy library and need to find a different XMPP library?
Upvotes: 0