Closed ralphbean closed 10 years ago
Let's wait for fedocal 0.2.0 has the API is rewritten in it
So that API is in now. We can access the data we need with a query like this one:
$ http --json get https://apps.fedoraproject.org/calendar/api/meetings location==\#fedora-meeting
For the record, I have tried to harmonize the locations to use fedora-meeting@irc.freenode.net
looks like I need to do a new pass, otherwise the #
gives problems with urls :)
Messing around with the api:
#!/usr/bin/env python
import arrow
import datetime
import requests
def future_meetings(channel):
response = requests.get(
'https://apps.fedoraproject.org/calendar/api/meetings',
params=dict(
location='%s@irc.freenode.net' % channel,
)
)
data = response.json()
now = datetime.datetime.utcnow()
for meeting in data['meetings']:
string = meeting['meeting_date'] + " " + meeting['meeting_time_start']
dt = datetime.datetime.strptime(string, "%Y-%m-%d %H:%M:%S")
if now < dt:
yield dt, meeting
def print_next_meetings(channel, n=3):
meetings = list(future_meetings(channel))[:n]
for date, meeting in meetings:
print "The next meeting in #%s is %s starting %s" % (
channel,
meeting['meeting_name'],
arrow.get(date).humanize(),
)
if __name__ == '__main__':
print_next_meetings('fedora-meeting')
add a .nextmeeting command that queries fedocal and tries to figure out how long until the next scheduled meeting (and what its about and what channel its in).
This would be super useful for bot maintenance to know when we can take the bot down for maintenance and stuff.