我正在创建一个搜索在线词典中的单词的电报机器人,当我需要在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)
答案 0 :(得分: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)