#!/bin/sh
# a1-mutt-calendar - run mutt-vcalendar-filter and mutt-ical to process ical VCALENDAR file on stdin
# This script is in the public domain
# Author: Joost van Baal-Ilić, january 2019
# maintained at git git.mdcc.cx ad1810-scripts/stuff
# Use this script to reply on a iCalendar aka VCALENDAR thingie. Uses mutt-ical as currently
# maintained by Martin "marvinthepa" Sander. It's about what is specified in
# "Internet Calendaring and Scheduling Core Object Specification (iCalendar)" @
# RFC 5545
# See also: sudo apt install todoman (in debian buster/10 and 11/bullseye)
# Usage:
# run mutt
# open a message with a calendar invitation
# press v to view attachments
# scroll to the attachment which looks like e.g.:
# I 4 └─> [text/calendar, base64, utf-8, 2,6K]
# press | (pipe symbol)
# when asked "Pipe to:" enter a1-mutt-calendar
# see stuff fail hard since we lack a controlling tty/terminal
# bugs: even when called as
# joostvb@dijkstra:~% a1-mutt-calendar $mailtje
mailtje=$1
#https://github.com/terabyte/mutt-filters
#joostvb@dijkstra:~/bin% ln -s ../git-ro/mutt-filters/vcalendar-filter mutt-vcalendar-filter
# sudo apt install libdata-ical-perl python-vobject
echo "$0: running mutt-vcalendar-filter"
mutt-vcalendar-filter <$mailtje
# patch this:
# foreach my $key ( qw(summary BR description BR location organizer dtstart dtend) ) {
# we want to parse this too:
# ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=J.E. van B
# aal:MAILTO:J.E.vanBaal@uvt.nl
# joostvb@dijkstra:~/git-ro% git clone https://github.com/marvinthepa/mutt-ical.git
# joostvb@dijkstra:~/bin% ln -s ../git-ro/mutt-ical/mutt-ical.py mutt-ical
echo "$0: running mutt-ical interactively, using $email as sender address"
mutt-ical -i -e $email $mailtje
echo "$0: finished"
# чет, 9. феб 2023. 14:12:46 CET
# https://github.com/marvinthepa/mutt-ical/blob/master/mutt-ical.py
# root@banach:~# apt update && apt -V dist-upgrade python3-vobject
# joostvb@banach:~% mutt-ical.py -i -e j.e.vanbaal@tilburguniversity.edu /tmp/cal
# Accept Invitation? [Y]es/[n]o/[t]entative/[c]ancel
# Y
# Seems like you have not been invited to this event!
# joostvb@banach:~%
#
# joostvb@banach:~% mutt-ical.py -i -e 'J.E.vanBaal@tilburguniversity.edu' /tmp/cal
# Feb 9 14:15:45 banach postfix/smtp[4835]: 990261F351: to=, relay=mailhost-prdtnnng.uvt.nl[137.56.247.246]:25, delay=0.51, delays=0.01/0/0.04/0.47, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as A4787B9)