问题描述
我正在编写测试电报内联机器人程序如下:
import telebot
from telebot import types
import time
TOKEN = "Your Bot's Token"
bot = telebot.TeleBot(TOKEN)
@bot.inline_handler(lambda query: query.query == 'test')
def test(inline_query):
r = types.InlineQueryResultArticle(
# The id of our inline result
id='1',title='test',input_message_content=types.InputTextMessageContent(
'I am a message'
)
)
bot.answer_inline_query(inline_query.id,[r])
@bot.inline_handler(lambda query: query.query == 'image')
def image(inline_query):
r = types.InlineQueryResultPhoto(
id='11',photo_url='https://images.assettype.com/swarajya/2020-08/a46bd36a-e65b-4b0b-91d9-c0fcac98c518/telegram.jpg?w=1200&h=800',thumb_url='https://images.assettype.com/swarajya/2020-08/a46bd36a-e65b-4b0b-91d9-c0fcac98c518/telegram.jpg?w=1200&h=800'
)
bot.answer_inline_query(inline_query.id,[r])
while True:
try:
bot.polling(True)
except Exception as e:
print(e)
time.sleep(5)
我将它部署在 heroku 上并出现错误:-
•Traceback (most recent call last):
•File "main.py",line 2,in <module>
•from telebot import types
•ImportError: cannot import name 'types'
我在 google 和 youtube 上搜索过,但没有得到解决方案。 帮助我如何修复它或给我一个使用其他库的程序??
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)