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
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, ''
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
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, ''
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
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