使用Google Apps Script网络应用程序绕过Telegram Bot API [重复]

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

我正在尝试使用python和Telegram Bot API构建Telegram机器人,并且由于Telegram Bot API在我的国家/地区受到审查,因此我发现this脚本被使用Google Apps脚本部署的应用程序绕过。但是问题在于它只发送文本而不发送文件,因此我希望Web应用程序将发送给它的文件重定向到Telegram,这是我的python代码的一部分:

fr = open("result.txt", "rb")
files = {"document": fr}
script_url = 'https://script.google.com/macros/s/AKfycby20pnglgWTp4oV0tDTKuU87XmvkS6EZd-LTuoCmMM3Ge7PbGJ/exec?bot_token=' + token + '&method=sendDocument&args={"chat_id": ' + chat_id + '}'
requests.post(
    url=script_url,
    files=files
)

所以我正在使用post方法将文件发送到Web应用程序,但是在Web应用程序方面,我不知道如何获取该文件并将其发送到Telegram。

google-apps-script http-post telegram-bot google-apps-script-web-application
1个回答
1
投票

最好只使用代理绕过审查。

如果使用python-telegram-bot,则可以在下面使用此代码:

#put HTTP proxy url here
REQUEST_KWARGS = {'proxy_url': 'http://localhost:62612/'}

updater = Updater(token=TOKEN, use_context=True, request_kwargs=REQUEST_KWARGS)

您可以使用lanterntor之类的免费工具来设置自己的代理。

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