maunium-stickerpicker-nix/README.md

87 lines
3.3 KiB
Markdown

[![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)
# maunium-stickerpicker-nix
Nix wrapper for [maunium/stickerpicker][maunium-stickerpicker] customized for pub.solar.
## Usage:
Overview of steps:
1. Download additional stickers manually from signalstickers.org
2. (Optional) Define desired stickers in `flake.nix` as type `chatsticker`
3. (Optional) Build `.#pub-solar-stickers`
4. Create `config.json` with `@stickerbot` Matrix access token
5. Upload stickers to matrix `@stickerbot` user's media and store thumbnail URLs in `*.json` files
6. Include `*.json` files in host config flake, see [example]()
`config.json` example:
```
{
"homeserver": "https://matrix.your.domain",
"user_id": "@stickerbot:matrix.your.domain",
"access_token": "<stickerbot-matrix-access-token>"
}
```
Commands:
```
# Enter nix devshell
nix develop
# Get URL from button on signalstickers.org -> "Add to Signal" -> Right-Click -> "Copy Link"
# Repeat for each signal sticker pack
python -m sigstickers --pack 'https://signal.art/addstickers/#pack_id=7d4893e5bb03ad6ec5f8a5effbdada62&pack_key=fa9893126e26c0d28ed332c08c99f13700497c1fe15980d5069f6c4e48b619ee'
sticker-pack --config config.json --add-to-index ./uploaded-packs/ --title "lindner" downloads/Lindner/png/
# Move images around, json "id" gets set from dirname
for dir in $(ls ./downloads); do mv ./downloads/$dir/png/* ./downloads/$dir/; done
for dir in $(ls ./downloads); do rm -r ./downloads/$dir/gif ./downloads/$dir/png ./downloads/$dir/webp; done
# Upload stickers to matrix and generate json files with thumbnail URLs
for dir in $(ls ./downloads); do sticker-pack --config config.json --add-to-index ./uploaded-packs/ --title "$dir" ./downloads/$dir; done
# Add json files to git, commit and push changes
git add uploaded-packs/
git commit
git push
```
Here's an example of a stickerpicker config in this flake
```nix
```
Afterwards, you can easily host it in an nginx config
```nix
{ ... }:
{
services.nginx.enable = true;
services.nginx.virtualHosts."stickers.myhost.org" = {
forceSSL = true;
enableACME = true;
root = pkgs.element-stickerpicker;
};
}
```
## List of available fetchers
| Site | Type Name |Required Arguments |
|------|-----------|-------------------|
| `<local dir>` | `directory` | `src` (path to a local dir with image files) |
| https://chatsticker.com | `chatsticker` | `name` (see url) |
## Some notes
To use this, leave the `sha256` empty at first, build the stickerspicker with whatever stickers you'd like, and paste the `sha256` from the error message back into your code.
Normally, [maunium/stickerpicker][maunium-stickerpicker] would cache the stickers in a config file, and reuse the config file on the next run in order not to.
This does not work with Nix' determinism.
Thus every time you want to add just 1 more stickerpack (or any other kind of edit), this will reupload all stickers.
In order to make it easier to delete all sticker once in a while, I would recommend creating a separate user (I've called mine `stickerbot`), whose only purpose is to be the owner of a bunch of sticker media files.
Whenever you want to clean up the media store, just delete all the media file of `stickerbot` (**THIS WILL BREAK OLDER MESSAGES**)
[maunium-stickerpicker]: https://github.com/maunium/stickerpicker