Code Monkey home page Code Monkey logo

newsmaker's Introduction

Newsmaker

Newsmaker is a daemon that implements the news filtering pipeline. The pipeline connects multiple news sources (rss/atom feeds) with multiple notifiers aka "publishers" through multiple filters.

Right now only "http-get" notifiers are supported. This permits you to publish the filtered news in your private Telegram channels using your own custom bot. It is not difficult to add your own custom notifiers/publishers or even custom sources too if rss/atom is not enough.

How to run

newsmaker config.toml

Config.toml sample:

rotation_tick = "45s" # random source will be requested each tick.
mute_hours = [20, 5] # demon will stop sources rotation and be mute from 8pm till 5 am

[[filters]] 
cond = "ABC; DAP" # title must contain either ABC _OR_ DAP
sources = ["main"] # sources to filter
pubs = ["main"]  # publishers that receive message, if cond is true

[[filters]]
cond = "Paris & Hilton"  # title must contain both Paris _AND_ Hilton (in any order)
pubs = ["info"]
sources = ["main", "other"]

[src.main]
cd = "15m" # cd is the cooldown for which the source is excluded from "rotation" after it was requested.
links = ["https://regnum.ru/rss/polit", "https://regnum.ru/rss/accidents"]

[src.other]
cd = "15m"
links = ["https://news.yandex.ru/finances.rss"]

[pub.main]
get_url = "https://api.telegram.org/bot50034962:BBGuVfL-EZ-Wnlj1b80oysOkurJgZdbI/sendMessage?text=%s&chat_id=-20023152348394761&parse_mode=Markdown"

[pub.info]
send_pause = "5s"
get_url = "https://api.telegram.org/bot50034962:BBGuVfL-EZ-Wnlj1b80oysOkurJgZdbI/sendMessage?text=%s&chat_id=-20023152348394761&parse_mode=Markdown"

Filter language description

Filter expression is DNF of regex pattern sequences. Before checking against the filter expression, the sentence (news title) is tokenized into a words sequence.

Filter Grammar EBNF:

Expr := Conj {";" Conj} // ; is OR
Conj := Seq {"&" Seq} // & is AND
Seq := Pattern {" " Pattern} //  a sequence of patterns to match some subsequence of words in a sentence.

Pattern is Go regex with minor *simplifications:

  • Lowercase letter matches both lowercase and uppercase, but uppercase matches only uppercase
  • Prefix match by default. If you need "middle" match, start pattern with star. If you need precise word match, end pattern with dollar. If youn need strict suffix match, start pattern with star and end it with dollar.

Patterns are word patterns i.e. they are matched against individual words of a sentence. If you need to match more than 1 word, you must use a sequence of patterns Seq.

There is special meta-characters for Russian language nouns morphology (see words.go)

todo

  • add more meaningfull unit tests & CI
  • vendoring
  • better docs

newsmaker's People

Contributors

dlepex avatar

Stargazers

 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.