发送txt文件到Telegram机器人的请求网站。

huangapple go评论74阅读模式
英文:

send txt file in telegam via request website to telegram bot

问题

我想使用一个请求网站(https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx)和Telegram中的一个机器人发送文件。

例如,以下代码用于向机器人发送消息:

TEXT = input('请输入您的文本:')
url = (f'https://api.telegram.org/bot{apiToken}/sendmessage?chat_id={chatID}&text={TEXT}')
payload = {"UrlBox": url,
        "AgentList": "Mozilla Firefox",
        "VersionsList": "HTTP/1.1",
        "MethodList": "POST"
    }
req = requests.post("https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx" , data=payload)
print(req)

但我不知道如何使用这个网站发送文件。我之所以要这样做,是因为Telegram在我们国家无法正常使用,我们必须使用VPN或第三方网站。

我尝试过ChatGPT并查阅Telegram文档。我找到了一个名叫m7.arman的人(用户名:14770721),他回答了我的问题,但答案不正确,没有帮助。虽然这个答案有效,但它无法通过https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx发送文件。

英文:

I want to send a file using a request website(https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx) and a bot in telegram
for example this code is for sending a massage in roobt :

TEXT = input('please enter your text : ')
url = (f'https://api.telegram.org/bot{apiToken}/sendmessage?chat_id={chatID}&text={TEXT}')
payload = {"UrlBox":url,
        "AgentList":"Mozilla Firefox",
        "VersionsList":"HTTP/1.1",
        "MethodList":"POST"
    }
req = requests.post("https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx" , data=payload)
print(req)

but i don't know how to send files with this website
i want to do this all because telegram is not working in our country and we have to use a vpn or third-party websites.

I tried chatgpt and searching in telegram documents
I found some guy named m7.arman (user:14770721) answered my question worng and it wasn't helpful
it is true and it works but it won't send file via https://www.httpdebugger.com/tools/ViewHttpHeaders.aspx

答案1

得分: 0

无法使用该网站发送文件。

使用sendDocument方法发送文件需要将文件传递为multipart/form-data,但是httpdebugger.com不提供将文件作为表单数据传递给POST请求的选项。

您需要使用代理或其他网站来向Telegram发送文件。

英文:

It's simply not possible to send files using that website.

Sending files using the sendDocument method requires passing the file as multipart/form-data, however, httpdebugger.com does not provide an optie to pass files as form-data for a POST request.

You'll need a proxy or an other website to send files to Telegram.

huangapple
  • 本文由 发表于 2023年7月3日 19:49:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76604460.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定