Esempio n. 1
0
    def __init__(self, config):
        """
        Create a ConfigComponent.

        Arguments:
            config      -- The XML contents of the config file.
            config_file -- The XML config file object itself.
        """
        ComponentXMPP.__init__(self, config["jid"], config["secret"], config["server"], config["port"])

        # Store the roster information.
        self.roster = config["roster"]["items"]

        # The session_start event will be triggered when
        # the component 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
        # broadcast any needed initial presence stanzas.
        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)

        #############################################################
        #########
        self.todo = []
Esempio n. 2
0
    def __init__(self, config):
        """
        Create a ConfigComponent.

        Arguments:
            config      -- The XML contents of the config file.
            config_file -- The XML config file object itself.
        """
        ComponentXMPP.__init__(self, config['jid'],
                                     config['secret'],
                                     config['server'],
                                     config['port'])

        # Store the roster information.
        self.roster = config['roster']['items']

        # The session_start event will be triggered when
        # the component 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
        # broadcast any needed initial presence stanzas.
        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)
Esempio n. 3
0
    def __init__(self, config):
        ComponentXMPP.__init__(self, config['jid'], config['password'],
                               config['server'], config['port'])
        self.config = config
        self.clients_config = {}
        self.clients = {}
        self.email_agents = {}

        self.register_plugin('xep_0030')

        self.auto_authorize = True
        self.auto_subscribe = True

        for client in config['clients']:
            self.clients_config[client['owner']] = client
            self.email_agents[client['owner']] = []
            for address in client['allowed']:
                addr = address[:]
                addr = '%s@%s' % (addr.replace('@', r'\40'), config['jid'])
                self.email_agents[client['owner']].append(addr)

        self.add_event_handler('session_start', self.start)
        self.add_event_handler('disconnected', self.shutdown)
        self.add_event_handler('killed', self.shutdown)
        self.add_event_handler('got_online', self.online, threaded=True)
        self.add_event_handler('got_offline', self.offline, threaded=True)
        self.add_event_handler('gmail_recv', self.send_message, threaded=True)
        self.add_event_handler('message', self.recv_message, threaded=True)
        self.add_event_handler('disco_info_request', self.disco, threaded=True)
Esempio n. 4
0
    def __init__(self, config):
        ComponentXMPP.__init__(self, config['jid'],
                                     config['password'],
                                     config['server'],
                                     config['port'])
        self.config = config
        self.clients_config = {}
        self.clients = {}
        self.email_agents = {}

        self.registerPlugin('xep_0030')
        self.registerPlugin('xep_0199')

        self.auto_authorize = True
        self.auto_subscribe = True

        for client in config['clients']:
            self.clients_config[client['owner']] = client
            self.email_agents[client['owner']] = []
            for address in client['email']['allowed']:
                addr = address[:]
                addr = '%s@%s' % (addr.replace('@', r'\40'), config['jid'])
                self.email_agents[client['owner']].append(addr)

        self.add_event_handler('session_start', self.start)
        self.add_event_handler('disconnected', self.shutdown)
        self.add_event_handler('got_online', self.online, threaded=True)
        self.add_event_handler('got_offline', self.offline, threaded=True)
        self.add_event_handler('gmail_recv', self.send_message, threaded=True)
        self.add_event_handler('message', self.recv_message, threaded=True)
        self.add_event_handler('disco_info_request', self.disco, threaded=True)
