def commentOn(commentUrl, success, inMerge, needTests, linkUrl):
    common_message = '\nThis test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly.  If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/\nContact BlueMatt on freenode if something looks broken.'
    recentcomments = requests.get((commentUrl + '?sort=created&direction=desc'), auth=(os.environ['GITHUB_USER'], os.environ['GITHUB_AUTH_TOKEN'])).json
    for comment in recentcomments:
        if ((comment['user']['login'] == os.environ['GITHUB_USER']) and (common_message in comment['body'])):
            requests.delete(comment['url'], auth=(os.environ['GITHUB_USER'], os.environ['GITHUB_AUTH_TOKEN']))
    if (success == True):
        if needTests:
            message = (('Automatic sanity-testing: PLEASE ADD TEST-CASES, though technically passed. See ' + linkUrl) + ' for binaries and test log.')
        else:
            message = (('Automatic sanity-testing: PASSED, see ' + linkUrl) + ' for binaries and test log.')
        post_data = {'body': (message + common_message)}
    elif inMerge:
        post_data = {'body': (((('Automatic sanity-testing: FAILED MERGE, see ' + linkUrl) + ' for test log.') + '\n\nThis pull does not merge cleanly onto current master') + common_message)}
    else:
        post_data = {'body': (((('Automatic sanity-testing: FAILED BUILD/TEST, see ' + linkUrl) + ' for binaries and test log.') + '\n\nThis could happen for one of several reasons:\n1. It chanages changes build scripts in a way that made them incompatible with the automated testing scripts (please tweak those patches in qa/pull-tester)\n2. It adds/modifies tests which test network rules (thanks for doing that), which conflicts with a patch applied at test time\n3. It does not build on either Linux i386 or Win32 (via MinGW cross compile)\n4. The test suite fails on either Linux i386 or Win32\n5. The block test-cases failed (lookup the first bNN identifier which failed in https://github.com/TheBlueMatt/test-scripts/blob/master/FullBlockTestGenerator.java)\n\nIf you believe this to be in error, please ping BlueMatt on freenode or TheBlueMatt here.\n') + common_message)}
    resp = requests.post(commentUrl, json.dumps(post_data), auth=(os.environ['GITHUB_USER'], os.environ['GITHUB_AUTH_TOKEN']))
def commentOn(commentUrl, success, inMerge, needTests, linkUrl):
    common_message = '\nThis test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly.  If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/\nContact BlueMatt on freenode if something looks broken.'
    recentcomments = requests.get((commentUrl + '?sort=created&direction=desc'), auth=(os.environ['GITHUB_USER'], os.environ['GITHUB_AUTH_TOKEN'])).json
    for comment in recentcomments:
        if ((comment['user']['login'] == os.environ['GITHUB_USER']) and (common_message in comment['body'])):
            requests.delete(comment['url'], auth=(os.environ['GITHUB_USER'], os.environ['GITHUB_AUTH_TOKEN']))
    if (success == True):
        if needTests:
            message = (('Automatic sanity-testing: PLEASE ADD TEST-CASES, though technically passed. See ' + linkUrl) + ' for binaries and test log.')
        else:
            message = (('Automatic sanity-testing: PASSED, see ' + linkUrl) + ' for binaries and test log.')
        post_data = {'body': (message + common_message)}
    elif inMerge:
        post_data = {'body': (((('Automatic sanity-testing: FAILED MERGE, see ' + linkUrl) + ' for test log.') + '\n\nThis pull does not merge cleanly onto current master') + common_message)}
    else:
        post_data = {'body': (((('Automatic sanity-testing: FAILED BUILD/TEST, see ' + linkUrl) + ' for binaries and test log.') + '\n\nThis could happen for one of several reasons:\n1. It chanages changes build scripts in a way that made them incompatible with the automated testing scripts (please tweak those patches in qa/pull-tester)\n2. It adds/modifies tests which test network rules (thanks for doing that), which conflicts with a patch applied at test time\n3. It does not build on either Linux i386 or Win32 (via MinGW cross compile)\n4. The test suite fails on either Linux i386 or Win32\n5. The block test-cases failed (lookup the first bNN identifier which failed in https://github.com/TheBlueMatt/test-scripts/blob/master/FullBlockTestGenerator.java)\n\nIf you believe this to be in error, please ping BlueMatt on freenode or TheBlueMatt here.\n') + common_message)}
    resp = requests.post(commentUrl, json.dumps(post_data), auth=(os.environ['GITHUB_USER'], os.environ['GITHUB_AUTH_TOKEN']))