0
def message_received(connect_object, message_node):
// if x event happens:
exit()
jid = xmpp.JID(user)
connection = xmpp.Client(jid.getDomain(), debug=[])
connection.connect(server)
result = connection.auth(jid.getNode(), password, "qwerty")
connection.RegisterHandler('message', message_received)
connection.sendInitPresence()
while connection.Process(1):
pass
无论上面的代码是做什么的,我都希望每小时都会向接收者发送一条消息作为提醒。即使收到一条消息并且控制权转至message_received
函数,每小时发送的消息应该继续,除非遇到exit()
。如何使用python-xmpp(和gtalk)每隔x分钟向收件人发送一条消息?
我在哪里插入消息?我想使用time.sleep()
,但任何其他解决方案也是可以接受的。
我有现在使用的日期时间模块,并在最后的while循环中使用。它工作正常。 – aste123 2015-02-10 01:45:04