How to use the errbot.backends.base.Presence function in errbot

To help you get started, we’ve selected a few errbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github errbotio / errbot / errbot / backends / slack.py View on Github external
def _hello_event_handler(self, event):
        """Event handler for the 'hello' event"""
        self.connect_callback()
        self.callback_presence(Presence(identifier=self.bot_identifier, status=ONLINE))
github errbotio / errbot / errbot / backends / slack.py View on Github external
"""Event handler for the 'presence_change' event"""

        idd = SlackIdentifier(self.sc, event['user'])
        presence = event['presence']
        # According to https://api.slack.com/docs/presence, presence can
        # only be one of 'active' and 'away'
        if presence == 'active':
            status = ONLINE
        elif presence == 'away':
            status = AWAY
        else:
            log.error(
                "It appears the Slack API changed, I received an unknown presence type %s" % presence
            )
            status = ONLINE
        self.callback_presence(Presence(identifier=idd, status=status))
github errbotio / errbot / errbot / backends / xmpp.py View on Github external
def user_left_chat(self, event):
        log.debug("user_left_chat %s" % event)
        idd = self.build_identifier(event['from'].full)
        p = Presence(chatroom=idd,
                     nick=idd.resource,
                     status=OFFLINE)
        self.callback_presence(p)
github errbotio / errbot / errbot / backends / tox.py View on Github external
def on_connection_status(self, friend_number, status):
        log.debug("TOX: user %s changed connection status", friend_number)
        pres = Presence(identifier=self.friend_to_idd(friend_number),
                        status=ONLINE if status else OFFLINE)
        self.backend.callback_presence(pres)
github errbotio / errbot / errbot / backends / xmpp.py View on Github external
def user_joined_chat(self, event):
        log.debug("user_join_chat %s" % event)
        idd = self.build_identifier(event['from'].full)
        p = Presence(chatroom=idd,
                     nick=idd.resource,
                     status=ONLINE)
        self.callback_presence(p)
github errbotio / errbot / errbot / backends / xmpp.py View on Github external
def contact_offline(self, event):
        log.debug("contact_offline %s" % event)
        p = Presence(
            identifier=self.build_identifier(event['from'].full),
            status=OFFLINE
        )
        self.callback_presence(p)
github errbotio / errbot / errbot / backends / tox.py View on Github external
def on_status_message(self, friend_number, message):
        pres = Presence(identifier=self.friend_to_idd(friend_number),
                        message=message)
        self.backend.callback_presence(pres)
github errbotio / errbot / errbot / backends / xmpp.py View on Github external
def contact_online(self, event):
        log.debug("contact_online %s" % event)
        p = Presence(
            identifier=self.build_identifier(event['from'].full),
            status=ONLINE
        )
        self.callback_presence(p)
github errbotio / errbot / errbot / backends / tox.py View on Github external
def on_user_status(self, friend_number, kind):
        log.debug("TOX: user %s changed state", friend_number)
        pres = Presence(identifier=self.friend_to_idd(friend_number),
                        status=TOX_TO_ERR_STATUS[kind])
        self.backend.callback_presence(pres)
github errbotio / errbot / errbot / backends / xmpp.py View on Github external
def user_changed_status(self, event):
        log.debug("user_changed_status %s" % event)
        errstatus = XMPP_TO_ERR_STATUS.get(event['type'], None)
        message = event['status']
        if not errstatus:
            errstatus = event['type']

        p = Presence(
            identifier=self.build_identifier(event['from'].full),
            status=errstatus,
            message=message
        )
        self.callback_presence(p)