Birthday notifications for SinusBot

subDesTagesMitExtraKaese 705c0351c7 added full node.js environment for DAV client преди 4 години
node_modules 705c0351c7 added full node.js environment for DAV client преди 4 години
test e69c31f000 init преди 4 години
.gitignore 705c0351c7 added full node.js environment for DAV client преди 4 години
.gitmodules e69c31f000 init преди 4 години
LICENSE 41aea044d3 Initial commit преди 4 години
README.md 705c0351c7 added full node.js environment for DAV client преди 4 години
birthday.js 705c0351c7 added full node.js environment for DAV client преди 4 години
ws-server.js 705c0351c7 added full node.js environment for DAV client преди 4 години

README.md

sinusbot-birthday-script

Birthday notifications for SinusBot

Sends private message or pokes users on join when someone had birthday.

Install

  1. copy birthday.js into your scripts folder
  2. restart sinusbot
  3. fill in admin options in Web GUI
  4. activate script in Web GUI

Admin options

  • The message that should be displayed. (%n = nickname, %b = list of birthdays)

    Hallo %n! Diese Personen haben Geburtstag:
    %b
    Um deinen eigenen angekündigt zu haben, schreibe einfach z. B.:
    !birthday 24.12.
    
  • select 'Private chat' or 'Poke'

  • send the notification upto N days after birthday

  • set a birthday server group by id or name

Commands

  • !birthdays lists all birthdays
  • !birthday show own birthday
  • !birthday <date> set own birthday, where <date> could be 24.12., dec-24, 12-24or similar
  • !birtday clear reset own birthday

Setup CardDAV client

Sinusbot doesn't allow direct communication via DAV, so this client runs seperately. They communicate via ws://127.0.0.1:23845, so the DAV program has to run on the same host as Sinusbot.

  1. Download ws-server.js and node_modules into a seperate folder.

    git clone https://github.com/subDesTagesMitExtraKaese/sinusbot-birthday-script/tree/dav-test
    cd sinusbot-birthday-script
    
  2. Create secrets.js and enter your CardDAV server credentials.

    module.exports = {
    davUrl:         'https://example.com/dav.php',
    davUsername:    'username',
    davPassword:    'password',
    davAddressBook: ''
    }
    
  3. install node.js

    sudo apt update
    sudo apt upgrade -y
    sudo apt autoremove
    sudo apt install nodejs
    
  4. test the program with sinusbot running

    node ws-server.js
    
  5. make it run on boot: create /lib/systemd/system/sinusbot-birthday-sync.service

    [Unit]
    Description=Sinusbot birthday cardDAV sync service
    Wants=network-online.target
    After=syslog.target network.target network-online.target
    
    [Service]
    User=sinusbot
    ExecStart=/usr/bin/node /path/to/your/ws-server.js
    WorkingDirectory=/path/to/your
    Type=simple
    
    [Install]
    WantedBy=multi-user.target
    
    sudo systemctl daemon-reload
    sudo systemctl enable sinusbot-birthday-sync.service
    sudo systemctl start sinusbot-birthday-sync.service