From 221cfc7717f15c47adaf978711d272ebf36dd8c0 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 25 Oct 2012 13:31:31 -0400 Subject: [PATCH] Add feedback@humbughq.com forwarding bot. (imported from commit 219909bd06025e3778f162321628781e2e3e2c94) --- bots/feedback-bot | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 bots/feedback-bot diff --git a/bots/feedback-bot b/bots/feedback-bot new file mode 100755 index 0000000..e4da883 --- /dev/null +++ b/bots/feedback-bot @@ -0,0 +1,36 @@ +#!/usr/bin/python +import sys +import os +import optparse + +usage = """feedback-bot [options] + +Forwards messages from MIT realm users sent to feedback@humbughq.com over to Humbug realm + +Example: feedback-bot --site=http://127.0.0.1:9991 +""" +parser = optparse.OptionParser(usage=usage) +parser.add_option('--site', + dest='site', + default="https://app.humbughq.com", + action='store') +(options, args) = parser.parse_args() + +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) +import api.common +client = api.common.HumbugAPI(email="feedback@humbughq.com", + api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + verbose=True, + site=options.site) + +def forward_message(message): + if message["sender_email"].endswith("@mit.edu"): + forwarded_message = { + "type": "stream", + "stream": "support", + "subject": "feedback from %s" % message["sender_email"], + "content": message["content"], + } + client.send_message(forwarded_message) + +client.call_on_each_message(forward_message)