translate.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Abb1t 作者: k-freeman 项目源码 文件源码
def run(self):
        while 1: 
            msg=self.queue_in.get() # get() is blocking
            chat_id=msg.get_chat_id()
            if re.search(r'^(?:/|!)translate ', msg.get_text().lower()) and len(msg.get_text().split(" "))>=2:
                foreign=msg.get_text().split(" ",1)[1]
                try:
                    b=textblob.TextBlob(foreign)
                    reply="{}".format(b.translate(to="de"))
                except textblob.exceptions.NotTranslated:
                    reply="Error while translation. (Are there smileys in some words?)"
                self.bot.sendMessage(chat_id,reply)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号