Telegram BOT -- 在字典中实现搜索
Telegram BOT -- Implementing the search in a dictionary
我正在创建一个在在线词典中搜索单词的电报机器人,当我需要在 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)
- 我在 Python 中使用此 Telegram API:https://github.com/yukuku/telebot
- 这 API 用于词典:https://github.com/dialelo/rae-1
这个怎么样。
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)
我正在创建一个在在线词典中搜索单词的电报机器人,当我需要在 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)
- 我在 Python 中使用此 Telegram API:https://github.com/yukuku/telebot
- 这 API 用于词典:https://github.com/dialelo/rae-1
这个怎么样。
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)