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 @@
use Sabre\VObject;
#$file = $argv[1]
include 'vendor/autoload.php';
$vcalendar = VObject\Reader::read(
# fopen('/media/freifunk/42-bot/calendar.ics','r')
echo "\n";
foreach ( $vcalendar->VEVENT as $event) {
if (substr($event->DTSTART,0,8) > (date("Ymd")-2)) {
echo date_format($something,"d.m.Y H");
echo "h " ;
echo $event->SUMMARY;
echo "\n";
echo date_format($something,"Y.m.d");
# echo $formatedsomething->format('Ymd');
echo " - ";
echo $event->SUMMARY;
echo "\n";
echo "\n";
# get as much calendars as needed and clean timezone stuff for sabredav read
# nextcloud - grether
curl > cccfr-cal-grether
# official cccfr-cal-www
curl -k > cccfr-cal-www
# nextcloud - related
curl -k > cccfr-cal-related
# "repair" / adjust the ics files for sabredav
for line in $(ls cccfr-cal-*)
# change all DTSTART so TZ is removed
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)
sed -E -i ${linenr}s/T[0-9]{6}// $line
# 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
if [ $(($(date +%W)%2)) != 0 ];
echo -e "\nletztes Pad$(date -d'tuesday-14 days' +%Y%m%d)\nnächstes Plenum$(date -d'tuesday' +%Y%m%d)"
echo -e "\nletztes Pad$(date -d'tuesday-7 days' +%Y%m%d)\nnächstes Plenum$(date -d'tuesday+7 days' +%Y%m%d)"
# get the right paddate
#### some legacycode - grown out of errors - working but overcomplex
#if [ $(($(date +%W)%2)) != 1 ];
# paddate=$(date -d'tuesday+7 days' +%Y%m%d);
# # echo "DEBUG ungerade woche"
# # 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$(date -d 'tuesday-7 days' +%Y%m%d)"
# else
# # echo "DEBUG gerade woche / plenum - vor=dienstag"
# paddate=$(date -d'tuesday' +%Y%m%d)
# 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 "$paddate"
curl -s -L -b "ET=xxxxxxxxxxxxxxxxxxx; ES=xxxxxxxxxxxxx" "$paddate/latest?format=txt" > aktuelles_cccfr_pad > aktuelles_cccfr_pad
grep -oq "</html>" aktuelles_cccfr_pad && ( echo "ERROR : there was no pad under$paddate" ; echo "ERROR : last one, see$(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))
# debug
# set -x
# need to have valid cookie infos for plenum pad
# need to have valid sendmail available at running server
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 einige der jobs die Mensch angehen könnte"
latest_jobs=$(curl -L -c cccfrcookie |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
content="kommenden Dienstag könnte Plenum sein, pads generell unter erstelle doch bei Bedarf selber eines\n\nvermutlich sind diese Links hilfreich\nletztes Pad$(date -d'tuesday-14 days' +%Y%m%d)\nnächstes Plenum$(date -d'tuesday' +%Y%m%d)\n"
# get plenumcontent
# had to get cookies from real account by hand, they shouldnt invalidate
curl -L -v -b "ET=XXXXXXXXXXXXXX; ES=XXXXXXXXXXXXXXX" "$(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)))"
# out of function - set cal
# müsste per Hand gesetzt werden, ein countdown für diverse events
#cal="kommende nicht reguläre Termine im\n$(${folder}\n\n$(${folder}\n\nalle kommenden Termine$(${folder}cccfrcal2.php|sort -n|head -n 25)\n\n"
# todo="$(/usr/bin/curl -s '' |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\ndruckerei is dead\n"
weather="$(/usr/bin/curl -s |head -n -2)"
echo -e "$subject\n\n\n$intro\
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