Giter Club home page Giter Club logo

readability-bot's Introduction

Readability Bot

A wrapper around Readability.js.

Telegram bot: @Readabbot

Web app: https://readability-bot.vercel.app

API

Endpoint: /api/readability?url={URL}&format=json (e.g.)

Returns a self-explanatory JSON inherited from Readability.js.

Instant View for any* website

Bot

The Telegram bot returns "readable" articles with Instant View enabled automatically.

Web service

It is also possbile to apply a quick Instant View to any* website programmatically with the help of the web service. Assuming ARTICLE_TITLE="Lorem Ipsum", ARTICLE_URL="https://example.org/blog-post/1" and CHANNEL is the ID of channel, which typically is the subscribing channel for a (news/blog/etc.) website:

JavaScript:

const readableUrl = `https://readability-bot.vercel.app/api/readability?url=${encodeURIComponent(
  ARTICLE_URL
)}`;
const ivUrl = `https://t.me/iv?url=${encodeURIComponent(
  readableUrl
)}&rhash=71b64d09b0a20d`;

const message = `<a href="${ivUrl}"> </a><a href="${articleUrl}">${ARTICLE_TITLE}</a>`;
bot.sendMessage(CHANNEL, message, (parseMode = "html"));

Python:

  import urllib.parse import quote as percent_encode
  # ... ...
  readable_url = f'https://readability-bot.vercel.app/api/readability?url={percent_encode(ARTICLE_URL, safe="")}';
  iv_url = f'https://t.me/iv?url={percent_encode(readable_url, safe="")}&rhash=71b64d09b0a20d';

  message = f'<a href="{iv_url}"> </a><a href="{article_url}">{articleTitle}</a>';
  bot.send_message(CHANNEL, message, parse_mode="html") # await it?

*: Almost, with no guarantee. Compatibility issues for specific websites are generally not accepted in this project. Please report those to readability.js, if applicable.

Deploy Your Own

Deploy with Vercel

And, some environment variables are expected:

  • BOT_TOKEN: REQUIRED for the bot service. Do not forget to set the webhook address to {APP_URL}/api/webhook.
  • APP_URL: Optional, inferred automatically from Vercel runtime. e.g. https://readability-bot.vercel.app
  • READABILITY_API_URL: Optional, inferred automatically from Vercel runtime. e.g. https://readability-bot.vercel.app/api/readability
  • IV_RHASH: Optional, 71b64d09b0a20d is used by default.

Run locally

npx vercel dev

readability-bot's People

Contributors

gowee 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.