Esempio n. 5
0
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)
        self.backend = SimpleBackend()
        # You don't need a session_start handler, but that is
        # where you would broadcast initial presence.

        # 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("session_start", self.start)
        # self.add_event_handler("message", self.message)
        self.add_event_handler("changed_subscription",
                               self.handleXMPPPresenceSubscription)
        self.add_event_handler("got_presence_probe",
                               self.handleXMPPPresenceProbe)
        for event in [
                "message", "got_online", "got_offline", "changed_status"
        ]:
            self.add_event_handler(event, self.handleIncomingXMPPEvent)
        #
        self.backend.addMessageHandler(self.handleMessageAddedToBackend)

        xpath = "{%s}iq/{cnry:sleep:1}sleep" % self.default_ns

        self.registerHandler(
            Callback('Sleep command handler', MatchXPath(xpath),
                     self.handle_sleep))
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)

        self.use_signals()

        # 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 intialize
        # our roster.
        self.add_event_handler("session_start", self.start)
        
        self.add_event_handler("pubsub_subscribe", self._pubsub_subscribe)
        self.add_event_handler("pubsub_unsubscribe", self._pubsub_unsubscribe)
        self.add_event_handler("pubsub_retrieve_subscriptions", self._pubsub_retrieve_subscriptions)
        self.add_event_handler("pubsub_retrieve_affiliations", self._pubsub_retrieve_affiliations)
        self.add_event_handler("pubsub_get_items", self._pubsub_get_items)

        self.add_event_handler("pubsub_set_items", self._pubsub_set_items)
        self.add_event_handler("pubsub_create_node", self._pubsub_create_node)
        self.add_event_handler("pubsub_delete_node", self._pubsub_delete_node)
        self.add_event_handler("pubsub_retract_node", self._pubsub_retract)
        self.add_event_handler("pubsub_get_config_node", self._pubsub_get_config_node)
        
        self.add_event_handler("presence_available", self._presence_available)
        self.add_event_handler("presence_subscribed", self._presence_subscribed)

        self.auto_authorize = True # Automatic bidirectional subscriptions
        self.auto_subscribe = True

        self.pnick = "openOV KV6 Journey"

        self.friends = set([])
        self.subscriptions = {}
Esempio n. 7
0
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)

        # You don't need a session_start handler, but that is
        # where you would broadcast initial presence.

        # 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)
Esempio n. 8
0
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)

        # You don't need a session_start handler, but that is
        # where you would broadcast initial presence.

        # 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)
Esempio n. 9
0
    def __init__(self, config):
        """
        Create a ConfigComponent.

        Arguments:
            config      -- The XML contents of the config file.
            config_file -- The XML config file object itself.
        """
        ComponentXMPP.__init__(self, config['jid'],
                                     config['secret'],
                                     config['server'],
                                     config['port'])

        path = '{%s}%s' % (IntamacHandler.namespace, IntamacHandler.name)
        print('THE PATH IS THIS: ', path)
        
        self.register_handler(
            Callback('iq_intamacdeviceinfo',
                StanzaPath('iq@type=set/iq_intamacdeviceinfo'),
                self.intamac_device_info))

        
        # Store the roster information.
        #self.roster = roster.Roster(self)
        #self.roster.add(self.boundjid)
        #print('First roster: ', self.roster)
        #self.roster = config['roster']['item']
        #print('Roster: ', self.roster)

        # The session_start event will be triggered when
        # the component 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
        # broadcast any needed initial presence stanzas.
        self.add_event_handler("session_start", self.start, threaded=True)
        self.add_event_handler('presence', self.presence, threaded=threaded)
        self.add_event_handler('iq_intamacdeviceinfo', self.intamac_device_info, threaded=True)
        if option == 'unsubscribe':
            print('on unsubscribe mode')
            pass
        else: 
            print('adding other handlers')
            self.add_event_handler('presence_subscribe', self.subscribe, threaded=threaded)
            self.add_event_handler('presence_subscribed', self.subscribed, threaded=threaded)    
            #self.add_event_handler('stream', self.stream)
            self.add_event_handler('presence_probe', self.probe, threaded=threaded)


        # 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, threaded=threaded)
        self.add_event_handler('iq', self.iq, threaded=True)
        print(self.boundjid)
Esempio n. 10
0
	def __init__(self, jid, password, server, port):
		ComponentXMPP.__init__(self, jid, password, server, port)

		#self.add_event_handler('session_start', self.start)
		self.add_event_handler('message', self.message)

		self.registerPlugin('xep_0077')
		self.plugin['xep_0077'].setForm('username', 'password')
		#self.registerPlugin('feature_mechanisms')
		#self['feature_mechanisms'].unencrypted_plain = True
		self.credentials = {}
		self._stream_feature_handlers = {}
		self._stream_feature_order = []
