【发布时间】:2020-03-06 08:13:53
【问题描述】:
所以我上了这门课:
import os #for getting the directory location
class telegramBot(object):
def __init__(self, token = telegram_token, chat_id = telegram_chat_id):
self.token = token
self.chat_id = chat_id
self.base_url = "https://api.telegram.org/bot{}/".format(token)
其中包含许多方法,如 sendMessage、replyToMessage 等。
我想创建一个从 LOCAL LIBRARY 发送图像的方法 通过我的 Bot 到我的电报频道。
我正在寻找看起来像这样的东西:
def sendImage(self, chat_id, image_path, message)
url = self.base_url + "sendPhoto?chat_id={}&image_path={}&text={}".format(chat_id, image_path, message)
response = requests.post(url)
return response
但没有任何效果,我无法在网络或电报 API 页面上找到答案 有没有人做到或知道如何正确地做到这一点?有没有更好的办法?
谢谢
【问题讨论】:
标签: python api http bots telegram