Esempio n. 1
0
def reply_one(mention_id, user_name, text):
    reply_text1 = twitter_based(text)
    reply_text2 = markov_based(text)
    reply_text3 = scenario_based(text)
    if reply_text3 is not None:
        print reply_text3
        api.send_reply(mention_id, user_name, 'sc:' + reply_text3)
    elif reply_text1 is not None:
        print reply_text1
        api.send_reply(mention_id, user_name, 'tw:' + reply_text1)
    else:
        print reply_text2
        api.send_reply(mention_id, user_name, 'mv:' + reply_text2)
Esempio n. 2
0
def process_message(session, update):
    bot = TeleBot(eloop, **update)
    response = yield from bot.get_response()
    r = yield from send_reply(session, response)
    return r
Esempio n. 3
0
    for rep in reps["replies"]:
        print "======================================================"
        if reps["grade"] == 0:
            scenario_file = "scenario_c09.txt"
        elif reps["grade"] == 1:
            scenario_file = "scenario_c09.txt"
        else:
            scenario_file = "scenario_c09.txt"
        sent = api.sentences(rep["text"])
        text = []
        for s in sent["sentences"]:
            print "-------------------------------------------------------"
            print s
            morphs = api.morph(s)
            print json.dumps(morphs, ensure_ascii=False, indent=4)
            query = list()
            for morph in morphs["morphs"]:
                query.append(u"{}:{}".format(morph["surface"], morph["pos"]))
            print json.dumps(query, ensure_ascii=False, indent=4)
            texts = api.trigger(scenario_file, query)
            print json.dumps(texts, ensure_ascii=False, indent=4)
            for t in texts["texts"]:
                text.append(t)
                print t
        if len(text) > 0:
            r = random.randint(0, len(text) - 1)
            print "++++++++++++++++++++++++++++++++++++++"
            print str(len(text))
            print text[r]
            api.send_reply(rep["mention_id"], rep["user_name"], text[r])
Esempio n. 4
0
def reply_one(mention_id, user_name, text):
    reply_text = twitter_based(text)
    api.send_reply(mention_id, user_name, reply_text)