@@ -0,0 +1,1832 @@
+#!/usr/bin/env python%0Afrom __future__ import division%0Aimport time%0Afrom time import ctime%0Afrom pyslack import SlackClient%0A%0Atry:%0A    from cStringIO import StringIO%0Aexcept ImportError:%0A    try:%0A        from StringIO import StringIO%0A    except ImportError:%0A        from io import StringIO%0A%0Afrom royweb import PacketHandler%0A%0Afrom km3pipe import Pipeline, Module%0Afrom km3pipe.pumps import CHPump%0Afrom km3pipe.pumps.daq import DAQPreamble, DAQEvent%0A%0A%0Aclass CHPrinter(Module):%0A    def process(self, blob):%0A        print(%22New blob:%22)%0A        print blob%5B'CHPrefix'%5D%0A        return blob%0A%0A%0Aclass SlackSender(Module):%0A    def __init__(self, **context):%0A        super(self.__class__, self).__init__(**context)%0A        self.client = SlackClient('YOUR_SLACK_API_TOKEN_HERE')%0A        self.current_run = None%0A%0A    def process(self, blob):%0A        data_size = blob%5B'CHPrefix'%5D.length%0A%0A        data = blob%5B'CHData'%5D%0A        data_io = StringIO(data)%0A%0A        preamble = DAQPreamble(file_obj=data_io)%0A        print(ctime())%0A        print(preamble)%0A%0A        event = DAQEvent(file_obj=data_io)%0A        print(%22Run: %7B0%7D%22.format(event.header.run))%0A        print(%22Time Slice: %7B0%7D%22.format(event.header.time_slice))%0A%0A        if not self.current_run == event.header.run:%0A            self.current_run = event.header.run%0A            self.client.chat_post_message(%22#du2-live%22,%0A                                          %22Run #%7B0%7D has started!%22.format(event.header.run),%0A                                          username=%22slackbot%22)%0A%0A        return blob%0A%0A%0Apipe = Pipeline()%0Apipe.attach(CHPump, host='localhost', # You'll need a VPN connection and several SSH tunnels%0A                    port=5553,%0A                    tags='IO_EVT',%0A                    timeout=60*60*24,%0A                    max_queue=50)%0Apipe.attach(SlackSender)%0Apipe.attach(CHPrinter)%0A%0Apipe.drain()%0A

Create slackbot.py