因此通过 Rstudio 中的电报机器人发送消息非常简单,请参阅:r-bloggers explantion...但是我只能通过 bot$sendMessage 和 bot$sendPhoto 单独发送书面消息和照片/图像电报......是否有可能让它在 1 个电报消息中一起发送,所以首先是文本消息而不是图像?
bot = Bot(token = bot_token('Yourbot'))
updates = bot$getUpdates()
#message
message_to_bot=sprintf('Process finished - Accuracy: %s', 0.99)
bot$sendMessage(chat_id = XXXXX, text = message_to_bot)
#figure
my_plot=ggplot(mtcars, aes(x=mpg)) + geom_histogram(bins = 5)
ggplot2::ggsave("my_plot.png", my_plot)
bot$sendPhoto(chat_id = XXXXX, photo = 'my_plot.png')
bot$sendPhoto(chat_id = XXXXX, document = 'my_plot.png')