def post(self): #get the credentials for the nazaztag u = self.request.get("id") p = self.request.get("secret") optionalreponame = self.request.get("repo") #get the JSON payload. this is stored in the POST variable "payload" jsonstr = self.request.get("payload") #parse it obj = json.loads(jsonstr) #read out some interesting data if optionalreponame=='': reponame = obj['repository']['name'] author = obj['commits'][0]['author']['name'] msg = obj['commits'][0]['message'] numcommits = len(obj['commits']) #construct the string we want to send to the rabbit txt = "Git alert! Git alert! %s just pushed %d commits to %s" %(author,numcommits,reponame) self.response.out.write(txt) #construct the nabaztag object and send the text myNabaztag = Nabaztag(u,p) myNabaztag.say(txt,voice='US-Liberty')
#!python # -*- coding: UTF-8 -*- """ nabazlib samples: HelloWorldSample You need this one }:) """ from nabazlib.Nabaztag import Nabaztag if __name__ == '__main__': # replace with your nabaztag's id myNabaztag = Nabaztag('0019DB000619', '1173966344') # a simple say print "Sending a Hello World!" myNabaztag.say("Hello World!")