Gowee / readability-bot

A Telegram bot that makes webpages "readable" (Instant View & Inline Mode)

Home Page:https://t.me/ReadabBot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

A Telegram bot that makes webpages "readable" (Instant View & Inline Mode)

https://t.me/ReadabBot


Languages

Language:JavaScript 73.0%Language:HTML 16.0%Language:Svelte 7.3%Language:CSS 3.8%