当前位置: 首页>>代码示例>>Python>>正文


Python connectionmanager.YowsupConnectionManager类代码示例

本文整理汇总了Python中Yowsup.connectionmanager.YowsupConnectionManager的典型用法代码示例。如果您正苦于以下问题:Python YowsupConnectionManager类的具体用法?Python YowsupConnectionManager怎么用?Python YowsupConnectionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了YowsupConnectionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, keepAlive = True, sendReceipts = True):
        self.sendReceipts = sendReceipts
        
        connectionManager = YowsupConnectionManager()
        connectionManager.setAutoPong(keepAlive)

        self.signalsInterface = connectionManager.getSignalsInterface()
        self.methodsInterface = connectionManager.getMethodsInterface()
        
        self.signalsInterface.registerListener("message_received", self.onMessageReceived)
        self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
        self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
        self.signalsInterface.registerListener("disconnected", self.onDisconnected)
        self.signalsInterface.registerListener("message_error", self.onError)

        self.signalsInterface.registerListener("receipt_messageSent", self.onMessageSent)
        self.signalsInterface.registerListener("receipt_messageDelivered", self.onMessageDelivered)
        
        self.signalsInterface.registerListener("image_received", self.onImageReceived)


        
        self.cm = connectionManager

        self.message_queue = Queue()
        self.image_queue = Queue()

        self.reply_dic = {}

        self.running = True
开发者ID:felix-dumit,项目名称:campusbot,代码行数:30,代码来源:Responder.py

示例2: __init__

	def __init__(self, phoneNumber):
		self.sendReceipts = True
		self.phoneNumber = phoneNumber
		self.jid = "%[email protected]" % phoneNumber
		
		self.sentCache = {}
		
		connectionManager = YowsupConnectionManager()
		connectionManager.setAutoPong(True)
		self.signalsInterface = connectionManager.getSignalsInterface()
		self.methodsInterface = connectionManager.getMethodsInterface()
		
		self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
		self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
		self.signalsInterface.registerListener("message_received", self.onMessageReceived)
		self.signalsInterface.registerListener("receipt_messageSent", self.onMessageSent)
		self.signalsInterface.registerListener("presence_updated", self.onPresenceUpdated)
		self.signalsInterface.registerListener("disconnected", self.onDisconnected)
		self.signalsInterface.registerListener("sync_contactsReceived", self.onSyncContacts)
		self.signalsInterface.registerListener("sync_statusesReceived", self.onSyncStatuses)
		
		
		self.commandMappings = {"lastseen":lambda: self.methodsInterface.call("presence_request", ( self.jid,)),
								"available": lambda: self.methodsInterface.call("presence_sendAvailable"),
								"unavailable": lambda: self.methodsInterface.call("presence_sendUnavailable"),
								"sync": lambda number: self.methodsInterface.call("sync_sendContacts", ([number],)),
								"status": lambda cjid: self.methodsInterface.call("sync_getStatuses", ([cjid],))
								 }
		
		self.done = False
开发者ID:Ediacarium,项目名称:BridgeMPP,代码行数:30,代码来源:TestClient.py

示例3: __init__

    def __init__(self):
        self.sendReceipts = True 
        self.groupMembership = {}
        self.groupParticipants = {}
        
        connectionManager = YowsupConnectionManager()
        connectionManager.setAutoPong(True)

        self.signalsInterface = connectionManager.getSignalsInterface()
        self.methodsInterface = connectionManager.getMethodsInterface()
        
        self.signalsInterface.registerListener("message_received", self.onMessageReceived)
        self.signalsInterface.registerListener("group_messageReceived", self.onGroupMessageReceived)
        self.signalsInterface.registerListener("group_subjectReceived", self.onGroupSubjectReceived)
        self.signalsInterface.registerListener("group_gotInfo", self.onGroupGotInfo)
        self.signalsInterface.registerListener("group_gotParticipants", self.onGroupGotParticipants)
        self.signalsInterface.registerListener("group_imageReceived", self.onGroupImageReceived)
        self.signalsInterface.registerListener("group_videoReceived", self.onGroupVideoReceived)
        self.signalsInterface.registerListener("group_audioReceived", self.onGroupAudioReceived)
        self.signalsInterface.registerListener("group_locationReceived", self.onGroupLocationReceived)
        self.signalsInterface.registerListener("group_vcardReceived", self.onGroupVcardReceived)

        self.signalsInterface.registerListener("notification_groupParticipantRemoved", self.onNotificationGroupParticipantRemoved)
        self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
        self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
        self.signalsInterface.registerListener("disconnected", self.onDisconnected)
        
        self.cm = connectionManager