Esempio n. 11
0
    def __init__(self, jid, password, server, port, secret, domain, storage):
        """
        :param jid:      the jid of the component itself (bot)
        :param password: the server password to attach this component
        :param server:   the address of the jabber server to attach to
        :param secret:   the secret used to garble jids
        :param storage:  the storage backend to use to store jids
        """
        ComponentXMPP.__init__(self, jid, password, server, port)
        self.hash_secret = secret
        self.domain = domain
        self.name_lookup = storage

        self.bot_jid = JID(jid)
        # the specific resource the bot replies from
        self.specific_bot_jid = JID(jid)
        self.specific_bot_jid.resource = 'a'

        self.add_event_handler("message", self.message)
Esempio n. 12
0
    def  __init__(self,jid,secret,config,server="localhost",port=5347):
        ComponentXMPP.__init__(self,jid,secret,server,port)
        self.add_event_handler("got_online",self.got_online)
        self.add_event_handler("got_offline",self.got_offline)
        self.add_event_handler("message",self.message)
        self.add_event_handler("presence",self.presence)
        self.add_event_handler("receipt_received",self.receipt_received)
        self.add_event_handler("session_start",self.start)
        self.add_event_handler("killed",self.shutdown)
#        self.add_event_handler("disco_info_query",self.info_query)
#        self.add_event_handler("disco_items_query",self.items_query)
        self.register_handler(Callback("cm_displayed",
                                 MatchXPath("{%s}message/{urn:xmpp:chat-markers:0}displayed"%(self.default_ns,)),
                                 self.message_displayed))
        self.logger=logging.getLogger("Component")
        self.config=config
        self.remove_handler('VCardTemp')
        self.register_handler(Callback('MyVCardTemp',
                              StanzaPath('iq/vcard_temp'),
                              self.handleVCard))
Esempio n. 13
0
    def __init__(self, config_file=None, config_connection=None, config_presence=None, config_roster=None):
        # load the configuration
        self.config = {}
        if config_file is not None:
            cf = ConfigParser()
            cf.read(config_file)
            self.config['connection'] = {
                    'domain': cf.get('connection', 'domain'),
                    'secret': cf.get('connection', 'secret'),
                    'host': cf.get('connection', 'host'),
                    'port': cf.getint('connection', 'port'),
                    }
            self.config['presence'] = {
                    'probe_initially': cf.getboolean('presence', 'probe_initially'),
                    'bcast_initially': cf.getboolean('presence', 'bcast_initially'),
                    }
            self.config['roster'] = {
                    'dbfile': cf.get('roster', 'dbfile'),
                    }
        if config_connection is not None:
            self.config['connection'] = config_connection
        if config_presence is not None:
            self.config['presence'] = config_presence
        if config_roster is not None:
            self.config['roster'] = config_roster

        #initialize the component with connection info
        ComponentXMPP.__init__(self, self.config['connection']['domain'], self.config['connection']['secret'], self.config['connection']['host'], self.config['connection']['port'])

        self.registerPlugin('xep_0045') # MUC
        self.add_event_handler('session_start', self.handleComponentStart)
        self.add_event_handler('presence_subscribe', self.handlePresSubscribe)
        self.add_event_handler('presence_subscribed', self.handlePresSubscribed)
        self.add_event_handler('presence_unsubscribe', self.handlePresUnsubscribe)
        self.add_event_handler('presence_unsubscribed', self.handlePresUnsubscribed)
        self.add_event_handler('presence_probe', self.handlePresProbe)
        self.add_event_handler('roster_subscription_request', self.handleNewSubscription)
        self.add_event_handler('roster_subscription_removed', self.handleRemovedSubscription)
        self.add_event_handler('got_online', self.handleGotOnline)

        self.current_status = {'default': self.Presence()}
