Update the to_room script with an unique presence uuid

This commit is contained in:
Kayou 2021-10-20 12:10:32 +02:00 committed by GitHub
parent 0affbc50ac
commit ab63cf7cc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@
import sys
import xmpp
from contextlib import contextmanager
import uuid
@contextmanager
@ -26,19 +27,19 @@ def XMPPBot(password, room="dev"):
client.sendInitPresence(requestRoster=0)
presence = xmpp.Presence(to="%s@conference.yunohost.org" % room)
presence = xmpp.Presence(attrs={'id': uuid.uuid4()}, to="%s@conference.yunohost.org" % room)
presence.setTag('x', namespace='http://jabber.org/protocol/muc')
client.send(presence)
client.send(xmpp.Presence(to='%s@conference.yunohost.org/GitBot' % room))
client.send(xmpp.Presence(attrs={'id': uuid.uuid4()}, to='%s@conference.yunohost.org/Saperlipopette' % room))
def sendToChatRoom(message):
if not client.connected:
connect()
client.connected = True
client.send(xmpp.protocol.Message("%s@conference.yunohost.org" % room, message, typ="groupchat"))
client.send(xmpp.protocol.Message("%s@conference.yunohost.org" % room, message, typ="groupchat", attrs={'id': uuid.uuid4()}))
client.sendToChatRoom = sendToChatRoom
@ -50,7 +51,7 @@ def XMPPBot(password, room="dev"):
if __name__ == '__main__':
if len(sys.argv[1:]) < 2:
print "Usage : python to_room.py <password> <message> [<room name>]"
print("Usage : python to_room.py <password> <message> [<room name>]")
sys.exit(1)
password, message = sys.argv[1:3]