开发者ID:dodysw,项目名称:wakaka,代码行数:28,代码来源:wakaka.py

示例4: __init__

	def __init__(self, phoneNumber, keepAlive = False, sendReceipts = False):
		self.sendReceipts = sendReceipts
		self.phoneNumber = phoneNumber
		self.jid = "%[email protected]" % phoneNumber
		
		self.sentCache = {}
		
		connectionManager = YowsupConnectionManager()
		connectionManager.setAutoPong(keepAlive)
		self.signalsInterface = connectionManager.getSignalsInterface()
		self.methodsInterface = connectionManager.getMethodsInterface()
		
		self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
		self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
		self.signalsInterface.registerListener("message_received", self.onMessageReceived)
		self.signalsInterface.registerListener("receipt_messageSent", self.onMessageSent)
		self.signalsInterface.registerListener("presence_updated", self.onPresenceUpdated)
		self.signalsInterface.registerListener("disconnected", self.onDisconnected)
		
		
		self.commandMappings = {"lastseen":lambda: self.methodsInterface.call("presence_request", ( self.jid,)),
								"available": lambda: self.methodsInterface.call("presence_sendAvailable"),
								"unavailable": lambda: self.methodsInterface.call("presence_sendUnavailable"),
								"crypt": None,
								"close": None
								 }
		
		self.done = False
		#signalsInterface.registerListener("receipt_messageDelivered", lambda jid, messageId: methodsInterface.call("delivered_ack", (jid, messageId)))

		#for encrypted communication
		self.decrRcvMsgKey = myRsa().create() #generate my rsa keys
		self.encrSendMsgKey = None
		self.encrProtocolStatus = 0 # 1: request made, 2:request arrived, 3: com. is encrypted
开发者ID:lucianogiuseppe,项目名称:yowsup,代码行数:34,代码来源:CmdClient.py

示例5: __init__

	def __init__(self, phoneNumber, keepAlive = False, sendReceipts = False):
		self.sendReceipts = sendReceipts
		self.phoneNumber = phoneNumber
		self.jid = "%[email protected]" % phoneNumber
		
		self.sentCache = {}
		
		connectionManager = YowsupConnectionManager()
		connectionManager.setAutoPong(keepAlive)
		self.signalsInterface = connectionManager.getSignalsInterface()
		self.methodsInterface = connectionManager.getMethodsInterface()
		
		self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
		self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
		self.signalsInterface.registerListener("message_received", self.onMessageReceived)
		self.signalsInterface.registerListener("receipt_messageSent", self.onMessageSent)
		self.signalsInterface.registerListener("presence_updated", self.onPresenceUpdated)
		self.signalsInterface.registerListener("disconnected", self.onDisconnected)
		
		
		self.commandMappings = {"lastseen":lambda: self.methodsInterface.call("presence_request", ( self.jid,)),
								"available": lambda: self.methodsInterface.call("presence_sendAvailable"),
								"unavailable": lambda: self.methodsInterface.call("presence_sendUnavailable")
								 }
		
		self.done = False
开发者ID:socialwhats,项目名称:whats-py,代码行数:26,代码来源:CmdClient.py

