所以我上了这堂课:
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等。
我想创建一个从本地库发送图像的方法 通过我的Bot进入我的电报频道。
我正在寻找看起来像这样的东西:
def sendImage(self,chat_id,image_path,message)
url = self.base_url + "sendPhoto?chat_id={}&image_path={}&text={}".format(chat_id,message)
response = requests.post(url)
return response
但是没有任何效果,我无法在网络上或电报API页面上找到答案 是否有人做过或知道如何正确做?有更好的方法吗?
谢谢