PythonAnywhere Forums

Telegram Bot

How a can deploy a telegram bot on pythonanywhere

Hi there,

There are people who have deployed a telegram bot on PythonAnywhere.

I would suggest reading this and this.

Thanks, in the links there are information for bot development have someone published a step by step guide to deploy a telegram on PythonAnywhere?

I don't think we've seen one, no.

Something strange here. I can't access telegram API. I tried this in console:

import telepot token = 'mytokennumbers' bot = telepot.Bot(token) bot.getMe()

It works on my local machine, but here i get an error: ... raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='', port=443): Max retries exceeded with url: /bot<mytokennumbers>/getMe (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f35a6934750>: Failed to establish a new connection: [Errno 101] Network is unreachable',))

That looks like it's because you're not using the proxy. You'll need to configure bot to use the proxy server. The address is proxy.server on port 3128.

Many thanks! It works now.

python-telegram-bot is a pretty good API, I recommend using that.

Hi, I have the same connection problem into the bash. Can you explain me better how to solve it ? Many thanks!

How are you connecting over bash?

To use telepot from a PythonAnywhere free account, put this code at the top of your bot's code:

import telepot
import urllib3

proxy_url = "http://proxy.server:3128"
telepot.api._pools = {
    'default': urllib3.ProxyManager(proxy_url=proxy_url, num_pools=3, maxsize=10, retries=False, timeout=30),
telepot.api._onetime_pool_spec = (urllib3.ProxyManager, dict(proxy_url=proxy_url, num_pools=1, maxsize=1, retries=False, timeout=30))

I've just published a detailed blog post explaining how to create a Telegram bot on PythonAnywhere.

Thanks guys, I've done! Thanks very much for the help, u r great! Now everything is running, it's my first bot and I'm still rookie :)

Great! Glad you got it working :-D

I need help I tried running the import telepot something but they keep telling me that "no Modula name" how can I get pass that one

You haven't installed the library or you're using a Python version that is different to the one that you installed the library into.