示例6: __init__

    def __init__(self, user, password, phone):
        """WhatsAppClient's constructor.

        Args:
          user (str): the local phone number.
          password (str): the WhatsApp password of 'user'.
          phone (str): the remote phone number.
        """

        super().__init__()

        self.user = user
        try:
            self.password = base64.b64decode(bytes(password.encode("utf-8")))
        except base64.binascii.Error:  # Lets Yowsup handle the error.
            self.password = bytes(password.encode("utf-8"))
        # Users are identified in WhatsApp by their phone number (plus the
        # code) followed by the domain '@s.whatsapp.net'.
        self.phone = phone + "@s.whatsapp.net"
        self.connected = False

        # Yowsup managers and signals setting up.
        connectionManager = YowsupConnectionManager()
        connectionManager.setAutoPong(True)
        self.signalsInterface = connectionManager.getSignalsInterface()
        self.methodsInterface = connectionManager.getMethodsInterface()

        self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
        self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
        self.signalsInterface.registerListener("message_received", self.onMessageReceived)
        self.signalsInterface.registerListener("image_received", self.onImageReceived)
        self.signalsInterface.registerListener("disconnected", self.onDisconnected)
开发者ID:newlawrence,项目名称:Funny-Stuff,代码行数:32,代码来源:splashwp_wpclient.py

示例7: __init__

	def __init__(self, url, keepAlive = False, sendReceipts = False):
		super(Server, self).__init__()
		self.sendReceipts = sendReceipts
		self.keepAlive = keepAlive
		self.db = create_engine(url, echo=False, pool_size=10, pool_timeout=600,pool_recycle=300)

		self.Session = sessionmaker(bind=self.db)
		self.s = self.Session()
		self.job = None

		self.pubnub = Pubnub(os.environ['PUB_KEY'], os.environ['SUB_KEY'], None, False)

		self.timeout = int(os.getenv('TIMEOUT', 3600))
		connectionManager = YowsupConnectionManager(self.timeout)

		connectionManager.setAutoPong(keepAlive)		

		self.signalsInterface = connectionManager.getSignalsInterface()
		self.methodsInterface = connectionManager.getMethodsInterface()
		
		self.signalsInterface.registerListener("message_received", self.onMessageReceived)
		self.signalsInterface.registerListener("group_messageReceived", self.onGroupMessageReceived)
		self.signalsInterface.registerListener("image_received", self.onImageReceived)
		self.signalsInterface.registerListener("video_received", self.onVideoReceived)
		self.signalsInterface.registerListener("audio_received", self.onAudioReceived)
		self.signalsInterface.registerListener("vcard_received", self.onVCardReceived)
		self.signalsInterface.registerListener("location_received", self.onLocationReceived)
		self.signalsInterface.registerListener("receipt_messageSent", self.onReceiptMessageSent)
		self.signalsInterface.registerListener("receipt_messageDelivered", self.onReceiptMessageDelivered)		
		
		self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
		self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
		self.signalsInterface.registerListener("disconnected", self.onDisconnected)

		self.signalsInterface.registerListener("contact_gotProfilePicture", self.onGotProfilePicture)
		self.signalsInterface.registerListener("profile_setStatusSuccess", self.onSetStatusSuccess)
		self.signalsInterface.registerListener("group_createSuccess", self.onGroupCreateSuccess)
		self.signalsInterface.registerListener("group_createFail", self.onGroupCreateFail)
		self.signalsInterface.registerListener("group_gotInfo", self.onGroupGotInfo)
		self.signalsInterface.registerListener("group_addParticipantsSuccess", self.onGroupAddParticipantsSuccess)
		self.signalsInterface.registerListener("group_removeParticipantsSuccess", self.onGroupRemoveParticipantsSuccess)
		self.signalsInterface.registerListener("group_imageReceived", self.onGroupImageReceived)


		self.signalsInterface.registerListener("group_subjectReceived", self.onGroupSubjectReceived)
		self.signalsInterface.registerListener("notification_removedFromGroup", self.onNotificationRemovedFromGroup)
		self.signalsInterface.registerListener("notification_groupParticipantAdded", self.onNotificationGroupParticipantAdded)
		self.signalsInterface.registerListener("group_gotParticipants", self.onGotGroupParticipants)

		self.signalsInterface.registerListener("media_uploadRequestSuccess", self.onUploadRequestSuccess)
		# self.signalsInterface.registerListener("media_uploadRequestFailed", self.onUploadRequestFailed)
		self.signalsInterface.registerListener("media_uploadRequestDuplicate", self.onUploadRequestDuplicate)
		self.signalsInterface.registerListener("presence_available", self.onPresenceAvailable)
		self.signalsInterface.registerListener("presence_unavailable", self.onPresenceUnavailable)
		
		self.cm = connectionManager
		self.url = os.environ['URL']

		self.post_headers = {'Content-type': 'application/json', 'Accept': 'application/json'}		
		self.done = False
