49
Telegram Bot 开发的代理设置
source link: https://arminli.com/telegram-bot/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Armin's Blog
Telegram Bot 开发的代理设置
February 13, 2018
在开发 Telegram Bot 时,我们要在本地测试机器人,但是其服务被墙,这里以 python-telegram-bot 为例,列出一些解决方法。
1. Updater
https://python-telegram-bot.readthedocs.io/en/stable/telegram.ext.updater.html#Updater.running :
updater = Updater(token=TOKEN, request_kwargs={'proxy_url': 'socks5://127.0.0.1:1080/'})
2. Bot
https://python-telegram-bot.readthedocs.io/en/stable/telegram.bot.html :
proxy = telegram.utils.request.Request(proxy_url='socks5://127.0.0.1:1080')
bot = telegram.Bot(token=TOKEN, request=proxy);
3. proxychains4
直接使用 proxychains-ng 运行程序:
proxychains4 python main.py
4. VPS
最后一种最简单的方法就是直接在墙外 VPS 上开发,潜在的缺点是延迟太高导致打码有迟钝感,这可以通过 mosh 缓解。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK