How to use the slixmpp.ClientXMPP function in slixmpp

To help you get started, we’ve selected a few slixmpp 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 poezio / slixmpp / examples / user_tune.py View on Github external
import sys
import logging
from getpass import getpass
from argparse import ArgumentParser

try:
    from appscript import *
except ImportError:
    print('This demo requires the appscript package to interact with iTunes.')
    sys.exit()

from slixmpp import ClientXMPP


class TuneBot(ClientXMPP):

    def __init__(self, jid, password):
        super().__init__(jid, password)

        # Check for the current song every 5 seconds.
        self.schedule('Check Current Tune', 5, self._update_tune, repeat=True)

        self.add_event_handler('session_start', self.start)
        self.add_event_handler('user_tune_publish', self.user_tune_publish)

        self.register_plugin('xep_0004')
        self.register_plugin('xep_0030')
        self.register_plugin('xep_0060')
        self.register_plugin('xep_0115')
        self.register_plugin('xep_0118')
        self.register_plugin('xep_0128')
github poezio / slixmpp / slixmpp / plugins / xep_0009 / remote.py View on Github external
def new_session(cls, jid, password, callback=None):
        '''
        Opens a new session and instantiates a new XMPP client.

        Arguments:
            jid -- The XMPP JID for logging in.
            password -- The password for logging in.
            callback -- An optional callback which can be used to track
                the starting state of the session.
        '''
        client = slixmpp.ClientXMPP(jid, password)
        #? Register plug-ins.
        client.register_plugin('xep_0004') # Data Forms
        client.register_plugin('xep_0009') # Jabber-RPC
        client.register_plugin('xep_0030') # Service Discovery
        client.register_plugin('xep_0060') # PubSub
        client.register_plugin('xep_0199') # XMPP Ping
        return cls.new_session_with_client(client, callback)
github poezio / slixmpp / examples / set_avatar.py View on Github external
def __init__(self, jid, password, filepath):
        slixmpp.ClientXMPP.__init__(self, jid, password)

        self.add_event_handler("session_start", self.start)

        self.filepath = filepath
github poezio / slixmpp / examples / thirdparty_auth.py View on Github external
def __init__(self, jid, password):
        slixmpp.ClientXMPP.__init__(self, jid, password)

        # The X-GOOGLE-TOKEN mech is ranked lower than PLAIN
        # due to Google only allowing a single SASL attempt per
        # connection. So PLAIN will be used for TLS connections,
        # and X-GOOGLE-TOKEN for non-TLS connections. To use
        # X-GOOGLE-TOKEN with a TLS connection, explicitly select
        # it using:
        #
        # slixmpp.ClientXMPP.__init__(self, jid, password,
        #                               sasl_mech="X-GOOGLE-TOKEN")

        # The session_start event will be triggered when
        # the bot establishes its connection with the server
        # and the XML streams are ready for use. We want to
        # listen for this event so that we we can initialize
        # our roster.
github poezio / slixmpp / examples / custom_stanzas / custom_stanza_user.py View on Github external
See the file LICENSE for copying permission.
"""

import logging
from getpass import getpass
from argparse import ArgumentParser

import slixmpp
from slixmpp import Iq
from slixmpp.exceptions import XMPPError
from slixmpp.xmlstream import register_stanza_plugin

from stanza import Action


class ActionUserBot(slixmpp.ClientXMPP):

    """
    A simple Slixmpp bot that sends a custom action stanza
    to another client.
    """

    def __init__(self, jid, password, other):
        slixmpp.ClientXMPP.__init__(self, jid, password)

        self.action_provider = other

        # The session_start event will be triggered when
        # the bot establishes its connection with the server
        # and the XML streams are ready for use. We want to
        # listen for this event so that we we can initialize
        # our roster.
github poezio / slixmpp / examples / http_upload.py View on Github external
def __init__(self, jid, password, recipient, filename):
        slixmpp.ClientXMPP.__init__(self, jid, password)

        self.recipient = recipient
        self.filename = filename

        self.add_event_handler("session_start", self.start)
github poezio / slixmpp / examples / markup.py View on Github external
def __init__(self, jid, password):
        slixmpp.ClientXMPP.__init__(self, jid, password)

        # The session_start event will be triggered when
        # the bot establishes its connection with the server
        # and the XML streams are ready for use. We want to
        # listen for this event so that we we can initialize
        # our roster.
        self.add_event_handler("session_start", self.start)

        # The message event is triggered whenever a message
        # stanza is received. Be aware that that includes
        # MUC messages and error messages.
        self.add_event_handler("message", self.message)
github poezio / slixmpp / examples / ibb_transfer / ibb_receiver.py View on Github external
"""
    Slixmpp: The Slick XMPP Library
    Copyright (C) 2010  Nathanael C. Fritz
    This file is part of Slixmpp.

    See the file LICENSE for copying permission.
"""

import logging
from getpass import getpass
from argparse import ArgumentParser

import slixmpp


class IBBReceiver(slixmpp.ClientXMPP):

    """
    A basic example of creating and using an in-band bytestream.
    """

    def __init__(self, jid, password):
        slixmpp.ClientXMPP.__init__(self, jid, password)

        self.register_plugin('xep_0030') # Service Discovery
        self.register_plugin('xep_0047', {
            'auto_accept': True
        }) # In-band Bytestreams

        # The session_start event will be triggered when
        # the bot establishes its connection with the server
        # and the XML streams are ready for use. We want to