Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Sam-Martin/db98e2bbd6a45f72bd0beeff3c09f407 to your computer and use it in GitHub Desktop.
Save Sam-Martin/db98e2bbd6a45f72bd0beeff3c09f407 to your computer and use it in GitHub Desktop.
RightGIF Integration for HipChat using AWS Lambda
import urllib
import urllib2
import json
def lambda_handler(event, context):
url = 'https://rightgif.com/search/web'
values = "text="+ event['item']['message']['message'].replace('/rightgif','').strip()
print values
req = urllib2.Request(url, headers={ 'user-agent': "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36" }, data=values)
response = urllib2.urlopen(req)
the_page = unicode(response.read(),errors='replace')
page_json = json.loads(the_page)
return {
"color": "green",
"message":page_json['url'],
"notify": "false",
"message_format": "text"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment