Пример #1
0
def bible(event):
    """Bible event handler for Slack webhook events
    """
    (text, command, args,) = parse_event_text(event)

    if command == 'bible':
        if args:
            location = args
            from htk.lib.literalword.utils import get_bible_passage
            #from htk.utils.text.converters import markdown2slack
            passage = get_bible_passage(args)
            passage['query'] = args
            slack_text = """Bible passage: *%(query)s*
Read on Literal Word: %(url)s
>>> %(text)s
""" % passage
        else:
            slack_text = 'Please specify a Bible passage to look up. e.g. `htk: bible Lamentations 3:22-23` or `htk: bible Psalm 119:11`'
    else:
        slack_text = 'Illegal command.'

    username = '******'

    payload = {
        'text' : slack_text,
        'username' : username,
    }
    return payload
Пример #2
0
def bible(event, **kwargs):
    """Bible event handler for Slack webhook events
    """
    text = kwargs.get('text')
    command = kwargs.get('command')
    args = kwargs.get('args')

    if command == 'bible':
        if args:
            from htk.lib.literalword.utils import get_bible_passage
            from htk.lib.literalword.utils import is_bible_version
            #from htk.utils.text.converters import markdown2slack
            arg_parts = args.split()
            arg1 = arg_parts[0].lower()
            if is_bible_version(arg1):
                bible_version = arg1
                args = ' '.join(arg_parts[1:])
            else:
                webhook_settings = event.get('webhook_settings', {})
                bible_version = webhook_settings.get('bible_version', None)
            passage = get_bible_passage(args, version=bible_version)
            passage['query'] = args
            slack_text = """Bible passage: *%(query)s*
Read on Literal Word: %(url)s
>>> %(text)s
""" % passage
        else:
            slack_text = 'Please specify a Bible passage to look up.\n%s' % get_usage(event, command)
    else:
        slack_text = 'Illegal command.'

    payload = {
        'text' : slack_text,
    }
    return payload