2012-10-25 13:31:31 -04:00
|
|
|
#!/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',
|
2012-10-27 11:36:55 -04:00
|
|
|
default="https://humbughq.com",
|
2012-10-25 13:31:31 -04:00
|
|
|
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):
|
2012-10-26 10:42:31 -04:00
|
|
|
forwarded_message = {
|
|
|
|
"type": "stream",
|
|
|
|
"stream": "support",
|
|
|
|
"subject": "feedback from %s" % message["sender_email"],
|
|
|
|
"content": message["content"],
|
|
|
|
}
|
|
|
|
client.send_message(forwarded_message)
|
2012-10-25 13:31:31 -04:00
|
|
|
|
|
|
|
client.call_on_each_message(forward_message)
|