Skip to content

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

Notifications You must be signed in to change notification settings

Gowee/readability-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published