Commit 5b1f79f4 authored by fuzzle's avatar fuzzle

added some psa scripts - with missing correct cookie values, you NEED php use Sabre\VObject;

for some of the calendar stuff, and you need a working sendmail structure an your mashine
parent be61134b
......@@ -2,19 +2,21 @@
<?php
use Sabre\VObject;
#$file = $argv[1]
include 'vendor/autoload.php';
$vcalendar = VObject\Reader::read(
fopen('/media/freifunk/42-bot/calendar.ics','r')
# fopen('/media/freifunk/42-bot/calendar.ics','r')
fopen($argv[1],'r')
);
echo "\n";
foreach ( $vcalendar->VEVENT as $event) {
if (substr($event->DTSTART,0,8) > (date("Ymd")-2)) {
$something=date_create_from_format("Ymd?His",$event->DTSTART);
echo date_format($something,"d.m.Y H");
echo "h " ;
echo $event->SUMMARY;
echo "\n";
$something=date_create_from_format("Ymd",$event->DTSTART);
echo date_format($something,"Y.m.d");
# echo $formatedsomething->format('Ymd');
echo " - ";
echo $event->SUMMARY;
echo "\n";
}
};
echo "\n";
#!/bin/bash
# get as much calendars as needed and clean timezone stuff for sabredav read
# nextcloud - grether
curl https://nextcloud.cccfr.de/remote.php/dav/public-calendars/CG2k2TZS5c6RzDRc?export > cccfr-cal-grether
# official cccfr-cal-www
curl -k https://cccfr.de/calendar.ics > cccfr-cal-www
# nextcloud - related
curl -k https://nextcloud.cccfr.de/remote.php/dav/public-calendars/6LRFdzNCJMD2Sxd6?export > cccfr-cal-related
# "repair" / adjust the ics files for sabredav
for line in $(ls cccfr-cal-*)
do
# change all DTSTART so TZ is removed
# DTSTART;VALUE=DATE:20190801
sed -E -i s/^"DTSTART"[^0-9]*/"DTSTART;VALUE=DATE:"/g $line
# get line numbers for special sed
for linenr in $(grep -En ^DTSTART.*"T"[0-9]{6} $line | cut -d ":" -f 1)
do
sed -E -i ${linenr}s/T[0-9]{6}// $line
done
done
# sed -E -i s/T[0-9]{6}$//g $line
# sed -i s/DTSTART[^0-9]*//g $line |cut -c 1-8|sed -e s/^/"DTSTART;VALUE=DATE:"/g
#!/bin/bash
if [ $(($(date +%W)%2)) != 0 ];
then
echo -e "\nletztes Pad https://fr.pads.ccc.de/plenum-$(date -d'tuesday-14 days' +%Y%m%d)\nnächstes Plenum https://fr.pads.ccc.de/plenum-$(date -d'tuesday' +%Y%m%d)"
else
echo -e "\nletztes Pad https://fr.pads.ccc.de/plenum-$(date -d'tuesday-7 days' +%Y%m%d)\nnächstes Plenum https://fr.pads.ccc.de/plenum-$(date -d'tuesday+7 days' +%Y%m%d)"
fi
# get the right paddate
#### some legacycode - grown out of errors - working but overcomplex
#if [ $(($(date +%W)%2)) != 1 ];
#then
# paddate=$(date -d'tuesday+7 days' +%Y%m%d);
# # echo "DEBUG ungerade woche"
#else
# # check if in plenum-week tuesday is already gone
# # before i checked for tuesday - which returns today OR next tuesday, indipendent of week
# if [ $(date +%u) -gt 2 ]
# then
# # echo "DEBUG gerade woche / plenum - nach dienstag"
# paddate=$(date -d'tuesday+7 days' +%Y%m%d)
# echo "lastplenum https://fr.pad.ccc.de/plenum-$(date -d 'tuesday-7 days' +%Y%m%d)"
# else
# # echo "DEBUG gerade woche / plenum - vor=dienstag"
# paddate=$(date -d'tuesday' +%Y%m%d)
# fi
#fi
paddate=$(date -d'tuesday+7 days' +%Y%m%d)
# correct paddate if
# - Weeknumber is-not even
# - it is monday or tuesday
# to the NEXT tuesday from today
# in all other cases above statement 7days-next tuesday should fit
[ $(($(date +%W)%2)) != 0 ] && [ $(date +%u) -le 2 ] && paddate=$(date -d'tuesday' +%Y%m%d)
echo "https://fr.pads.ccc.de/plenum-$paddate"
curl -s -L -b "ET=xxxxxxxxxxxxxxxxxxx; ES=xxxxxxxxxxxxx" "https://fr.pads.ccc.de/ep/pad/export/plenum-$paddate/latest?format=txt" > aktuelles_cccfr_pad > aktuelles_cccfr_pad
grep -oq "</html>" aktuelles_cccfr_pad && ( echo "ERROR : there was no pad under https://fr.pads.ccc.de/plenum-$paddate" ; echo "ERROR : last one, see https://fr.pads.ccc.de/plenum-$(date -d'tuesday-7 days' +%Y%m%d)"; exit)
# make some magic to get only essential parts
startquote=$(($(cat aktuelles_cccfr_pad | grep -n ==== |sed -n 2p |cut -d ":" -f1)-1))
[[ ! -z "$startquote" ]] || startquote=1
stopquote=$(($(cat aktuelles_cccfr_pad | grep -n ==== |sed -n 4p |cut -d ":" -f1)+2))
[[ ! -z "$stopquote" ]] || stopquote=2
cat aktuelles_cccfr_pad| head -n $stopquote |tail -n $(($stopquote - $startquote))
#!/bin/bash
# debug
# set -x
# need to have valid cookie infos for plenum pad
# need to have valid sendmail available at running server
folder="/media/freifunk/42-bot/"
target="intern@cccfr.de"
from="psa@openfreiburg.de"
subject="Content-Type: text/plain; charset=UTF-8\nSubject: public service announcement"
intro="refreshing memories..\nkomm doch mal wieder und ¡tuwat! dir Freude bereitet\n\n"
# from
latest_jobs_text="aus https://fr.pads.ccc.de/todo-bau-cccfr einige der jobs die Mensch angehen könnte"
latest_jobs=$(curl -L -c cccfrcookie https://fr.pads.ccc.de/ep/pad/export/todo-bau-cccfr/latest?format=txt |grep " \*")
# Gerade ungerade Woche aufteiler - set $content
if [ $(($(date +%W)%2)) != 0 ];
# you may want to add an exit 0 for not sending at all
then content="der CCCFr könnte mal wieder geputzt werden"
# plenumswoche
else
content="kommenden Dienstag könnte Plenum sein, pads generell unter https://fr.pads.ccc.de/ erstelle doch bei Bedarf selber eines\n\nvermutlich sind diese Links hilfreich\nletztes Pad https://fr.pads.ccc.de/plenum-$(date -d'tuesday-14 days' +%Y%m%d)\nnächstes Plenum https://fr.pads.ccc.de/plenum-$(date -d'tuesday' +%Y%m%d)\n"
# get plenumcontent
# had to get cookies from real account psa@cccfr.de by hand, they shouldnt invalidate
curl -L -v -b "ET=XXXXXXXXXXXXXX; ES=XXXXXXXXXXXXXXX" "https://fr.pads.ccc.de/ep/pad/export/plenum-$(date -d'tuesday' +%Y%m%d)/latest?format=txt" > aktuelles_cccfr_pad
startquote=$(($(cat aktuelles_cccfr_pad | grep -n ==== |sed -n 2p |cut -d ":" -f1)-1))
[[ ! -z "$startquote" ]] || startquote=1
stopquote=$(($(cat aktuelles_cccfr_pad | grep -n ==== |sed -n 4p |cut -d ":" -f1)+2))
[[ ! -z "$stopquote" ]] || stopquote=2
content="$content\n\n$(cat aktuelles_cccfr_pad| head -n $stopquote |tail -n $(($stopquote - $startquote)))"
fi
# out of function - set cal
# müsste per Hand gesetzt werden, ein countdown für diverse events
#cal="kommende nicht reguläre Termine im https://cccfr.de/calendar\n$(${folder}cccfrcal.sh)\n\n$(${folder}36c3.sh)\n\nalle kommenden Termine$(${folder}cccfrcal2.php|sort -n|head -n 25)\n\n"
# todo="$(/usr/bin/curl -s 'https://cccfr.de/git/todo/druckerei/issues.atom?rss_token=UX9Ug1AcpcbQJr4pRXPJ&state=opened' |grep summary|cut -d'>' -f2|cut -d'<' -f1|tr -d '\\\b\f|\r"')"
cal="diverse kommende Termine\n(aus versch. Kalendern)\n"
cal=$cal$(for line in $(ls cccfr-cal-*) ; do ./cccfrcal.php $line ; done)
# todo="\nIdeenpool (gerne auch eigene einsenden)\nnon-public\n\n"
# todo2="\nletzten 20 ToDo aus https://cccfr.de/git/todo/druckerei\ndruckerei is dead\n"
weather="$(/usr/bin/curl -s wttr.in/Freiburg?qn03T |head -n -2)"
echo -e "$subject\n\n\n$intro\
$content\n\n\
$cal\n\n\
$latest_jobs_text\n$latest_jobs\n\n\
$todo\n\n\
zum Schluss das Wetter\n$weather" \
| /usr/sbin/sendmail -t $target -F $from -f $from $target
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment