-
Notifications
You must be signed in to change notification settings - Fork 1
/
CalUpdate.pl
executable file
·65 lines (39 loc) · 1.72 KB
/
CalUpdate.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl
#1353303800 #hive76bots KyleYankan Bed
#EPOCHDATE CHANNEL NICK MESSAGE
use JSON;
use LWP::Simple;
use DateTime::Format::ISO8601;
$now = DateTime->now;
$timemin = $now->iso8601;
print "$timemin\n";
$then = $now;
$then->add( years => 1 );
$timemax = $then->iso8601;
print "$timemax\n";
$calURL = 'https://www.googleapis.com/calendar/v3/calendars/hive76.org_b6up588cfkui85d83v5oekhvco%40group.calendar.google.com/events?singleEvents=true&key=AIzaSyCkr1uIFuY4Ovh4Bj6qoO-BhUnq6VKnlqk&timeMin=' . $timemin . '-05:00&timeMax=' . $timemax . '-05:00';
print $calURL . "\n";
$reqJSON = get($calURL);
die "Couldn't get the Calendar Feed: $!" unless defined $reqJSON;
$calendar = {};
$events = 0;
$calendar = decode_json $reqJSON;
$events = scalar( $calendar->{"items"} );
@calendar = $calendar->{"items"};
print $calendar->{"updated"} . "\n";
print "localtime: " . $now->epoch() . "\n";
open(FILE, ">/home/irssi/.phenny/QueenBee-irc.freenode.org.events.db") or die "Can't open file: $!\n";
for my $event ( @{$calendar->{"items"}} ) {
if ($event->{"start"}->{"dateTime"} =~ /T/) {
my $start = DateTime::Format::ISO8601->parse_datetime( $event->{"start"}->{"dateTime"});
my $end = DateTime::Format::ISO8601->parse_datetime( $event->{"end"}->{"dateTime"});
#$timeDiff = $end->delta_ms($start);
#print $event->{"summary"} . " @ " . $start->datetime() . " to " . $end->datetime() . "\n";
#print "\t " . $event->{"description"} . " at " . $event->{"location"}. "\n";
#print "\n";
#print $start->epoch() . " < " . $now->epoch() . " == ". localtime() . "\n";
#Put into reminders file
print FILE $start->epoch() . "\t#hive76bots\tEveryone\t " . $event->{"summary"} . "\n";
}
}
close(FILE);