Esempio n. 14
0
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)

        self.use_signals()

        # 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 intialize
        # our roster.
        self.add_event_handler("session_start", self.start)

        self.add_event_handler("pubsub_subscribe", self._pubsub_subscribe)
        self.add_event_handler("pubsub_unsubscribe", self._pubsub_unsubscribe)
        self.add_event_handler("pubsub_retrieve_subscriptions",
                               self._pubsub_retrieve_subscriptions)
        self.add_event_handler("pubsub_retrieve_affiliations",
                               self._pubsub_retrieve_affiliations)
        self.add_event_handler("pubsub_get_items", self._pubsub_get_items)

        self.add_event_handler("pubsub_set_items", self._pubsub_set_items)
        self.add_event_handler("pubsub_create_node", self._pubsub_create_node)
        self.add_event_handler("pubsub_delete_node", self._pubsub_delete_node)
        self.add_event_handler("pubsub_retract_node", self._pubsub_retract)
        self.add_event_handler("pubsub_get_config_node",
                               self._pubsub_get_config_node)

        self.auto_authorize = True  # Automatic bidirectional subscriptions
        self.auto_subscribe = True

        self.pnick = 'openOV Transit Pubsub'

        self.modalities = {
            'bus': modality('bus'),
            # 'drive': drive(),
            # 'taxi': taxi(),
            # 'tram': tram(),
            #  'train': train(),
            # 'walk': walk(),
            # 'cycle': cycle()
        }
Esempio n. 15
0
    def __init__(self, jid, secret, server, port):
        self.logger = logging.getLogger(__name__)

        ComponentXMPP.__init__(self, jid, secret, server, port)

        # You don't need a session_start handler, but that is
        # where you would broadcast initial presence.

        # 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)

        self.zmqsender = ZMQSender()
        self.zmqreceiver = ZMQReceiver('wa_component')

        self.schedule('Check ZMQ', 2, self.check_zmq, repeat=True)

        self.auto_authorize = True
        self.logger.info('__init__() done')
        self.dispatcher = MsgDispatcher()
Esempio n. 16
0
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)
        self.backend = SimpleBackend()
        # You don't need a session_start handler, but that is
        # where you would broadcast initial presence.

        # 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("session_start", self.start)
        # self.add_event_handler("message", self.message)
        self.add_event_handler("changed_subscription",  self.handleXMPPPresenceSubscription)
        self.add_event_handler("got_presence_probe", self.handleXMPPPresenceProbe)
        for event in ["message", "got_online", "got_offline", "changed_status"] :
          self.add_event_handler(event, self.handleIncomingXMPPEvent)
        #
        self.backend.addMessageHandler(self.handleMessageAddedToBackend)

        xpath = "{%s}iq/{cnry:sleep:1}sleep" % self.default_ns

        self.registerHandler(Callback('Sleep command handler', MatchXPath(xpath), self.handle_sleep))
Esempio n. 17
0
    def __init__(self, config_dict):
        """
        Инициализация, подключение плагинов и регистрация событий
        :param config_dict:
        """

        ComponentXMPP.__init__(self, config_dict['jid'], config_dict['secret'],
                               config_dict['server'], config_dict['port'])

        self.config = config_dict
        self.tg_connections = dict()
        self.tg_phones = dict()
        self.tg_dialogs = dict()

        self.db_connection = self.init_database()

        self.register_plugin('xep_0030')  # Service discovery
        self.register_plugin('xep_0054')  # VCard-temp
        self.register_plugin('xep_0172')  # NickNames

        self.add_event_handler('message', self.message)
        self.add_event_handler('presence', self.event_presence)
        self.add_event_handler('got_online', self.handle_online)
        self.add_event_handler('got_offline', self.handle_offline)
        self.add_event_handler('session_start', self.handle_start)

        self.plugin['xep_0030'].add_identity(category='gateway',
                                             itype='telegram',
                                             name=self.config['title'],
                                             node=self.boundjid.node,
                                             jid=self.boundjid.bare,
                                             lang='no')

        vcard = self.plugin['xep_0054'].make_vcard()
        vcard['FN'] = self.config['title']
        vcard['DESC'] = 'Send /help for information'
        self.plugin['xep_0054'].publish_vcard(jid=self.boundjid.bare,
                                              vcard=vcard)
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)

        self.use_signals()

        # 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 intialize
        # our roster.
        self.add_event_handler("session_start", self.start)
        
        self.add_event_handler("pubsub_subscribe", self._pubsub_subscribe)
        self.add_event_handler("pubsub_unsubscribe", self._pubsub_unsubscribe)
        self.add_event_handler("pubsub_retrieve_subscriptions", self._pubsub_retrieve_subscriptions)
        self.add_event_handler("pubsub_retrieve_affiliations", self._pubsub_retrieve_affiliations)
        self.add_event_handler("pubsub_get_items", self._pubsub_get_items)

        self.add_event_handler("pubsub_set_items", self._pubsub_set_items)
        self.add_event_handler("pubsub_create_node", self._pubsub_create_node)
        self.add_event_handler("pubsub_delete_node", self._pubsub_delete_node)
        self.add_event_handler("pubsub_retract_node", self._pubsub_retract)
        self.add_event_handler("pubsub_get_config_node", self._pubsub_get_config_node)

        self.auto_authorize = True # Automatic bidirectional subscriptions
        self.auto_subscribe = True

        self.pnick = 'openOV Transit Pubsub'
        
        self.modalities = { 
                            'bus': modality('bus'),
                          # 'drive': drive(),
                          # 'taxi': taxi(),
                          # 'tram': tram(),
                          #  'train': train(),
                          # 'walk': walk(),
                          # 'cycle': cycle()
                          }
