A Matrix bot which can generate "This Week in X" like blog posts

Overview

hebbot

A Matrix bot which can help to generate periodic / recurrent summary blog posts (also known as "This Week in X").

The bot was inspired by twim-o-matic, and is developed in Rust using the matrix-rust-sdk.

Features

  • Automatic recognition of news when the bot username is mentioned at the beginning of the message
  • Approval of messages by a defined group of editors
  • Messages can be sorted into projects / sections by using emoji reactions
  • Support for images / videos
  • Markdown generation (can be used for blogs, e.g. Hugo)

Screenshots

Usage

Two Matrix rooms are required to use this bot.

"Reporting" room

This room is open to everyone. Here people can share news any time. Editors can mark messages, but also images and videos with emoji reactions here. For example...

  • : Approve a message (to include it in the rendered markdown)
  • 📷️ : Add image. The image will then be automatically added to the corresponding news message, and inserted in the rendered markdown.
  • 🛰️ : Add message to the third-party section

Those emojis are just an example, you can configure them as you want in the config.toml file.

"Admin" room

In this closed room administrative commands can be executed.

Command Description
!clear Clears all stored news
!list-config Lists current bot configuration
!list-projects Lists configured projects
!list-sections Lists configured sections
!render Creates a markdown file with the stored news
!restart Restarts the bot, useful when you edited the configuration
!say "message" Sends a message in reporting room
!status Shows saved messages

Configuration

In order to use the bot, two configuration files are required. The config.toml configuration file contains the bot settings (e.g. username/password, room ids, ...) and the definitions for the sections and projects. The second configuration file template.md serves as a template for the actual summary.

