Exemplo n.º 1
0
Arquivo: brain.py Projeto: anwen/anwen
def get_andesay(usersay, userip, userlang, user_id, method):
    doc = {
        'user_id': user_id,
        'user_ip': userip,
        'usersay': usersay,
        'usersay_low': usersay.lower(),
    }
    # usersay_en = translate(usersay, '', 'en')
    # is_firstmeet = query.is_firstmeet(userip, user_id)
    ego_info = ego.find_ego(usersay)
    ip_info = ip.find_ip(doc)
    first = query.first(usersay, userip, user_id, method)
    hello = query.hello(usersay)
    song = query.song(usersay)
    trans = query.trans(usersay, userlang)
    clock = query.clock(usersay)
    get_memo = query.search_memo(usersay, userip)
    #search = search.search(usersay)

    andesay = ''.join([
        ego_info, ip_info, get_memo, first, hello, song, trans, clock,
        #search,
    ])
    doc['andesay'] = andesay
    doc.pop('usersay_low')
    Ande.new(doc)
    #return doc
    return andesay
Exemplo n.º 2
0
def get_andesay(usersay, userip, userlang, user_id, method):
    doc = {
        'user_id': user_id,
        'user_ip': userip,
        'usersay': usersay,
        'usersay_low': usersay.lower(),
    }
    # usersay_en = translate(usersay, '', 'en')
    # is_firstmeet = query.is_firstmeet(userip, user_id)
    ego_info = ego.find_ego(usersay)
    ip_info = ip.find_ip(doc)
    first = query.first(usersay, userip, user_id, method)
    hello = query.hello(usersay)
    song = query.song(usersay)
    trans = query.trans(usersay, userlang)
    clock = query.clock(usersay)
    get_memo = query.search_memo(usersay, userip)
    #search = search.search(usersay)

    andesay = ''.join([
        ego_info,
        ip_info,
        get_memo,
        first,
        hello,
        song,
        trans,
        clock,
        #search,
    ])
    doc['andesay'] = andesay
    doc.pop('usersay_low')
    Ande.new(doc)
    #return doc
    return andesay
Exemplo n.º 3
0
Arquivo: brain.py Projeto: bowu8/anwen
def get_andesay(usersay, userip, userlang, user_id, method):
    data = {
        'usersay': usersay,
        'userip': userip,
        'userlang': userlang,
        'user_id': user_id,
        'method': method,
    }

    # usersay_en = translate(usersay, '', 'en')
    # is_firstmeet = query.is_firstmeet(userip, user_id)
    first = query.first(usersay, userip, user_id, method)
    hello = query.hello(usersay)
    song = query.song(usersay)
    trans = query.trans(usersay, userlang)
    clock = query.clock(usersay)

    get_tools = by_tools(data)
    get_memo = query.search_memo(usersay, userip)
    get_ego = ego.find_ego(usersay)

    andesay = ''.join([
        get_tools, get_memo, get_ego, first, hello, song, trans, clock,
    ])

    doc = {
        'user_id': user_id,
        'user_ip': userip,
        'usersay': usersay,
        'andesay': andesay,
    }

    Ande.new(doc)

    return andesay, ''
Exemplo n.º 4
0
def is_firstmeet(userip, user_id):
    if user_id == 0:
        a = 'not good friend'
        num = Ande.by_ip(userip)
    else:
        a = 'is good friend'
        num = Ande.by_uid(user_id)
    is_firstmeet = '%s we say %s times' % (a, num)
    return is_firstmeet
Exemplo n.º 5
0
def is_firstmeet(userip, user_id):
    if user_id == 0:
        a = 'not good friend'
        num = Ande.by_ip(userip)
    else:
        a = 'is good friend'
        num = Ande.by_uid(user_id)
    is_firstmeet = '%s we say %s times' % (a, num)
    return is_firstmeet
Exemplo n.º 6
0
Arquivo: brain.py Projeto: vipwp/anwen
def get_andesay(usersay, userip, userlang, user_id, method):
    data = {
        'usersay': usersay,
        'userip': userip,
        'userlang': userlang,
        'user_id': user_id,
        'method': method,
    }
    # usersay_en = translate(usersay, '', 'en')
    # is_firstmeet = query.is_firstmeet(userip, user_id)
    # print(usersay_en, is_firstmeet)
    first = query.first(usersay, userip, user_id, method)
    hello = query.hello(usersay)
    song = query.song(usersay)
    trans = query.trans(usersay, userlang)
    clock = query.clock(usersay)

    get_ego = ego.find_ego(usersay)
    get_memo = query.search_memo(usersay, userip)
    # get_tools = by_tools(data) if (get_ego or get_memo) else ''

    from .skills import search
    search = search.search(usersay)

    andesay = ''.join([
        get_ego,
        get_memo,
        first,
        hello,
        song,
        trans,
        clock,
        search,
    ])

    doc = {
        'user_id': user_id,
        'user_ip': userip,
        'usersay': usersay,
        'andesay': andesay,
    }

    Ande.new(doc)
    return andesay, ''
Exemplo n.º 7
0
def search_memo(usersay, userip):
    memo = ''
    lasthints = [u'上一句', u'前一句']
    for i in lasthints:
        if i in usersay:
            usersay = usersay.replace(i, '')
            usersay = usersay.replace('?', '')
            # memo = get_last(usersay) ['usersay']
            memo = Ande.find(
                {'user_ip': userip}).sort('_id', DESCENDING).limit(1)

            memo = u'你说的是:%s' % memo[0]['usersay']
            break
    return memo
Exemplo n.º 8
0
def search_memo(usersay, userip):
    memo = ''
    lasthints = [u'上一句', u'前一句']
    for i in lasthints:
        if i in usersay:
            usersay = usersay.replace(i, '')
            usersay = usersay.replace('?', '')
            # memo = get_last(usersay) ['usersay']
            memo = Ande.find({
                'user_ip': userip
            }).sort('_id', DESCENDING).limit(1)

            memo = u'你说的是:%s' % memo[0]['usersay']
            break
    return memo