neingeist
/
neinomaten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

36 lines
999 B
Ruby

#!/usr/bin/env ruby
$:.unshift('vendor/ruby-mediawiki/lib')
require 'mediawiki/dotfile'
require 'http-access2'
require 'vpim/icalendar'
include Vpim
$ical_url = "http://www.google.com/calendar/ical/nsb7jkat2efmkfs85qcbvouk8g@group.calendar.google.com/public/basic.ics"
$st = - 3*24*3600
$en = +180*24*3600
def get_events()
@client = HTTPAccess2::Client.new()
ical = @client.get_content($ical_url)
events = []
Icalendar.decode(ical).each do |publish|
publish.events.each do |event|
if event.dtstart >= (Time.now+$st) and event.dtstart <= (Time.now+$en)
events.push(event)
end
end
end
return events
end
@wiki = MediaWiki.dotfile(nil,'stadtwiki')
body = "Folgende Termine stammen von #{$ical_url}:\n\n"
get_events().sort {|x,y| x.dtstart <=> y.dtstart }.each do |event|
body += "* #{event.dtstart.mday}.#{event.dtstart.month}. #{event.summary}\n"
end
a = @wiki.article("Benutzer:Neingeist/Termine_aus_Google_Calendar")
a.text = body
a.submit("Import")