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)
评论列表
文章目录