开发者ID:pungoyal,项目名称:wassup,代码行数:60,代码来源:server.py

示例8: __init__

	def __init__(self, keepAlive=False, sendReceipts=False, dryRun=False):
		self.sendReceipts = sendReceipts
		self.dryRun = dryRun

		# Initialize
		connectionManager = YowsupConnectionManager()
		connectionManager.setAutoPong(keepAlive)
		self.signalsInterface = connectionManager.getSignalsInterface()
		self.methodsInterface = connectionManager.getMethodsInterface()

		# Configure the listeners
		self.signalsInterface.registerListener("message_received", self.onMessageReceived)
		self.signalsInterface.registerListener("group_messageReceived", self.onGroupMessageReceived)
		self.signalsInterface.registerListener("image_received", self.onImageReceived)
		self.signalsInterface.registerListener("group_imageReceived", self.onGroupImageReceived)
		self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
		self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
		self.signalsInterface.registerListener("disconnected", self.onDisconnected)


		# Create a printqueue so we won't print two things at the same time
		self.queue = Queue.PriorityQueue()
		self.history = [] #List of timestamp, action, item
		self.printer = None
		self.last_sender = None
		self.connected = False
开发者ID:noio,项目名称:RaspiWhatsApp,代码行数:26,代码来源:printchat.py

示例9: LibInterfaceHandler

class LibInterfaceHandler(InterfaceHandlerBase):
	
	def __init__(self, username):
		self.connectionManager = YowsupConnectionManager()
		self.connectionManager.setAutoPong(True)
		
		self.signalInterface = self.connectionManager.getSignalsInterface()
		self.methodInterface = self.connectionManager.getMethodsInterface()
		
		super(LibInterfaceHandler,self).__init__();
		
		self.initSignals()
		self.initMethods()

	def initSignals(self):		
		self.signals = self.signalInterface.getSignals()


	def initMethods(self):
		#get methods
		self.methods = self.methodInterface.getMethods()
	
	def connectToSignal(self, signalName, callback):
		if not self.isSignal(signalName):
			raise InvalidSignalException()
		
		self.signalInterface.registerListener(signalName, callback)

	def call(self, methodName, params = ()):
		if not self.isMethod(methodName):
			raise InvalidMethodException()

		return self.methodInterface.call(methodName, params)
开发者ID:AbinashBishoyi,项目名称:wazapp,代码行数:33,代码来源:LibInterfaceHandler.py

示例10: __init__

    def __init__(self, sendReceipts = True, timeout = 5):
        """ __init__"""
        self.timeout = timeout
        self.done = False
        self.path = ""
        self.gotMediaReceipt = False

        connectionManager = YowsupConnectionManager()
        connectionManager.setAutoPong(True)

        self.signalsInterface = connectionManager.getSignalsInterface()
        self.methodsInterface = connectionManager.getMethodsInterface()

        self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
        self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
        self.signalsInterface.registerListener("disconnected", self.onDisconnected)
