- Create a telegram bot using botfather
First run
/newbot
and provide a bot name
after that provide a bot username
You will receive a bot token which must be saved.
- Create an OWM API Token
Look at the instructions to get access the API and generate a token on
Edit all the values in config.yml to the correct values. Most important are the bot and OWM API token.
NOTE: use the config.yml and NOT the sample_config.yml. The sample_config is only there to provide an example.
- Install requirements.txt
It is recommended to create a venv for this so ensure that is installed
ai-dan@fedora~$ cd {program_directory}
ai-dan@fedora~$ python3 -m venv {venv_name}
ai-dan@fedora~$ source venv/bin/activate
ai-dan@fedora~$ (venv) pip install -r requirements.txt
If you don't wish to run a virtual environment then run the last command without running any others.
- Create the bot as a python package
Do this only if it hasn't already been created as a package.
ai-dan@fedora~$ pip install -e .
- Run the bot, ensuring that the user is in their virtual environment (venv).
ai-dan@fedora~$ python3 -m src
First ensure that docker is installed. An install guide is
- Create the docker container
ai-dan@fedora~$ sudo docker build -t {container-name} .
- Run the docker container
aidan@fedora~$ sudo docker run {container-name}
This program uses which is simple to set up and great for running small Python programs with its free or paid plans.
Ensure that you have created an account on PythonAnywhere and at least used their free plan, otherwise other plans work just fine and could provide better processing power.
First, you must zip up the whole application recursively to upload it to PythonAnywhere, and then unzip it on the platform to run it.
ai-dan@fedora~$ cd {program_directory}
ai-dan@fedora~$ zip -r {zip_filename} {directory_path}
If you go to the Files
section of PythonAnywhere, then you'll see the option to upload files as shown below
After uploading the files you must unzip them as shown below
ai-dan@fedora~$ unzip -D {zip_filename}
ai-dan@fedora~$ cd {unzipped_file}
From here you can use the manual method as explained above to run the bot. When you close the web application then you notice that the bot will still be running. Note that if you use PythonAnywhere with a free plan then you can only run the bot for a limited amount of time as the server bounces and resets. To resolve this you should note when the bot will reset and then run the program again. Otherwise, you should get a paid plan of PythonAnywhere to run the bot infinitely.
Thanks for checking out the program. If possible a star would be appreciated.