diff --git a/campfirelistener/__init__.py b/campfirelistener/__init__.py new file mode 100644 index 0000000..2a1f595 --- /dev/null +++ b/campfirelistener/__init__.py @@ -0,0 +1,2 @@ +#campfirelistener module +from campfirelistener import * diff --git a/campfirelistener/campfirelistener.py b/campfirelistener/campfirelistener.py new file mode 100644 index 0000000..cea926d --- /dev/null +++ b/campfirelistener/campfirelistener.py @@ -0,0 +1,27 @@ +import sys +import pinder +from trac.core import * +from trac.ticket.api import ITicketChangeListener + +class CampfireListener(Component): + implements(ITicketChangeListener) + + def _sendText(self, ticketid, text): + try: + c = pinder.Campfire('campfire_subdomain') + c.login('email','password') + room = c.find_room_by_name('room') + room.speak("Trac: ticket #%i (http://url.to.your.trac.install/projects/project_name/ticket/%i) %s" % (ticketid, ticketid, text)) + + except: + print "Unexpected error:", sys.exc_info()[0] + return + + def ticket_created(self, ticket): + self._sendText(ticket.id, "\"%s\" created by %s." % (ticket.values['summary'][0:100], ticket.values['reporter'])) + + def ticket_changed(self, ticket, comment, author, old_values): + self._sendText(ticket.id, "changed by %s, Comment: %s." % (author, comment[0:100])) + + def ticket_deleted(self, ticket): + self._sendText(ticket.id, "Ticket deleted") \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7bfa98c --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup + +setup( + name='TracCampfireListener', version='0.1', + packages=['campfirelistener'], + entry_points = { + 'trac.plugins' : [ + 'campfirelistener.campfirelistener = campfirelistener.campfirelistener' + ] + }, +) +