-1

我正在创建一个在在线词典中搜索单词的电报机器人,当我需要在 Telegram 中创建用于在该词典中搜索的命令时,问题就出现了,此时我有这个:

from rae import Drae
drae = Drae()

  if text.startswith('/'):
     if text =='/define':
        drae.search(u' ')  # The problem is here, I don't know how to implement the command and the word who the client wants to search.
        setEnabled(chat_id, True)
4

1 回答 1

0

这个怎么样。

from rae import Drae

drae = Drae()

if text.startswith('/'):
  if text.startswith('/define'):
    try:
      [command, data] = text.split(' ',1)
    except:
      send('Write: /define <word>')
    meanings = drae.search(data) 
    reply(str(meanings)) 
    setEnabled(chat_id, True)
于 2015-07-06T13:57:59.003 回答