Python sleekxmpp.ClientXMPP() Examples
The following are 11
code examples of sleekxmpp.ClientXMPP().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sleekxmpp
, or try the search function
.
Example #1
Source File: xmpp.py From fishroom with GNU General Public License v3.0 | 6 votes |
def __init__(self, server, port, jid, password, rooms, nick): sleekxmpp.ClientXMPP.__init__(self, jid, password) self.rooms = rooms self.nick = nick self.add_event_handler("session_start", self.on_start) self.add_event_handler("groupchat_message", self.on_muc_message) self.register_plugin('xep_0045') # Multi-User Chat self.register_plugin('xep_0199') # XMPP Ping self.srvaddress = (server, port) # if not self.connect((server, port)): # raise Exception("Unable to connect to XMPP server")
Example #2
Source File: gchat_shell_bot.py From XMPP_Shell_Bot with GNU General Public License v2.0 | 6 votes |
def __init__(self, jid, password, xor_var): # , room, nick): sleekxmpp.ClientXMPP.__init__(self, jid, password) #self.room = room #self.nick = nick self.xor_var = bytearray(self.hexToByte(xor_var)) # The session_start event will be triggered when the bot connects to the server self.add_event_handler("session_start", self.start) #The message event is triggered whenever you are sent a message self.add_event_handler("message", self.message) # The groupchat_message event #self.add_event_handler("groupchat_message", self.muc_message) # The groupchat_presence event is triggered whenever someone joins a room #self.add_event_handler("muc::%s::got_online" % self.room, self.muc_online) # session_start event
Example #3
Source File: wikibot.py From python-docs-samples with Apache License 2.0 | 6 votes |
def __init__(self, jid, password): sleekxmpp.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) # Register plugins. Note that while plugins may have # interdependencies, the order you register them in doesn't matter. self.register_plugin('xep_0030') # Service Discovery self.register_plugin('xep_0004') # Data Forms self.register_plugin('xep_0060') # PubSub self.register_plugin('xep_0199') # XMPP Ping
Example #4
Source File: remote.py From jarvis with GNU General Public License v2.0 | 6 votes |
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 = sleekxmpp.ClientXMPP(jid, password) #? Register plug-ins. client.registerPlugin('xep_0004') # Data Forms client.registerPlugin('xep_0009') # Jabber-RPC client.registerPlugin('xep_0030') # Service Discovery client.registerPlugin('xep_0060') # PubSub client.registerPlugin('xep_0199') # XMPP Ping return cls.new_session_with_client(client, callback)
Example #5
Source File: manager.py From allianceauth with GNU General Public License v2.0 | 6 votes |
def __init__(self, jid, password, recipient, message): sleekxmpp.ClientXMPP.__init__(self, jid, password) self.reconnect_max_attempts = 5 self.auto_reconnect = False # The message we wish to send, and the JID that # will receive it. self.recipient = recipient self.msg = message # Success checking self.message_sent = False # 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) if getattr(settings, 'BROADCAST_IGNORE_INVALID_CERT', False): self.add_event_handler("ssl_invalid_cert", self.discard)
Example #6
Source File: search_xmpp.py From watchdog with Apache License 2.0 | 5 votes |
def __init__(self, jid, password): sleekxmpp.ClientXMPP.__init__(self, jid, password) if opts.ipv4 is False: self.use_ipv6 = True else: self.use_ipv6 = False self.add_event_handler("session_start", self.start) self.add_event_handler("message", self.message) self.add_event_handler("ssl_invalid_cert", self.ssl_invalid_cert)
Example #7
Source File: xmpp.py From minemeld-core with Apache License 2.0 | 5 votes |
def _start_xmpp_client(self): if self._xmpp_client is not None: return if self.jid is None or self.password is None: raise RuntimeError('%s - jid or password not set', self.name) if self.server is None or self.port is None: raise RuntimeError('%s - server or port not set', self.name) if self.node is None or self.pubsub_service is None: raise RuntimeError( '%s - node or pubsub_service not set', self.name ) self._xmpp_client = sleekxmpp.ClientXMPP( jid=self.jid, password=self.password ) self._xmpp_client.register_plugin('xep_0030') self._xmpp_client.register_plugin('xep_0059') self._xmpp_client.register_plugin('xep_0060') self._xmpp_client.add_event_handler( 'session_start', self._xmpp_session_start ) self._xmpp_client.add_event_handler( 'disconnected', self._xmpp_disconnected ) if not self._xmpp_client.connect((self.server, self.port)): raise RuntimeError( '%s - error connecting to XMPP server', self.name ) self._xmpp_client.process(block=True)
Example #8
Source File: xmpp.py From minemeld-core with Apache License 2.0 | 5 votes |
def _start_xmpp_client(self): if self._xmpp_client is not None: return if self.jid is None or self.password is None: raise RuntimeError('%s - jid or password not set', self.name) if self.server is None or self.port is None: raise RuntimeError('%s - server or port not set', self.name) if self.node is None or self.pubsub_service is None: raise RuntimeError( '%s - node or pubsub_service not set', self.name ) self._xmpp_client = sleekxmpp.ClientXMPP( jid=self.jid, password=self.password ) self._xmpp_client.register_plugin('xep_0030') self._xmpp_client.register_plugin('xep_0059') self._xmpp_client.register_plugin('xep_0060') self._xmpp_client.add_event_handler( 'session_start', self._xmpp_session_start ) self._xmpp_client.add_event_handler( 'pubsub_publish', self._xmpp_publish ) if not self._xmpp_client.connect((self.server, self.port)): raise RuntimeError( '%s - error connecting to XMPP server', self.name ) self._xmpp_client.process(block=True)
Example #9
Source File: Signal.py From Controllers with MIT License | 5 votes |
def __init__(self, jid, password, sasl_mech): sleekxmpp.ClientXMPP.__init__(self, jid, password, sasl_mech=sasl_mech) self._overlay_id = None # self.overlay_descr = None self._sig = None self._node_id = None self._presence_publisher = None self._jid_cache = None self._outgoing_rem_acts = None self._cbt_to_action_tag = {} # maps remote action tags to cbt tags self._host = None self._port = None
Example #10
Source File: SleekXmppAdapter.py From apprise with MIT License | 4 votes |
def load(self): # Prepare our object self.xmpp = sleekxmpp.ClientXMPP(self.jid, self.password) # Register our session self.xmpp.add_event_handler("session_start", self.session_start) for xep in self.xep: # Load xep entries try: self.xmpp.register_plugin('xep_{0:04d}'.format(xep)) except sleekxmpp.plugins.base.PluginNotFound: self.logger.warning( 'Could not register plugin {}'.format( 'xep_{0:04d}'.format(xep))) return False if self.secure: # Don't even try to use the outdated ssl.PROTOCOL_SSLx self.xmpp.ssl_version = ssl.PROTOCOL_TLSv1 # If the python version supports it, use highest TLS version # automatically if hasattr(ssl, "PROTOCOL_TLS"): # Use the best version of TLS available to us self.xmpp.ssl_version = ssl.PROTOCOL_TLS self.xmpp.ca_certs = None if self.verify_certificate: # Set the ca_certs variable for certificate verification self.xmpp.ca_certs = next( (cert for cert in self.CA_CERTIFICATE_FILE_LOCATIONS if isfile(cert)), None) if self.xmpp.ca_certs is None: self.logger.warning( 'XMPP Secure comunication can not be verified; ' 'no local CA certificate file') return False # We're good return True
Example #11
Source File: SleekXmppAdapter.py From bazarr with GNU General Public License v3.0 | 4 votes |
def load(self): # Prepare our object self.xmpp = sleekxmpp.ClientXMPP(self.jid, self.password) # Register our session self.xmpp.add_event_handler("session_start", self.session_start) for xep in self.xep: # Load xep entries try: self.xmpp.register_plugin('xep_{0:04d}'.format(xep)) except sleekxmpp.plugins.base.PluginNotFound: self.logger.warning( 'Could not register plugin {}'.format( 'xep_{0:04d}'.format(xep))) return False if self.secure: # Don't even try to use the outdated ssl.PROTOCOL_SSLx self.xmpp.ssl_version = ssl.PROTOCOL_TLSv1 # If the python version supports it, use highest TLS version # automatically if hasattr(ssl, "PROTOCOL_TLS"): # Use the best version of TLS available to us self.xmpp.ssl_version = ssl.PROTOCOL_TLS self.xmpp.ca_certs = None if self.verify_certificate: # Set the ca_certs variable for certificate verification self.xmpp.ca_certs = next( (cert for cert in self.CA_CERTIFICATE_FILE_LOCATIONS if isfile(cert)), None) if self.xmpp.ca_certs is None: self.logger.warning( 'XMPP Secure comunication can not be verified; ' 'no local CA certificate file') return False # We're good return True