Giter Club home page Giter Club logo

formatbot1's Introduction

This bot makes instant view from channel post that have not IV

You can find this bot by keywords such as “InstantViewBot”

Features

  • Extract link from amp,clck,bit.ly
  • Create IW from any full link
  • Compress Content
  • Partially support too long content
  • Second "process queue"
  • Text/Html/MD Document from storage
  • Better parse images
  • Multi links

🔨 Installation

Required env:

  • DEV = 1 show logging
  • TBTKN = bot token
  • TGGROUP = group for logs
  • TGADMIN = admin telegram id
  • TGPHTOKEN = Telegra.ph token
  • MESSAGE_QUEUE = rabbitmq message queue connection, thanks cloudamqp.com
  • MONGO_URI = mongodb connection uri, thanks cloud.mongodb.com

formatbot1's People

Contributors

albertincx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

formatbot1's Issues

Change content parser

@mozilla/readability is better than @postlight/mercury-parser

here is an example page: https://www.douban.com/people/166039423/status/3594363157/

@mozilla/readability can get main content but @postlight/mercury-parser can't.

main content is:
image

example's source code
var fs = require('fs')
var { Readability } = require('@mozilla/readability')
var Mercury = require('@postlight/mercury-parser')
var { JSDOM } = require('jsdom')

// source html is from: https://www.douban.com/people/166039423/status/3594363157/
var html = fs.readFileSync('t.html', 'utf8')

var doc = new JSDOM(html)

var reader = new Readability(doc.window.document)
var article = reader.parse()

console.log('mozilla_____', article)

Mercury.parse(
  'https://www.douban.com/people/166039423/status/3594363157/',
  {
    html,
  }
)
  .then((res) => {
    console.log('mercury_____', res)
  })
  .catch((err) => {
    console.log('mercury_____', err)
  })

Sorry, but your link (https://mp.weixin.qq.com/s/xxxxxx) is broken, restricted, or content is empty

InstantViewBot  | availableOne true
InstantViewBot  | elTime 223
InstantViewBot  | 223s, 214ms test1DEV
InstantViewBot  | queue job undefined
InstantViewBot  | reset start2
InstantViewBot  | merc
InstantViewBot  | before san 349
InstantViewBot  | length 70
InstantViewBot  | domed 126
InstantViewBot  | Error: empty ivlink
InstantViewBot  |     at Object.makeIvLink (/app/src/api/utils/ivMaker.js:45:11)
InstantViewBot  |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
InstantViewBot  |     at async jobMessage (/app/src/api/routes/format/index.js:434:11)
InstantViewBot  | error = broken https://mp.weixin.qq.com/s/xxxxxxx Error: empty ivlink

how to fix it?
Thanks!

Hint: add proxy config If the program runs in LAN or China.

Anyone who wants to run this program in the local area network or China(GFW), should modify these places:

  1. src/config/bot.js
...
var httpsAgent = require('socks5-https-client/lib/Agent');
...

const opts = {
    channelMode: true,
    telegram: {
        agent: new httpsAgent({
            socksHost: '127.0.0.1', // Defaults to 'localhost'.
            socksPort: 1085, // Defaults to 1080.
        }),
    },
};
  1. src/api/utils/makeTelegaph.js
...
var httpsAgent = require('socks5-https-client/lib/Agent');
...

return fetch('https://api.telegra.ph/createPage', {
    body: JSON.stringify(body),
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    agent: new httpsAgent({
      socksHost: '127.0.0.1', // Defaults to 'localhost'.
      socksPort: 1085, // Defaults to 1080.
    })
})

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.