Git Product home page Git Product logo

telegraph_daily's Introduction

Telegraph Daily

A python script that sends me daily top headlines with the help of github actions.

This script creates a telegra.ph page with the news recieved from newsapi.org every time it is executed and sends the link to the telegraph page via telegram bot api.

Here is a link to a sample page that this script creates.
See the logs.txt for latest page created by this script.

How to set-up

1. Get API Access Tokens and Keys.

  • Telegram Bot API
    Follow this guide to get a telegram bot api token.
  • Telegraph API
    You can create a telegraph account by using telegraph api python module.
    Or you can copy and paste this link with a new short_name and author_name in your browser, and copy access_token from there. https://api.telegra.ph/createAccount?short_name=Sandbox&author_name=Anonymous
  • NewsAPI.org API Key
    Register on newsapi.org to get your api key.
  • Chat-ID
    As this script does not reply to bot commands but rather sends a message automatically, you need to get the chat id for your telegram account for this to work. To get it follow this link.

2. Set-up github secrets

To access the api keys we need to store them in environment variables. While using github actions to run your scripts these environment variables are called github actions secrets. To set-up a secret goto, Settings > Secrets > Actions > New repository secret and save -

  • Telegram Bot API key as TELEGRAM_API_KEY
  • Telgraph access token as TELEGRAPH_TOKEN
  • NewsAPI API key as NEWS_API
  • and Chat ID as CHAT_ID

3. Finalising

Now, the script is ready to run.
To change the timing of github actions, edit .github/workflows/main.yml and change - cron * * * * * *.
To change the localisation and category of news, edit main.py and change top_headlines = newsapi.get_top_headlines(language='en',country='in').

Thank You, for visiting my repo.

telegraph_daily's People

Contributors

actions-user avatar iusekarma avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.