我有用于python的sleekXMPP,我使用API创建了发送消息的函数,但是当我研究接收消息时,我找不到任何东西,有人能帮我解决这个问题吗,或者反驳这种可能性。谢谢。 下面是我用来发送消息的代码,如果有帮助的话。在
to = config.get('usermap', to[4:])
gmail_from_user = config.get('auth', 'email')
gmail_from_secret = config.get('auth', 'secret')
sys.stdout = stdouttmp
sys.stderr = stderrtmp
print "Sending chat message to " + to
xmpp = SendMsgBot(gmail_from_user, gmail_from_secret, to, message)
xmpp.register_plugin('xep_0030') # Service Discovery
xmpp.register_plugin('xep_0199') # XMPP Ping
sys.stdout = stdouttmp
if xmpp.connect(('talk.google.com', 5222)):
xmpp.process(block=True)
else:
sys.stdout = stdouttmp
print("Unable to connect.")
sys.stdout = stdouttmp
sys.stderr = stderrtmp
顺便说一句,我使用一个.cfg文本文件作为用户的电子邮件和密码,以及一些联系人,然后在中进行解析
我看到您使用的是send_client.py示例。该示例的目的是如何可靠地登录、发送一条消息,然后注销。您的用例是同时发送和接收消息,所以您最好看看echo_client.py示例。在
值得注意的是,为了接收消息,您应该:
同样,您需要从使用
SendMsgBot
示例切换,因为它在发送消息后会自动断开连接。在别忘了sleek@conference.jabber.org聊天室,如果你需要帮助。在
兰斯
相关问题 更多 >
编程相关推荐