#        self.signalsInterface.registerListener("profile_setPictureSuccess", self.onSetPictureSuccess)
#        self.signalsInterface.registerListener("profile_setPictureError", self.onSetPictureError)
#        self.signalsInterface.registerListener("profile_setStatusSuccess", self.onSetStatusSuccess)
#        self.signalsInterface.registerListener("presence_updated", self.onPresenceUpdated)
#        self.signalsInterface.registerListener("presence_available", self.onPresenceAvailable)
#        self.signalsInterface.registerListener("presence_unavailable", self.onPresenceUnavailable)
        self.signalsInterface.registerListener("media_uploadRequestSuccess", self.onMediaUploadRequestSuccess)
        self.signalsInterface.registerListener("media_uploadRequestFailed", self.onMediaUploadRequestFailure)
        self.signalsInterface.registerListener("media_uploadRequestDuplicate", self.onMediaUploadRequestDuplicate)
开发者ID:neotheicebird,项目名称:yowsup,代码行数:25,代码来源:MediaClient.py

示例11: __init__

    def __init__(self, keepAlive = False, sendReceipts = False):
        self.sendReceipts = sendReceipts
        self.redis=redis.Redis()

        self.queue_key = 'MESSAGES_LISTS'
        self.MODE_CONNECTED=1
        self.MODE_DISCONNECTED=2
        self.MODE_CONNECTING=3

        connectionManager = YowsupConnectionManager()
        connectionManager.setAutoPong(keepAlive)

        self.signalsInterface = connectionManager.getSignalsInterface()
        self.methodsInterface = connectionManager.getMethodsInterface()

        self.signalsInterface.registerListener("message_received", self.onMessageReceived)
        self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
        self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
        self.signalsInterface.registerListener("disconnected", self.onDisconnected)
        self.signalsInterface.registerListener("receipt_messageSent", self.onMessageSent)
        self.signalsInterface.registerListener("receipt_messageDelivered",self.messageReceived)

        #self.signalsInterface.registerListener("receipt_messageDelivered", lambda jid, messageId: methodsInterface.call("delivered_ack", (jid, messageId)))


        self.cm = connectionManager
开发者ID:badubizzle,项目名称:whookapp,代码行数:26,代码来源:ListenerClient.py

示例12: inicia_whatsapp

def inicia_whatsapp():
    #Se hacen publicas las variables de la conexion
    global y
    global signalsInterface
    global methodsInterface
    global contador
    global vaciado_mensajes_offline
    y = YowsupConnectionManager()
    y.setAutoPong(True) #Responder a los ping que hagan
    signalsInterface = y.getSignalsInterface() #Se recibiran las senales
    methodsInterface = y.getMethodsInterface() #Se utilizaran los metodos
 
    signalsInterface.registerListener("message_received", onMessageReceived)
    signalsInterface.registerListener("receipt_messageSent", onMessageSent)
    signalsInterface.registerListener("receipt_messageDelivered", onMessageDelivered)
    signalsInterface.registerListener("auth_success", onAuthSuccess)
    signalsInterface.registerListener("ping", onPing)
    signalsInterface.registerListener("disconnected", onDisconnected)
 
    methodsInterface.call("auth_login", (username, password))
    methodsInterface.call("ready")
     
    #Leer todos los mensajes offline y no analizarlos
    contador = 0
    vaciado_mensajes_offline = False
    while (contador<10): #Contador se pondra a cero cada vez que salta la interrupcion de un mensaje
        contador += 1
        time.sleep(0.1)
    #Cuando sale del while ha pasado 1 segundo sin recibir mensajes
    vaciado_mensajes_offline = True
	#Aqui ponemos nuestro numero de movil principal para que abrá una conversación como que la pi está operativa
    methodsInterface.call("message_send", ("[email protected]", 'Reset'))
开发者ID:chanjohns,项目名称:Raspberry-Domotic-With-Whatsapp,代码行数:32,代码来源:Domotic-whatspi.py

