Beispiel #1
0
    except Exception as e:
        return str(e)


@bot.command(r'light brightness (?P<brightness>\d+)')
@bot.restrict_user('light')
def light_brightness(update, brightness=0):
    try:
        resp = requests.post('{}/light'.format(YEELIGHT_BASE_URL),
                             {'brightness': brightness})
        return resp.text
    except Exception as e:
        return str(e)


@bot.command(r'light warm (?P<warm>\d+)')
@bot.restrict_user('light')
def light_warm(update, warm=0):
    try:
        warm = float(warm) / 100
        resp = requests.post('{}/light'.format(YEELIGHT_BASE_URL),
                             {'warm': warm})
        return resp.text
    except Exception as e:
        return str(e)


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    bot.loop()