我可以把savfig发送到python的telegram bot吗?

问题描述 投票:0回答:1

我试着添加bot.sendPhoto(chat_id=chat_id, photo='。http:/s33.postimg.orgplci93h4vimage.png'),在这里我有savfig,并需要将图像发送到我的telegram机器人。

import telebot
from flask import Flask, request


token = '9542...................ke8nT10'

URL = 'http://re......here.com/'
bot = telebot.TeleBot(token, threaded=False)
bot.remove_webhook()
bot.set_webhook(url=URL)

app = Flask(__name__)
@app.route('/', methods=['POST'])
def webhook():
    update = telebot.types.Update.de_json(request.stream.read().decode('utf-8'))
    bot.process_new_updates([update])
    return 'ok',200

def code:
        plt.savefig('plot_name.png', dpi = 300)

@bot.message_handler(commands=['start'])  # welcome message handler
def start(message):
    bot.sendPhoto(chat_id=chat_id)

我想用code:函数把savfig发送到我的telegram机器人上

python-3.x matplotlib telegram telegram-bot python-telegram-bot
1个回答
0
投票

bot.send_photo(chat_id, photo=open('plot_name.png', 'rb'))

© www.soinside.com 2019 - 2024. All rights reserved.