Esempio n. 1
0
def command_add(update):
    message = update.message.text

    if not message:
        raise InvalidCommand('Usage: /add product-number')

    product_number = message[4:].strip()
    try:
        weblaunch = create_beerbot(update.message.chat_id).get_weblaunch_by_product(product_number)
    except LoginException:
        return {'text': 'Could not log in.'}

    if not weblaunch:
        return {'text': 'Could not find any web launch for that product.'}

    model.add_weblaunch_booking(update.message.chat_id, weblaunch.weblaunch_id)
    return {'text': 'Will book "{}"\n{}'.format(weblaunch.product_name, weblaunch.url)}
Esempio n. 2
0
def command_when(update):
    try:
        start = create_beerbot(update.message.chat_id).get_weblaunch_start()
    except LoginException:
        return {'text': 'Could not log in.'}

    if not start:
        return {'text': 'There are no planned events right now.'}

    if start >= datetime.datetime.now():
        days = (start - datetime.datetime.now()).days
        text = 'Next event opens at {} ({} days).'.format(start, days)
    else:
        text = 'There is an open event right now (started at {}).'.format(start)

    return {'disable_web_page_preview': True, 'text': """
{}

https://www.systembolaget.se/fakta-och-nyheter/nyheter-i-sortimentet/webblanseringar/webblansering/
""".format(text)}