import json

def check_labels(api):
    with open('config.json', 'r') as fd:
        config = json.load(fd)

    if not config['active']:
        return

    labels = config['labels']
    for label, comment in labels.items():
        if api.payload['label']['name'].lower() == label:
            api.post_comment(comment)

method = check_labels

import json

def check_labels(api, config):
    if not config.get('active'):
        return

    labels = config.get('labels', [])
    for label, comment in labels.items():
        if api.payload['label']['name'].lower() == label:
            api.post_comment(comment)

methods = [check_labels]

Support for multiple methods, and leave the config file to hooker
Support for multiple methods, and leave the config file to hooker

  import json
  
- def check_labels(api):
+ def check_labels(api, config):
-     with open('config.json', 'r') as fd:
-         config = json.load(fd)
- 
-     if not config['active']:
+     if not config.get('active'):
          return
  
-     labels = config['labels']
+     labels = config.get('labels', [])
      for label, comment in labels.items():
          if api.payload['label']['name'].lower() == label:
              api.post_comment(comment)
  
- method = check_labels
+ methods = [check_labels]
  
Support for multiple methods, and leave the config file to hooker
## Code Before:
import json

def check_labels(api):
    with open('config.json', 'r') as fd:
        config = json.load(fd)

    if not config['active']:
        return

    labels = config['labels']
    for label, comment in labels.items():
        if api.payload['label']['name'].lower() == label:
            api.post_comment(comment)

method = check_labels

## Instruction:
Support for multiple methods, and leave the config file to hooker
## Code After:
import json

def check_labels(api, config):
    if not config.get('active'):
        return

    labels = config.get('labels', [])
    for label, comment in labels.items():
        if api.payload['label']['name'].lower() == label:
            api.post_comment(comment)

methods = [check_labels]
