【发布时间】:2018-11-07 05:44:20
【问题描述】:
我尝试了一些代码,但未能成功使用我的机器人发送文件消息。上传我的文件后,我无法从服务器获取 file_id 和 access_hash 等来发送它。 这是我的代码:
@dispatcher.message_handler(PhotoFilter())
def ask_photo(bot, update):
user_peer = update.get_effective_user()
bot.upload_file(file="../files/upload_file_test.jpeg",
file_type="file",
success_callback=file_upload_success,failure_callback=failure)
def file_upload_success(response):
photo_message = PhotoMessage(file_id=response.file_id,
access_hash=response.access_hash, name="photo", file_size="100",
mime_type="image/jpeg", thumb=response.thumb, width=80, height=80,
caption_text="caption")
bot.send_message(photo_message, user_peer)
这行不通! :( 有什么帮助吗?
【问题讨论】:
标签: python bots bale-messenger