Пример #1
0
def events(message, eventtype='extern'):
    events = get_from_api(EVENT_URL, encoding='utf-8', cache=True,
                          cache_experation=600)
    if eventtype == 'intern':
        message.reply(decode_event(events['intern']))
    else:
        message.reply(decode_event(events['public']))
Пример #2
0
def get_departures(stop_id,
                   datetime=None,
                   transporttypes=None,
                   linenames=None):
    params = dict()
    if transporttypes is not None:
        params['transporttypes'] = transporttypes
    return get_from_api(base_url + 'StopVisit/GetDepartures/' + str(stop_id),
                        params=params)
Пример #3
0
def vouchers(message, username=None):
    printed = False
    if username is None:
        if 'user' in message.body:
            user = get_user_from_message(message)
            username = user['name']
    wallets = get_from_api(base_url + 'voucher/wallets?user='******'utf8')
    for wallet in wallets:
        if semester_is_valid(wallet['semester']):
            printed = True
            message.reply(wallet_to_string(wallet))
    if printed is False:
        message.reply('I can\'t find a valid wallet for %s' % username)
Пример #4
0
def get_stations(name):
    return get_from_api(base_url + 'Place/GetPlaces/' + name)