errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.13k stars 616 forks source link

callback_user_* and callback_contact_* not hooked up in XMPP backend #265

Closed otherdave closed 10 years ago

otherdave commented 10 years ago

I'm working on a HipChat bot (but I'm using the XMPP backend of ERR) and after going crazy wondering why my bot's callbacks for on/offline and join/leave a room weren't being called, I noticed that the XMPP backend doesn't invoke them:

https://github.com/gbin/err/blob/master/errbot/backends/xmpp.py

lines 218 and on just pass. So I tried to hook them up by:

def contact_online(self, stanza):
    u"""Callback for online contacts"""
    self.callback_contact_online(self.conn, stanza)

def contact_offline(self, stanza):
    u"""Callback for offline contacts"""
    self.callback_contact_offline(self.conn, stanza)

def user_joined_chat(self, stanza):
    u"""Callback for Users joining a room"""
    self.callback_user_joined_chat(self.conn, stanza)

def user_left_chat(self, stanza):
    u"""Callback for Users joining a room"""
    self.callback_user_left_chat(self.conn, stanza)

But it looks like "stanza" isn't the right thing to pass in to the callback? In my callback, I'm expecting to receive a Presence and when I call "get_real_name()" on it (for example), it's not found.

So this issue could either be a "please implement these" or if you are ok providing some guidance here, I don't mind hooking them up and submitting a pull request.

apophys commented 10 years ago

Hi, this thing is still a work in progress (lazy me...).

You are right, stanza as it is passed right now isn't the right thing to do. It should be abstracted to an object that is usable regardless of underlying protocol (e.g. irc, xmpp). Other than that, the way how you hooked them up is pretty much what I intend to do.

I don't mind you implementing this abstraction, if you want to. Though, I planned to do something about it this weekend. :)

If you want to use presence and other events in the meantime, take a look here for a hint. This way, with sleekxmpp under, you can register a handler for any of the events available.

gbin commented 10 years ago

This has been implemented