我在 Visual Studio 2015 中添加了一个yowsup项目。在命令提示符下我使用 运行它yowsup-cli -demos
,我的问题是如何从 Visual Studio 运行它?
我找到了解决方案。首先,在 Visual Studio 中要运行的示例应用程序之一(在 yowsup 项目的 demos 文件夹中)上创建一个 run.py 文件,并根据yowsup wiki 中的示例应用程序在该文件上添加代码(使用一个来自示例应用程序的 run.py 代码)。例如:
from layer import EchoLayer
from yowsup.layers import YowParallelLayer
from yowsup.layers.auth import YowAuthenticationProtocolLayer
from yowsup.layers.protocol_messages import YowMessagesProtocolLayer
from yowsup.layers.protocol_receipts import YowReceiptProtocolLayer
from yowsup.layers.protocol_acks import YowAckProtocolLayer
from yowsup.layers.network import YowNetworkLayer
from yowsup.layers.coder import YowCoderLayer
from yowsup.stacks import YowStack
from yowsup.common import YowConstants
from yowsup.layers import YowLayerEvent
from yowsup.stacks import YowStack, YOWSUP_CORE_LAYERS
from yowsup.layers.axolotl import AxolotlControlLayer, AxolotlSendLayer, AxolotlReceivelayer
from yowsup.env import YowsupEnv
CREDENTIALS = ("phone", "password") # replace with your phone and password
if __name__== "__main__":
layers = (
EchoLayer,
YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer,
YowAckProtocolLayer]),
AxolotlControlLayer,
YowParallelLayer((AxolotlSendLayer, AxolotlReceivelayer)),
) + YOWSUP_CORE_LAYERS
stack = YowStack(layers)
stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, CREDENTIALS) #setting credentials
stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0]) #whatsapp server address
stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
stack.setProp(YowCoderLayer.PROP_RESOURCE, YowsupEnv.getCurrent().getResource()) #info about us as WhatsApp client
stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT)) #sending the connect signal
stack.loop() #this is the program mainloop
保存它,然后右键单击 run.py -> Run with debugging。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句