Esempio n. 19
0
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)

        # 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 intialize
        # our roster.
        self.add_event_handler("session_start", self.start)
        #self.add_event_handler("disco_items_query", self._get_items2)

        self.add_event_handler("pubsub_subscribe", self._subscribe)
        self.add_event_handler("pubsub_unsubscribe", self._unsubscribe)
        self.add_event_handler("pubsub_get_items", self._get_items)

        self.add_event_handler("pubsub_set_items", self._set_items)
        self.add_event_handler("pubsub_create_node", self._create_node)
        self.add_event_handler("pubsub_delete_node", self._delete_node)
        self.add_event_handler("pubsub_retract_node", self._retract)
        self.add_event_handler("pubsub_get_config_node", self._get_config_node)

        self.auto_authorize = True  # Automatic bidirectional subscriptions
        self.auto_subscribe = True
    def __init__(self, jid, secret, server, port):
        ComponentXMPP.__init__(self, jid, secret, server, port)

        # 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 intialize
        # our roster.
        self.add_event_handler("session_start", self.start)
        #self.add_event_handler("disco_items_query", self._get_items2)
        
        self.add_event_handler("pubsub_subscribe", self._subscribe)
        self.add_event_handler("pubsub_unsubscribe", self._unsubscribe)
        self.add_event_handler("pubsub_get_items", self._get_items)

        self.add_event_handler("pubsub_set_items", self._set_items)
        self.add_event_handler("pubsub_create_node", self._create_node)
        self.add_event_handler("pubsub_delete_node", self._delete_node)
        self.add_event_handler("pubsub_retract_node", self._retract)
        self.add_event_handler("pubsub_get_config_node", self._get_config_node)

        self.auto_authorize = True # Automatic bidirectional subscriptions
        self.auto_subscribe = True
