<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>README.markdown</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,3 @@
 *.tac
 *.pyc
+twistd.pid</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,15 @@
+from twisted.python import log
+from twisted.web import resource
 from twisted.words.xish import domish
 from wokkel.subprotocols import XMPPHandler
 from wokkel.xmppim import AvailablePresence, Presence
 
+import simplejson as json
+
+
 NS_MUC = 'http://jabber.org/protocol/muc'
+NS_XHTML_IM = 'http://jabber.org/protocols/xhtml-im'
+NS_XHTML_W3C = 'http://www.w3.org/1999/xhtml'
 
 class CommitBot(XMPPHandler):
 
@@ -11,7 +18,6 @@ class CommitBot(XMPPHandler):
 
 	self.room = room
 	self.nick = nick
-	self.joined = False
 
     def connectionMade(self):
 	self.send(AvailablePresence())
@@ -22,7 +28,51 @@ class CommitBot(XMPPHandler):
 	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&quot;&lt;a href='%s' name='%s'&gt;%s&lt;/a&gt;&quot;
 	
+	text.append('New commits in %s:\n' % data['repository']['url'])
+	html.append(&quot;New commits in &quot; \
+			&quot;&lt;a href='%s'&gt;%s&lt;/a&gt;:&lt;br/&gt;&quot; % \
+			(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&lt;br /&gt;' % (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)
+
+
+class WebHook(resource.Resource):
+    isLeaf = True
+
+    def __init__(self, bot):
+	resource.Resource.__init__(self)
+	self.bot = bot
+
+    def render_GET(self, req):
+	return &quot;commitbot ready to rock!&quot;
+
+    def render_POST(self, req):
+	data = json.loads(req.args['payload'][0])
+	self.bot.notify(data)
+	return &quot;&quot;</diff>
      <filename>commitbot.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,23 @@
 # -*- mode: python -*-
 
-from twisted.application import service
+from twisted.application import service, internet
+from twisted.web import server
 from twisted.words.protocols.jabber import jid
 from wokkel.client import XMPPClient
 
-from commitbot import CommitBot
+from commitbot import CommitBot, WebHook
 
 application = service.Application('commitbot')
 
-client = XMPPClient(jid.internJID('user@host'), 'password')
-client.logTraffic = False
 
-bot = CommitBot('room@chat.example.com', 'commits')
+client = XMPPClient(jid.internJID('user@example.com'), 'password')
+client.logTraffic = True
+
+bot = CommitBot('room@chat.example.com', 'gitbot')
 bot.setHandlerParent(client)
 
 client.setServiceParent(application)
+
+site = server.Site(WebHook(bot))
+server = internet.TCPServer(8888, site)
+server.setServiceParent(application)</diff>
      <filename>commitbot.tac.example</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e28cc06917ef1b325a2293ebb6c1e507f98345e1</id>
    </parent>
  </parents>
  <author>
    <name>Jack Moffitt</name>
    <email>jack@metajack.im</email>
  </author>
  <url>http://github.com/metajack/commitbot/commit/37f607acd2bc8986a9a1934aa499ea335a32afce</url>
  <id>37f607acd2bc8986a9a1934aa499ea335a32afce</id>
  <committed-date>2008-12-04T14:57:37-08:00</committed-date>
  <authored-date>2008-12-04T14:57:37-08:00</authored-date>
  <message>Commitbot now works.</message>
  <tree>fb5f826ba28f87e37a1d1ca860805ecd2b3ecdea</tree>
  <committer>
    <name>Jack Moffitt</name>
    <email>jack@metajack.im</email>
  </committer>
</commit>
