Fix stupid tabs.
This commit is contained in:
parent
c61c595205
commit
7d370761af
84
commitbot.py
84
commitbot.py
@ -14,65 +14,65 @@ NS_XHTML_W3C = 'http://www.w3.org/1999/xhtml'
|
||||
class CommitBot(XMPPHandler):
|
||||
|
||||
def __init__(self, room, nick):
|
||||
XMPPHandler.__init__(self)
|
||||
XMPPHandler.__init__(self)
|
||||
|
||||
self.room = room
|
||||
self.nick = nick
|
||||
self.room = room
|
||||
self.nick = nick
|
||||
|
||||
def connectionMade(self):
|
||||
self.send(AvailablePresence())
|
||||
self.send(AvailablePresence())
|
||||
|
||||
# add handlers
|
||||
# add handlers
|
||||
|
||||
# join room
|
||||
pres = Presence()
|
||||
pres['to'] = self.room + '/' + self.nick
|
||||
pres.addElement((NS_MUC, 'x'))
|
||||
self.send(pres)
|
||||
# join room
|
||||
pres = Presence()
|
||||
pres['to'] = self.room + '/' + self.nick
|
||||
pres.addElement((NS_MUC, 'x'))
|
||||
self.send(pres)
|
||||
|
||||
def notify(self, data):
|
||||
# build the messages
|
||||
text = []
|
||||
html = []
|
||||
link = r"<a href='%s' name='%s'>%s</a>"
|
||||
# build the messages
|
||||
text = []
|
||||
html = []
|
||||
link = r"<a href='%s' name='%s'>%s</a>"
|
||||
|
||||
text.append('New commits in %s:\n' % data['repository']['url'])
|
||||
html.append("New commits in " \
|
||||
"<a href='%s'>%s</a>:<br/>" % \
|
||||
(data['repository']['url'],
|
||||
data['repository']['name']))
|
||||
text.append('New commits in %s:\n' % data['repository']['url'])
|
||||
html.append("New commits in " \
|
||||
"<a href='%s'>%s</a>:<br/>" % \
|
||||
(data['repository']['url'],
|
||||
data['repository']['name']))
|
||||
|
||||
for c in data['commits']:
|
||||
text.append('%s | %s | %s\n' % (c['message'],
|
||||
c['author']['email'],
|
||||
c['url']))
|
||||
ltxt = link % (c['url'], c['id'], c['id'][:7])
|
||||
html.append('%s | %s | %s<br />' % (c['message'],
|
||||
c['author']['email'],
|
||||
ltxt))
|
||||
msg = domish.Element((None, 'message'))
|
||||
msg['to'] = self.room
|
||||
msg['from'] = self.room + '/' + self.nick
|
||||
msg['type'] = 'groupchat'
|
||||
msg.addElement('body', content=''.join(text))
|
||||
wrap = msg.addElement((NS_XHTML_IM, 'html'))
|
||||
body = wrap.addElement((NS_XHTML_W3C, 'body'))
|
||||
body.addRawXml(''.join(html))
|
||||
for c in data['commits']:
|
||||
text.append('%s | %s | %s\n' % (c['message'],
|
||||
c['author']['email'],
|
||||
c['url']))
|
||||
ltxt = link % (c['url'], c['id'], c['id'][:7])
|
||||
html.append('%s | %s | %s<br />' % (c['message'],
|
||||
c['author']['email'],
|
||||
ltxt))
|
||||
msg = domish.Element((None, 'message'))
|
||||
msg['to'] = self.room
|
||||
msg['from'] = self.room + '/' + self.nick
|
||||
msg['type'] = 'groupchat'
|
||||
msg.addElement('body', content=''.join(text))
|
||||
wrap = msg.addElement((NS_XHTML_IM, 'html'))
|
||||
body = wrap.addElement((NS_XHTML_W3C, 'body'))
|
||||
body.addRawXml(''.join(html))
|
||||
|
||||
self.send(msg)
|
||||
self.send(msg)
|
||||
|
||||
|
||||
class WebHook(resource.Resource):
|
||||
isLeaf = True
|
||||
|
||||
def __init__(self, bot):
|
||||
resource.Resource.__init__(self)
|
||||
self.bot = bot
|
||||
resource.Resource.__init__(self)
|
||||
self.bot = bot
|
||||
|
||||
def render_GET(self, req):
|
||||
return "commitbot ready to rock!"
|
||||
return "commitbot ready to rock!"
|
||||
|
||||
def render_POST(self, req):
|
||||
data = json.loads(req.args['payload'][0])
|
||||
self.bot.notify(data)
|
||||
return ""
|
||||
data = json.loads(req.args['payload'][0])
|
||||
self.bot.notify(data)
|
||||
return ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user