Beispiel #1
0
def dict_handler():
    text = slack_utils.get_slack_text()
    LOG.info("/slack/dict : " + text)
    if text is None:
        return 'Invalid text'
    text = '\n\n'.join(eng_dict.get_word_defns(text)['defns'])
    ret = {'response_type': 'in_channel', 'text': text}
    ret = {'response_type': 'in_channel', 'text': eng_dict.get_word_defns(text)[
        'defns']}
    text = '\n\n'.join(eng_dict.get_word_defns(text)['defns'])
    ret = {'response_type': 'in_channel', 'text': text}
    return Response(json.dumps(ret), mimetype='application/json')
Beispiel #2
0
def handle_fb_dictionary(dct, msg, sender):
    if dct == 'urb':
        details = urban_dict.word_to_defn_messenger(msg)
    else:
        details = eng_dict.get_word_defns(msg, 'messenger')
    link = details.get('link', None)
    # 2 defns for urban dictionary as the definitions are too long
    # very often
    limit = 3 if dct != 'urb' else 2
    for defn in details['defns'][:limit]:
        LOG.info(defn)
        messenger_utils.send_reply(sender, defn)
    if link:
        LOG.info('{}'.format(link))
        messenger_utils.send_reply(
            sender, 'For more details visit {}'.format(link))
Beispiel #3
0
 def eng(text):
     LOG.info("'" + text + "'")
     if text[0] == '*':
         text = text[1:]
     text = '\n\n'.join(eng_dict.get_word_defns(text)['defns'])
     return get_dict("English Meaning", "#36a64f", text)