本文整理汇总了Python中sleekxmpp.ClientXMPP类的典型用法代码示例。如果您正苦于以下问题:Python ClientXMPP类的具体用法?Python ClientXMPP怎么用?Python ClientXMPP使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClientXMPP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,jid,password,objects,objectl):
ClientXMPP.__init__(self,jid,password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message",self.message_logging)
self.collectorl=objectl
self.collectorl.info("XMPP connected")
self.collectors=objects
示例2: __init__
def __init__(self, jid, password):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message)
self.last_state = False
self.last_check = 0
示例3: start_xmpp_client
def start_xmpp_client(self):
logger = logging.getLogger(__name__)
ClientXMPP.__init__(self, "%s/bot" % settings.WILL_USERNAME, settings.WILL_PASSWORD)
self.rooms = []
self.default_room = settings.WILL_DEFAULT_ROOM
# Property boostraps the list
self.available_rooms
for r in settings.WILL_ROOMS:
if r != "":
if not hasattr(self, "default_room"):
self.default_room = r
try:
self.rooms.append(self.available_rooms[r])
except KeyError:
logger.error(
u'"{0}" is not an available room, ask'
' "@{1} what are the rooms?" for the full list.'
.format(r, settings.WILL_HANDLE))
self.nick = settings.WILL_NAME
self.handle = settings.WILL_HANDLE
self.handle_regex = re.compile("@%s" % self.handle)
self.whitespace_keepalive = True
self.whitespace_keepalive_interval = 30
self.add_event_handler("roster_update", self.join_rooms)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message_recieved)
self.add_event_handler("groupchat_message", self.room_message)
self.register_plugin('xep_0045') # MUC
示例4: __init__
def __init__(self, jid, password, server_jid):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message)
self.server_jid = server_jid
self.msgcallback = {}
示例5: __init__
def __init__(self, jid, password, server, server_port, friend_pattern, group, room, nick, auto_login):
"""
The constructor of the XMPP Client
"""
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message, threaded=True)
self.add_event_handler('presence_subscribe',
self.subscribe)
self._password = password
self._server = server
self._server_port = server_port
self._friend_pattern= friend_pattern
self._friend_default_group = group
self._connection = None
self._auth = None
self.loggedin = False
self.joinmuc = False
self._log = logging.getLogger("cement:app:xmpp")
self.ssl_version = ssl.PROTOCOL_SSLv3
self._log.info('XMPP client initialized...', extra={'namespace' : 'xmpp'})
if self._server_port != 5222:
self._log.info('server_port:%s is not default value!'%(self._server_port), extra={'namespace' : 'xmpp'})
self.register_plugin('xep_0030') # Service Discovery
self.register_plugin('xep_0045') # Multi-User Chat
self.register_plugin('xep_0199') # XMPP Ping
#Adapt the value of self.room when you test the conference
self.room = room
self.nick = nick
self.auto_login = auto_login
if self.auto_login == True:
self.login()
示例6: __init__
def __init__(self, jid, password):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.start)
self.add_event_handler('message', self.receive_message)
self.register_plugin('xep_0030') # Service Discovery
self.register_plugin('xep_0199') # XMPP Ping
示例7: __init__
def __init__(self, jid, password, sensor_bot_jid, pubsub_server_jid, node, trigger, action):
ClientXMPP.__init__(self, jid, password)
# Setting the sender jid and the receiver jid
self.sender_jid = jid
self.sensor_bot_jid = sensor_bot_jid
self.trigger = trigger
self.action = action
self.stopped = threading.Event()
self.action_thread = None
# Setting the session_start event handler to a method that prints "Started" at session start
self.add_event_handler("session_start", self.session_start)
self.register_plugin('xep_0060')
self.node = node
self.pubsub_server = pubsub_server_jid
self.add_event_handler('pubsub_publish', self._publish)
try:
# Connecting bot
self.connect()
# Sending bot presence
self.send_presence()
self.subscribe()
# Starting to process incoming messages
self.process(block=False)
except KeyboardInterrupt:
self.send_thread.cancel()
示例8: __init__
def __init__(self, jid, password, bot):
ClientXMPP.__init__(self, jid, password)
self.bot = bot
#self.recipient = RECIPIENT
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message)
示例9: __init__
def __init__(self, jid, password):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler('session_start', self.start)
self.add_event_handler('message', self.message)
self.schedule('Check mail', 10, self._check_mail, repeat=True)
self.register_plugin('xep_0030')
self.register_plugin('xep_0199')
示例10: __init__
def __init__(self):
ClientXMPP.__init__(self, config['user']['jid'], config['user'][
'passwd'])
self.register_plugin('xep_0060') # PubSub
self.register_plugin('xep_0065') # Socks5 Bytestreams
self.pubsub_addr = config['server']['pubsub']
self.working_dir = config['server']['working_dir']
# Some shortcuts
self.pubsub = self.plugin['xep_0060']
self.streamer = self.plugin['xep_0065']
self.disconnected = Event()
self.pending_rsyncs = {} # {SID => RsyncTask}
self.pending_git_init_tasks = {} # {BID => GitInitTask}
# Bind all handlers to corresponding events.
self._bind()
# Start the XMPP connection.
self.use_ipv6 = False
if self.connect(use_ssl=False, use_tls=False):
self.disconnected.clear()
self.process()
示例11: __init__
def __init__(self, jid='[email protected]/monitor18', password='Mq77aszdkd', address=(), debug=False, **conf):
"""
address must be a (ip, port) tuple
"""
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("presence_probe", self.handle_probe)
self.add_event_handler("roster_update", self.handle_roster)
self.add_event_handler("message", self.handle_message)
self.add_event_handler("changed_status", self.handle_changed_status)
self.add_event_handler("presence_unavailable", self.handle_availability)
self.add_event_handler("presence_available", self.handle_availability)
# auto subscription management
self.auto_authorize = True
self.auto_subscribe = True
self.conf = conf
self.auto_reconnect = True
self.address = address
self.jid = jid
self.nickname = jid.split("@")[0]
self.muc_status = False
if debug:
self.log = logging.basicConfig(level=logging.DEBUG,
format='%(levelname)-8s %(message)s')
self.redis_thread = AsyncAlarmThread(**self.conf)
self.redis_thread.start()
示例12: start_xmpp_client
def start_xmpp_client(self):
ClientXMPP.__init__(self, settings.WILL_USERNAME, settings.WILL_PASSWORD)
self.rooms = []
self.default_room = settings.WILL_DEFAULT_ROOM
# Property boostraps the list
self.available_rooms
for r in settings.WILL_ROOMS:
if r != "":
if not hasattr(self, "default_room"):
self.default_room = r
self.rooms.append(self.available_rooms[r])
self.nick = settings.WILL_NAME
self.handle = settings.WILL_HANDLE
self.handle_regex = re.compile("@%s" % self.handle)
self.whitespace_keepalive = True
self.whitespace_keepalive_interval = 30
self.add_event_handler("roster_update", self.join_rooms)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message_recieved)
self.add_event_handler("groupchat_message", self.room_message)
self.register_plugin('xep_0045') # MUC
示例13: __init__
def __init__(self, message):
# global scope of ahenk
scope = Scope().get_instance()
self.logger = scope.get_logger()
self.configuration_manager = scope.get_configuration_manager()
self.registration = scope.get_registration()
self.event_manager = scope.get_event_manager()
self.host = str(socket.gethostbyname(self.configuration_manager.get('CONNECTION', 'host')))
self.service = str(self.configuration_manager.get('CONNECTION', 'servicename'))
self.port = str(self.configuration_manager.get('CONNECTION', 'port'))
ClientXMPP.__init__(self, self.service, None)
self.message = message
self.receiver_resource = self.configuration_manager.get('CONNECTION', 'receiverresource')
self.receiver = self.configuration_manager.get('CONNECTION',
'receiverjid') + '@' + self.configuration_manager.get(
'CONNECTION', 'servicename')
if self.receiver_resource:
self.receiver += '/' + self.receiver_resource
if self.configuration_manager.get('CONNECTION', 'use_tls').strip().lower() == 'true':
self.use_tls = True
else:
self.use_tls = False
self.logger.debug('XMPP Receiver parameters were set')
self.add_listeners()
self.register_extensions()
示例14: __init__
def __init__(self, jid, password, send_message, logger):
ClientXMPP.__init__(self, jid, password)
self.add_event_handler("session_start", self.session_start)
self.add_event_handler("message", self.message_logging)
self.logger = logger
self.logger.info("XMPP connected")
self.send_message = send_message
示例15: __init__
def __init__(self, source, config):
super(XMPPPublisher, self).__init__(source, config)
jid = self.config['jid']
password = self.config['pwd']
ClientXMPP.__init__(self, jid, password)
self.node = self.config['pubsub_node']
self.pubsubjid = self.config['pubsub_jid']
"""
print "Testing connection to %s..." % (self.node)
s = socket.socket()
port = 80
try:
s.connect((self.node, port))
except Exception, e:
print "Cannnot connect to: %s:%d." % (self.node, port)
exit(-1)
"""
self.register_plugin('xep_0030') #discovery
self.ready = False
self.add_event_handler("session_start", self.session_start)
self.register_plugin('xep_0060') # PubSub
print "Connecting to %s as %s" % (self.node, jid)
sys.stdout.flush()
self.connect()
self.process(block=True)