def Translated(data):
    title = data.get("title")
    content = data.get('content')
    # print(content)
    tran_title = translater.translate(title)
    tran_content_list = ''
    if len(content) > 4000:
        req_content = cut_text(content)
        for i in req_content:
            print('++++', len(i))
            tran_content = translater.translate(i)
            # print(tran_content)
            tran_content_list = tran_content_list + tran_content
    else:
        tran_content_list = translater.translate(content)

    return tran_title, tran_content_list
Beispiel #2
0
def reply_text(msg):
    name, message = msg['FromUserName'], msg['Content']

    lang = check_language(message)
    if lang != ENGLISH:
        message = translate(message)

    if name in Clients and Clients[name].is_alive():
        if lang != Clients[name].language:
            Clients[name].language = lang
        Clients[name].queue.put(message)

    elif 'bot' in message.lower():
        Clients[name] = WxClient(HOST=HOST, PORT=PORT, Language=lang, ID=name)
        Clients[name].callback('I am here!')
Beispiel #3
0
 def callback(self, receive):
     print 'Robot:', receive.decode('utf-8')
     if self._language != 2 and 'link' not in receive:
         receive = translate(receive)
     itchat.send('BOT:' + receive.decode('utf-8'), self._ID)