Script for creating reminder tweet texts from ical
This commit is contained in:
parent
4dbc6d46b9
commit
e8bb2259ec
2 changed files with 30 additions and 1 deletions
|
|
@ -30,4 +30,4 @@ cal = RiCal.Calendar do |cal|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
%><%= cal.to_s %>
|
%><%= cal.to_s.strip %>
|
||||||
|
|
|
||||||
29
scripts/tweet-reminders.rb
Executable file
29
scripts/tweet-reminders.rb
Executable file
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
require 'date'
|
||||||
|
require 'ri_cal'
|
||||||
|
|
||||||
|
|
||||||
|
days=ARGV[0].to_i
|
||||||
|
infotext=ARGV[1]
|
||||||
|
|
||||||
|
outputlen=140
|
||||||
|
urllen=24
|
||||||
|
|
||||||
|
RiCal.parse($stdin).each do |calendar|
|
||||||
|
calendar.events.each do |event|
|
||||||
|
start = event.dtstart.to_date
|
||||||
|
if (start-Date.today())==days
|
||||||
|
output = "#{infotext} #{event.summary}".byteslice(0,outputlen)
|
||||||
|
if event.url and event.url.length>0
|
||||||
|
if output.length + urllen + 1 > outputlen
|
||||||
|
output = "#{output.byteslice(0,outputlen - urllen - 1)} #{event.url}"
|
||||||
|
else
|
||||||
|
output = "#{output} #{event.url}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
puts output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue