diff --git a/commitbot.py b/commitbot.py index 4c48d20..74a2766 100644 --- a/commitbot.py +++ b/commitbot.py @@ -13,11 +13,12 @@ NS_XHTML_W3C = 'http://www.w3.org/1999/xhtml' class CommitBot(XMPPHandler): - def __init__(self, room, nick): + def __init__(self, room, nick, password=None): XMPPHandler.__init__(self) self.room = room self.nick = nick + self.password = password def connectionMade(self): self.send(AvailablePresence()) @@ -27,7 +28,9 @@ class CommitBot(XMPPHandler): # join room pres = Presence() pres['to'] = self.room + '/' + self.nick - pres.addElement((NS_MUC, 'x')) + x = pres.addElement((NS_MUC, 'x')) + if not self.password is None: + x.addElement('password', content = self.password) self.send(pres) def notify(self, data): diff --git a/commitbot.tac.example b/commitbot.tac.example index a00c538..c5ccee4 100644 --- a/commitbot.tac.example +++ b/commitbot.tac.example @@ -13,7 +13,8 @@ application = service.Application('commitbot') client = XMPPClient(jid.internJID('user@example.com'), 'password') client.logTraffic = True -bot = CommitBot('room@chat.example.com', 'gitbot') +#In the next line, replace None with the password, for a protected room +bot = CommitBot('room@chat.example.com', 'gitbot', None) bot.setHandlerParent(client) client.setServiceParent(application)