For both configuration files, examples are available that can be used as templates (configuration/*.example files).

Deployment

The bot is available as docker image.

Example docker-compose:

services:
  hebbot:
    image: haeckerfelix/hebbot:v2.0
    restart: unless-stopped
    volumes:
      - hebbot_data:/data
    environment:
      - CONFIG_PATH=/data/config.toml
      - TEMPLATE_PATH=/data/template.md
      - STORE_PATH=/data/store.json

volumes:
  hebbot_data:

The configuration files have to be placed in the hebbot_data volume.

Example usage

Hebbot gets used to generate the weekly GNOME summaries ("This Week in GNOME"). More information, and usage examples can be found here:

Comments
  • images: Support High DPI screenshots

    images: Support High DPI screenshots

    • Mark images as high DPI in report room
    • Generate HTML that scales the images correctly

    My idea was to tag screenshots with both, the notice ⭕ and something like 2️⃣ for 2x scaling. Would require enhancing the data structure for News.images. Would probably make sense to make it a struct at this point?

    opened by sophie-h 5
  • Fixes #49, #54 - React to displayname and remove it from the message

    Fixes #49, #54 - React to displayname and remove it from the message

    This is my first attempt to do anything serious with Rust, and I suspect I'm breaking a lot of rules. However, it appears to work, so hopefully we can tidy it up. Examples:

    Reporting room:

    Gwmngilfen: newsbot 🗞️: this report is using a display name!
    newsbot 🗞️: ✅ Thanks for the report Gwmngilfen, I'll store your update!
    Gwmngilfen: @hebbot:mydomain.org this report is using a full id
    newsbot 🗞️: ✅ Thanks for the report Gwmngilfen, I'll store your update!
    Gwmngilfen: hebbot this report is using a localpart only
    newsbot 🗞️: ✅ Thanks for the report Gwmngilfen, I'll store your update!
    

    Rendered MD:

    [Gwmngilfen](https://matrix.to/#/@gwmngilfen:ansible.im) says
    > this report is using a full id
    
    [Gwmngilfen](https://matrix.to/#/@gwmngilfen:ansible.im) says
    > this report is using a localpart only
    
    [Gwmngilfen](https://matrix.to/#/@gwmngilfen:ansible.im) reports
    > this report is using a display name!
    

    The code is really ugly. In particular, I think I should just pass the whole Bot object to msg_starts_with_mention and then extract the user_id and displayname inside - but I couldn't work out how to make the type-checking work with that. Instead I'm left with a lot of string unwrapping that is fairly nasty.

    Also, I see there's a nice method to get display names for reporters - but that requires a RoomMember object, which the bot is not - could that be reused in some way?

    Looking forward to the feedback!

    opened by GregSutcliffe 5
  • Use distinct emojis for reporting and editor approval

    Use distinct emojis for reporting and editor approval

    Sometimes people can forget to mention the bot when reporting news. It's quite noisy to copy the former message, potentially redact it and send a new one by mentioning the bot first.

    If the person who reported the news could react to it with an emoji (⭕ by default, configurable?) to tell the bot it actually was a news report, it would make reporting rooms less noisy. Bonus points: it's consistent with twim-o-matic 😇

    Then the editor can approve the news e.g. with the ✅ emoji (instead of ⭕ by default today)

    opened by thibaultamartin 4
  • Make the template more configurable

    Make the template more configurable

    It would be very helpful to be able to set:

    • How section are rendered (variable available: {{section.emoji}}, {{section.title}})
    • How projects are rendered (variables available: {{project.emoji}}, {{project.title}}, {{project.website}}, {{project.description}})

    It would typically allow people to have sections that are h2 title in markdown and not h1 title by declaring them as ## {{section.title}} and to change how project titles are rendered, e.g. as ### {{project.title}} ([link]({{project.website}}))

    enhancement 
    opened by thibaultamartin 3
  • Stripping the bot name from the news item leaves some characters behind

    Stripping the bot name from the news item leaves some characters behind

    When the bot display starts the same as the MXID, but has extra characters, then the truncation goes wrong. I noticed this because my bot is on my Conduit server, and Conduit adds :zap: too all display names by default :)

    ID: "[email protected]" Display: "Hebbot :zap:"

    News item: "hebbot :zap:: some more news is you! A thing is good!" Rendered text: "> ⚡️: some more news is you! A thing is good!"

    You can see it has left the :zap: and the colon behind.

    bug 
    opened by GregSutcliffe 1
  • Fixes #40 - give projects and sections their own templates

    Fixes #40 - give projects and sections their own templates

    OK, this was a bit harder, I learned some Rust :)

    I'm not sure if the reading of the template files is in the right place, but I also wasn't sure about how to pass the resulting strings around, so this seemed cleaner. Feedback very welcome!

    opened by GregSutcliffe 1
  • Fixes #50 - make verbs configurable

    Fixes #50 - make verbs configurable

    My first attempt at Rust, so comments very welcome :)

    Also, for some reason, using "./config.toml" etc wasn't working in gitignore while I was testing, so I changed "./" to just "/" so it ignores those files in the project root. Can drop that commit if it's a problem, just let me know.

    opened by GregSutcliffe 1
  • Using the reaction-submission overwrites the mention-submission

    Using the reaction-submission overwrites the mention-submission

    This relates to this news item

    So it would seem that using the reaction to flag a post overwrites any previous metadata. This is the timeline:

    1. The above item is posted with a correct mention of the bot, and the bot notices and replies
    2. Editor adds a project reaction (🪜)
    3. Editor adds a submission reaction (:o:)

    Result: no project/section (via default_section) is stored:

    • ℹ️ 1 news are not included because of project/section assignment is missing. Use !status command to list them. ❌ Unassigned / ignored news entries (1):
    • [open message] @andersson007_:matrix.org: the [community.libvirt](https://github.com/ansible …

    Looking at the logs around the submission, I see this:

    ✅ @andersson007_:matrix.org submitted a news entry. [open message] ✅ Editor @cybette:ansible.im added the project description “Maintainers” to @andersson007_:matrix.org’s news entry [open message]. ✅ @andersson007_:matrix.org submitted a news entry. [open message]

    The second "submission" is clearly a duplicate caused by step 3 in the timeline. It should:

    1. Not overwrite the previous submission
    2. Probably log something different so editors know that it is unneccessary
    bug 
    opened by GregSutcliffe 1
  • Choosing between 📷️ and 📹️ should not be necessary when adding a media to a news

    Choosing between 📷️ and 📹️ should not be necessary when adding a media to a news

    Hebbot is already able to distinguish between a picture and a video. It shouldn't be necessary for the editor to make the distinction.

    Simply using 📷️ for both should work.

    enhancement 
    opened by thibaultamartin 1
  • Add news entry to a category by answering the report in the admin room

    Add news entry to a category by answering the report in the admin room

    When a news entry gets announced in the admin room as follows:

    ✅ @person:provider.org submitted a news entry. [open message]

    Replying to that message with project projectName should:

    • Make the bot add the reaction emoji corresponding to the project in the news report
    • Add the news entry in the corresponding section

    Replying to the same message with clear project should make the bot un-react to the original report and remove it from the corresponding section.

    opened by thibaultamartin 1
  • Hebbot reacts to commands in admin room

    Hebbot reacts to commands in admin room

    Hebbot adds a :heavy_check_mark: reaction to commands in the admin room when it successfully executed it Hebbot adds a :x: reaction to commands in the admin room when it failed to execute it

    opened by thibaultamartin 1
  • Allow templates for downloaded files

    Allow templates for downloaded files

    Atm the names of the files downloaded with the curl command are quite cryptic. Templatifying the names of the downloads would be great. The following variables make sense imho:

    • yyyy year in 4 digits format
    • mm month of the year
    • dd day of the month
    • section name of the section in which the related news is in (if any, nosection if in none), kebab cased
    • project name of the project to which the related news is in (if any, noproject if in none), kebab cased

    In case of duplicate name, appending a -n with n being an integer should do the trick

    An example of template for the downloads could be: {{ yyyy }}-{{ mm }-{{ dd }}-twim-{{ section }}-{{ project }} The resulting downloaded file would be:

    • 2022-10-14-twim-clients-element-ios.png
    • 2022-10-14-twim-clients-element-ios-1.png
    • 2022-10-14-twim-servers-noproject.jpg
    enhancement 
    opened by thibaultamartin 0
  • Allow editor to ask hebbot to re-send reactions

    Allow editor to ask hebbot to re-send reactions

    When #69 is merged, it would be very handy to be able to ask hebbot to scan a message again and post reactions to the message with the matching projects.

    enhancement 
    opened by thibaultamartin 0
  • Use objects instead of arrays for projects, sections?

    Use objects instead of arrays for projects, sections?

    Since every section and project seems to have a sort of id ("name") in addition to its title, is this not an obvious place to use an object instead and change

    [[section]]
    name = "foo"
    title = "Foo"
    

    to

    [section.foo]
    title = "Foo"
    

    ?

    enhancement 
    opened by jplatte 0
  • Allow the bot to respond to reports with a reaction

    Allow the bot to respond to reports with a reaction

    In some circumstances it is nice to have some indication that the bot saw your report via reactions - especially where there is heavy use of notice_emoji which suppresses the text acknowledgement.

    This PR adds an ack_emoji, and allows for it to be disbled in the config. Best paired with #62 which would allow you to either disabled all text and just use reactions, or disable reactions and just use text, or a mix of both.

    opened by GregSutcliffe 2
Releases(v2.1)
  • v2.1(Oct 3, 2021)

    Changelog

    • The bot automatically accepts room invites now on startup (reporting/admin room) (https://github.com/haecker-felix/hebbot/commit/4c857370f399f82ba423eff8027b4061b9b733c2)
    • New !about command to print bot version (https://github.com/haecker-felix/hebbot/commit/1715051a41dbfd7ab1c1ccca4ad5d6db25c8e85b)
    • New !details command to show details for a specific section / project (https://github.com/haecker-felix/hebbot/commit/9330fd209eec1e06c6358b678026aa7ce605c92b)
    • Bot messages are now using m.notice as message type (https://github.com/haecker-felix/hebbot/commit/029f2cdf45106b88cc6dac373e9d4d7fa6ed7909)
    • Fixed a bug where the !render command didn't display the correct number of rendered news (https://github.com/haecker-felix/hebbot/commit/b0b2c101253b64d31398ad57fd88fb11d7dd3abd)

    This update can be installed with no need to make any changes to the configuration file.

    Source code(tar.gz)
    Source code(zip)
  • v2.0(Aug 11, 2021)

    Hebbot v2.0 is out and it packs a lot of goodness so reports are easier and faster than ever to issue!

    The new !render command now warns you about common mistakes like:

    • a news entry has been added to several sections or projects (and will be rendered several times)
    • a news entry is lacking both a section or project (and will not be rendered at all)

    It also tells you when you probably forgot something, i.e. when:

    • a news entry is not added to any project
    • a news entry is about a given project, but it has also been added to a section which is not the default one for this project

    You don't need to add both the project and the section for a news entry anymore. Hebbot's configuration file now allow you to add your project to a default_section. Then, when you add a project to a news entry, Hebbot will automatically add it to the default section for that project as well.

    Hebbot is now less strict: while the previous version forced you to define a project, you can now add a news entry only to a section and it will be rendered. Hebbot also allows you to add several news to a single project and will not duplicate the section or project title.

    And finally, one of the greatest improvements of this release is the ability to keep track of photos and videos as well! When someone reports a piece of news and sends a photo/video shortly before/after, an editor can tag it with 📷️/📹️. Next time you issue the !report command, Hebbot will generate a report with the proper markdown to add the photos and videos and will give you a curl command to paste in your terminal to retrieve all the media assets!

    IMPORTANT UPGRADE NOTE: Hebbot v1.0 cannot be upgraded directly to v2.0. The configuration file must be adapted (JSON -> TOML). You can use the following file as a template: config.toml.example

    To simplify the upgrade you can use the following web tool: https://pseitz.github.io/toml-to-json-online-converter/ (Don't forget to add the new values like default-section, image_emoji, image_markdown, ... and some values were renamed like project repository -> website)

    Source code(tar.gz)
    Source code(zip)
Owner
Häcker Felix
Häcker Felix
A bunch of links to blog posts, articles, videos, etc for learning Rust

rust-learning A bunch of links to blog posts, articles, videos, etc for learning Rust. Feel free to submit a pull request if you have some links/resou

Camille TJHOA 8.8k Nov 29, 2022
Blog posts, mostly about Rust.

Sean Chen's Blog ?? Blog posts, mostly about Rust. Posts Date Title 2021-04-06 A Beginner's Guide to Handling Errors in Rust 2021-01-23 Implementing a

Sean Chen 13 Sep 4, 2022
fast rust implementation of online nonnegative matrix factorization as laid out in the paper "detect and track latent factors with online nonnegative matrix factorization"

ONMF status: early work in progress. still figuring this out. code still somewhat messy. api still in flux. fast rust implementation of online nonnega

null 2 Apr 10, 2020
A tray application for Windows that gives you push notifications and instant downloads of new posts, messages and stories posted by models you subscribe to on Onlyfans.

OF-notifier A tray application for Windows that gives you push notifications and instant downloads of new posts, messages and stories posted by models

Gentlemen Mercenary 7 Nov 25, 2022
Cogo is a high-performance library for programming stackful coroutines with which you can easily develop and maintain massive concurrent programs.

Cogo is a high-performance library for programming stackful coroutines with which you can easily develop and maintain massive concurrent programs.

co-rs 47 Nov 17, 2022
Powerful math lib for Vector, Matrix and Quaternion operations

An opinionated, powerful math lib for Vector2, Vector3, Matrix and Quaternion operations Vector2 Add, Sub, Div, Mul, Eq Distance Move towards target a

O(ʒ) 4 Mar 28, 2022
Powerful math lib for Vector, Matrix and Quaternion operations

An opinionated, powerful math lib for Vector2, Vector3, Matrix and Quaternion operations Vector2 Add, Sub, Div, Mul, Eq Distance Move towards target a

O(ʒ) 4 Mar 28, 2022
This blog provides detailed status updates and useful information about Theseus OS and its development

The Theseus OS Blog This blog provides detailed status updates and useful information about Theseus OS and its development. Attribution This blog was

Theseus OS 1 Apr 14, 2022
Zomby7e's Blog - Backend

7eblog_backend Zomby7e's Blog - Backend, is just a micro blog backend. This project is written in Rust, it depends on Actix, uses SQLite to store data

Zomby7e 2 Aug 26, 2022
Generate voxel block meshes in Rust.

block-mesh Fast algorithms for generating voxel block meshes. Two algorithms are included: visible_block_faces: very fast but suboptimal meshes greedy

Duncan 82 Dec 1, 2022
This crate allows to generate a flat binary with the memory representation of an ELF.

flatelf Library This crate allows to generate a flat binary with the memory representation of an ELF. It also allows to generate a FLATELF with the fo

Roi Martin 3 Sep 29, 2022
A peer-reviewed collection of articles/talks/repos which teach concise, idiomatic Rust.

This repository collects resources for writing clean, idiomatic Rust code. Please bring your own. ?? Idiomatic coding means following the conventions

Matthias 4.1k Nov 26, 2022
An embedded key-value storage for learning purpose, which is based on the idea of SSTable / LSM-tree.

Nouzdb An embedded key-value storage for learning purpose, which is based on the idea of SSTable / LSM-tree. Plan Implement a memtable. Implement the

Nouzan 1 Dec 5, 2021
ArbOS operating system, to run at Layer 2 on Arbitrum chains. Also a compiler for Mini, the language in which ArbOS is written.

ArbOS and Mini compiler ArbOS is the "operating system" that runs at Layer 2 on an Arbitrum chain, to manage the chain's operation, maintain security,

Offchain Labs 88 Nov 6, 2022
Core Temporal SDK that can be used as a base for language specific Temporal SDKs

Core SDK that can be used as a base for all other Temporal SDKs. Getting started See the Architecture doc for some high-level information. This repo u

temporal.io 131 Nov 21, 2022
Rust 核心库和标准库的源码级中文翻译,可作为 IDE 工具的智能提示 (Rust core library and standard library translation. can be used as IntelliSense for IDE tools)

Rust 标准库中文版 这是翻译 Rust 库 的地方, 相关源代码来自于 https://github.com/rust-lang/rust。 如果您不会说英语,那么拥有使用中文的文档至关重要,即使您会说英语,使用母语也仍然能让您感到愉快。Rust 标准库是高质量的,不管是新手还是老手,都可以从中

wtklbm 481 Nov 30, 2022
Custom deserialization for fields that can be specified as multiple types.

serde-this-or-that Custom deserialization for fields that can be specified as multiple types. This crate works with Cargo with a Cargo.toml like: [dep

Ritvik Nag 7 Aug 25, 2022
TypeRust - simple Rust playground where you can build or run your Rust code and share it with others

Rust playground Welcome to TypeRust! This is a simple Rust playground where you can build or run your Rust code and share it with others. There are a

Kirill Vasiltsov 29 Nov 19, 2022
In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang.

Learn Rust What is this? In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang. This is usef

Domagoj Ratko 5 Nov 5, 2022