Esempio n. 21
0
    def __init__(self, config):
        """
        Create a ConfigComponent.

        Arguments:
            config      -- The XML contents of the config file.
            config_file -- The XML config file object itself.
        """
        ComponentXMPP.__init__(self, config['jid'],
                                     config['secret'],
                                     config['server'],
                                     config['port'], use_jc_ns=False)

        custom_stanzas = {
            DeviceInfo: self.intamac_device_info,
            IntamacStream: self.intamac_stream,
            IntamacFirmwareUpgrade: self.intamac_firmware_upgrade,
            IntamacAPI: self.intamac_api,
            IntamacEvent: self.intamac_event
        }

        for custom_stanza, handler in custom_stanzas.items():
            register_stanza_plugin(Iq, custom_stanza)
            self.register_handler(
                Callback(custom_stanza.plugin_attrib,
                    StanzaPath('iq@type=set/{}'.format(custom_stanza.plugin_attrib)),
                    handler)
                )

        # The lines of code below configure support for the xep-0203
        # to be able to receive and process specific presence delayed
        # stanzas. I don't think this is the right way to do this,
        # as just registering the plugin should be enough to accomplish
        # the expected behavior. Something to look at later on. 
        from sleekxmpp.plugins.xep_0203 import Delay

        register_stanza_plugin(Presence, Delay)

        self.register_handler(
            Callback(Delay.name,
                StanzaPath('presence/{}'.format(Delay.plugin_attrib)),
                self.delay)
            )

        # The following piece of code shows how a normal registration
        # process for a single stanza plugin takes place: 
        '''
        self.register_handler(
            Callback('iq_api',
                StanzaPath('iq@type=set/iq_intamacapi'),
                self.intamac_device_info))
        
        '''

        # The following lines of code take care of registering 
        # specific listener methods for every kind of stanza that
        # we want to process. The code will be cleaned once a final
        # decision regarding the best way to deal with this is 
        # rechaed. 

        self.add_event_handler("session_start", self.start, threaded=True)
        #self.add_event_handler('presence', self.presence, threaded=threaded)
        #self.add_event_handler('iq_intamacdeviceinfo', self.intamac_device_info, threaded=True)
        self.add_event_handler('presence_subscribe', self.subscribe, threaded=threaded)
        self.add_event_handler('presence_subscribed', self.subscribed, threaded=threaded)  
        self.add_event_handler('delay', self.delay, threaded=threaded)  
Esempio n. 22
0
 def __init__(self, jid, secret, server, port):
     ComponentXMPP.__init__(self, jid, secret, server, port)
     self.add_event_handler("session_start", self.start)
 def __init__(self, jid, secret, server,port):
     ComponentXMPP.__init__(self, jid, secret, server, port)
     self.add_event_handler("message", self.message)
Esempio n. 24
0
 def __init__(self, jid, secret, port):
     ComponentXMPP.__init__(self, jid, secret, "localhost", port)
     self.register_plugin('xep_0030')
     self.register_plugin('upload',module='plugins.upload')
     self.add_event_handler('request_upload_slot',self.request_upload_slot)
Esempio n. 25
0
# coding=utf-8

__author__ = 'huangyouxiang'
__copyright__ = 'Copyright 15-6-11'

import mailer

from sleekxmpp.componentxmpp import ComponentXMPP


if __name__ == '__main__':
    muc = ComponentXMPP("test", "mimi", host="127.0.0.1", port=9090)
    if muc.connect():
        muc.process(block=False)
Esempio n. 26
0
 def __init__(self, jid, secret, host, port):
     ComponentXMPP.__init__(self, jid, secret, host, port)
     self.register_plugin('xep_0030')
     self.register_plugin('upload', module='plugins.upload')
     self.add_event_handler('request_upload_slot', self.request_upload_slot)
Esempio n. 27
0
if __name__ == '__main__':

    optp = OptionParser()
    optp.add_option('--daemon', action="store_true", dest='daemonize', help="run as daemon")
    optp.add_option('-q','--quiet', help='set logging to ERROR', action='store_const', dest='loglevel', const=logging.ERROR, default=None)
    optp.add_option('-d','--debug', help='set logging to DEBUG', action='store_const', dest='loglevel', const=logging.DEBUG, default=None)
    optp.add_option('-v','--verbose', help='set logging to COMM', action='store_const', dest='loglevel', const=5, default=None)
    optp.add_option("-c","--config", dest="configfile", default="config.ini", help="set config file to use")
    opts,args = optp.parse_args()


    logging.basicConfig(level=opts.loglevel, format='%(levelname)-8s %(message)s')
    logging.info("Not daemonized")


    print "loaded modules"
    p = Thoonk(listen=True, db=10)
    print p.get_feeds()
    print p.feed_exists('test')
    print "pubsub"
    print "interface"
    xmpp = ComponentXMPP('pubsub.local', 'secreteating', '127.0.0.1', 5347)
    print "xmpp"
    sleekpubsub = SleekPubsub2(xmpp, p)
    print "Sleekpubsub"
    print "registered"
    print xmpp.connect()
    print "connected"
    xmpp.process(threaded=False)
    print "processed"