17
17
def findwebhookidbyname (api , webhookname ):
18
18
webhooks = api .webhooks .list ()
19
19
for wh in webhooks :
20
- # print (room['title'])
21
20
if wh .name == webhookname :
22
21
return wh .id
23
22
else :
@@ -43,34 +42,33 @@ def findwebhookidbyname(api, webhookname):
43
42
print ("no ngrok running - deleting webhook if it exists" )
44
43
whid = findwebhookidbyname (api , webhookname )
45
44
if "not found" in whid :
46
- #create
47
- print "no webhook found"
45
+ print ("no webhook found" )
48
46
sys .exit ()
49
47
else :
50
- #update
51
- print whid
48
+ print (whid )
52
49
dict = api .webhooks .delete (whid )
53
- print dict
50
+ print (dict )
51
+ print ("Webhook deleted" )
54
52
sys .exit ()
55
53
56
54
for line in ngrokpage .split ("\n " ):
57
55
if "window.common = " in line :
58
56
ngrokjson = re .search ('JSON.parse\(\" (.+)\" \)\;' ,line ).group (1 )
59
57
ngrokjson = (ngrokjson .replace ('\\ ' ,'' ))
60
- print ngrokjson
58
+ print ( ngrokjson )
61
59
targetUrl = (json .loads (ngrokjson )["Session" ]["Tunnels" ]["command_line (http)" ]["URL" ])+ url_suffix
62
- print targetUrl
60
+ print ( targetUrl )
63
61
64
62
#check if the webhook exists by name and then create it if not
65
63
whid = findwebhookidbyname (api , webhookname )
66
64
67
65
if "not found" in whid :
68
66
#create
69
- print "not found"
67
+ print ( "not found" )
70
68
dict = api .webhooks .create (webhookname , targetUrl , resource , event )
71
- print dict
69
+ print ( dict )
72
70
else :
73
71
#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