1717def findwebhookidbyname (api , webhookname ):
1818 webhooks = api .webhooks .list ()
1919 for wh in webhooks :
20- # print (room['title'])
2120 if wh .name == webhookname :
2221 return wh .id
2322 else :
@@ -43,34 +42,33 @@ def findwebhookidbyname(api, webhookname):
4342 print ("no ngrok running - deleting webhook if it exists" )
4443 whid = findwebhookidbyname (api , webhookname )
4544 if "not found" in whid :
46- #create
47- print "no webhook found"
45+ print ("no webhook found" )
4846 sys .exit ()
4947 else :
50- #update
51- print whid
48+ print (whid )
5249 dict = api .webhooks .delete (whid )
53- print dict
50+ print (dict )
51+ print ("Webhook deleted" )
5452 sys .exit ()
5553
5654for line in ngrokpage .split ("\n " ):
5755 if "window.common = " in line :
5856 ngrokjson = re .search ('JSON.parse\(\" (.+)\" \)\;' ,line ).group (1 )
5957 ngrokjson = (ngrokjson .replace ('\\ ' ,'' ))
60- print ngrokjson
58+ print ( ngrokjson )
6159targetUrl = (json .loads (ngrokjson )["Session" ]["Tunnels" ]["command_line (http)" ]["URL" ])+ url_suffix
62- print targetUrl
60+ print ( targetUrl )
6361
6462#check if the webhook exists by name and then create it if not
6563whid = findwebhookidbyname (api , webhookname )
6664
6765if "not found" in whid :
6866 #create
69- print "not found"
67+ print ( "not found" )
7068 dict = api .webhooks .create (webhookname , targetUrl , resource , event )
71- print dict
69+ print ( dict )
7270else :
7371 #update
74- print whid
75- dict = api .webhooks .update (whid , webhookname , targetUrl )
76- print dict
72+ print ( whid )
73+ dict = api .webhooks .update (whid , webhookname , targetUrl ) #not working yet
74+ print ( dict )
0 commit comments