Skip to content

Commit

Permalink
Adapt for sonicretro
Browse files Browse the repository at this point in the history
  • Loading branch information
FraGag committed Dec 3, 2013
1 parent 45c29da commit 9ba1b8b
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions captainhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@
],
"config": {
"branch_regexes": "",
"nick": "github",
"nick": "GitHub",
"password": "",
"long_url": "1",
"room": "#captainhook",
"server": "irc.example.com",
"port": "6667"
}
}

username = raw_input('Enter github username:')
password = getpass.getpass("Enter github.com password for '%s':" % (username,))
org = raw_input('Enter github org:')
server = raw_input("Enter irc server hostname:")
room = raw_input("Enter #channel::key or #channel:")
username = raw_input('Enter github username: ')
password = getpass.getpass("Enter github.com password for '%s': " % (username,))
org = raw_input('Enter github org: ')
server = raw_input("Enter irc server hostname: ")
room = raw_input("Enter #channel::key or #channel: ")
overwrite = raw_input("Overwrite existing hooks? [y/N] ")
overwrite = overwrite == "Y" or overwrite == "y"

hook['config']['server'] = server
hook['config']['room'] = room
Expand All @@ -50,22 +51,23 @@
else:
if not (inp == "" or inp == "y" or inp == "Y"):
continue
## Get all existing hooks
hs = requests.get(hurl, auth=auth)
if not r.ok:
print " Failed: ", name
continue
hj = json.loads(hs.text or hs.content)
## Look for existing hook that matches this one
found = False
for h in hj:
if h['name'] != hook['name']:
if not overwrite:
## Get all existing hooks
hs = requests.get(hurl, auth=auth)
if not r.ok:
print " Failed: ", name
continue
if h['config']['room'] == hook['config']['room'] and h['config']['server'] == hook['config']['server'] and h['active']:
found = True
break
hj = json.loads(hs.text or hs.content)
## Look for existing hook that matches this one
found = False
for h in hj:
if h['name'] != hook['name']:
continue
if h['config']['room'] == hook['config']['room'] and h['config']['server'] == hook['config']['server'] and h['active']:
found = True
break
## Setup hook, if matching one not found
if not found:
if overwrite or not found:
headers = {'Content-type': 'application/json'}
k = requests.post(hurl, auth=auth, data=json.dumps(hook), headers=headers)
if k.ok:
Expand Down

0 comments on commit 9ba1b8b

Please sign in to comment.