示例13: __init__

	def __init__(self, config, keepAlive=False, sendReceipts=False, dryRun=False):
		self.sendReceipts = sendReceipts
		self.dryRun = dryRun
		self.config = config
			

		# Initialize
		connectionManager = YowsupConnectionManager()
		connectionManager.setAutoPong(keepAlive)
		self.signalsInterface = connectionManager.getSignalsInterface()
		self.methodsInterface = connectionManager.getMethodsInterface()

		# Configure the listeners
		self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
		self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
		self.signalsInterface.registerListener("disconnected", self.onDisconnected)
		
		self.signalsInterface.registerListener("message_received", self.onMessageReceived)

		self.signalsInterface.registerListener("presence_updated", self.onPresenceUpdated)
		self.signalsInterface.registerListener("presence_available", self.onPresenceAvailable)
		self.signalsInterface.registerListener("presence_unavailable", self.onPresenceUnavailable)


		# Create a queue so we can stash the incoming data somewhere
		self.events = Queue.PriorityQueue()
		# Dictionary of contacts with their names
		self.names = dict(config['jids'])
		self.contacts = [jid for jid, name in config['jids']]
		# A count of events for each interval for each contact
		self.tally = defaultdict(lambda: dict((jid, 0) for jid in self.contacts))
		self.printer = None
		self.connected = False
		self.lastline, self.nextline = findInterval(LINE_INTERVAL)
		self.nth = 0
开发者ID:noio,项目名称:RaspiWhatsApp,代码行数:35,代码来源:onlines.py

示例14: __init__

	def __init__(self, app, keepAlive = False, sendReceipts = False):
		self.sendReceipts = sendReceipts
		self.app = app
		
		connectionManager = YowsupConnectionManager()
		connectionManager.setAutoPong(keepAlive)		

		self.signalsInterface = connectionManager.getSignalsInterface()
		self.methodsInterface = connectionManager.getMethodsInterface()
		
		self.signalsInterface.registerListener("message_received", self.onMessageReceived)
		self.signalsInterface.registerListener("group_messageReceived", self.onGroupMessageReceived)
		self.signalsInterface.registerListener("image_received", self.onImageReceived)
		self.signalsInterface.registerListener("auth_success", self.onAuthSuccess)
		self.signalsInterface.registerListener("auth_fail", self.onAuthFailed)
		self.signalsInterface.registerListener("disconnected", self.onDisconnected)

		self.signalsInterface.registerListener("contact_gotProfilePicture", self.onGotProfilePicture)
		self.signalsInterface.registerListener("profile_setStatusSuccess", self.onSetStatusSuccess)
		self.signalsInterface.registerListener("group_createSuccess", self.onGroupCreateSuccess)
		self.signalsInterface.registerListener("group_createFail", self.onGroupCreateFail)
		self.signalsInterface.registerListener("group_gotInfo", self.onGroupGotInfo)
		self.signalsInterface.registerListener("group_addParticipantsSuccess", self.onGroupAddParticipantsSuccess)
		
		self.cm = connectionManager
		self.url = os.getenv('SERVER_URL', 'http://localhost:3000')
		self.post_headers = {'Content-type': 'application/json', 'Accept': 'application/json'}		
		self.done = False
开发者ID:pungoyal,项目名称:wassup,代码行数:28,代码来源:app.py

示例15: __init__

 def __init__(self, login, password):
     connectionManager = YowsupConnectionManager()
     self.signals = connectionManager.getSignalsInterface()
     self.methods = connectionManager.getMethodsInterface()
     self.signals.registerListener("auth_success", self.onAuthSuccess)
     self.signals.registerListener("auth_fail", self.onAuthFailed)
     self.login = login
     self.password = base64.b64decode(bytes(password.encode('utf-8')))
     self.done = False
开发者ID:AbinashBishoyi,项目名称:sentry-whatsapp,代码行数:9,代码来源:__init__.py


注:本文中的Yowsup.connectionmanager.YowsupConnectionManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。