lichess-notify/notify.py
Loic Guegan e9f1e4e724 Debug
2020-04-24 17:24:57 +02:00

24 lines
653 B
Python
Executable file

#!/usr/bin/env python
import berserk, subprocess
# Change ACCESS TOKEN according to your need
ACCESS_TOKEN="EiZbLRtZzWnTL4xh"
# Notify using notify-send
def notify_send(summary, message):
subprocess.Popen(['notify-send', '-u', 'critical','-t', '99999999', summary, message])
return
# Fetch data and notify
session = berserk.TokenSession(ACCESS_TOKEN)
client = berserk.Client(session=session)
data=client.games.get_ongoing()
for game in data:
opponent=game["opponent"]["username"]
lastMove=game["lastMove"]
if game["isMyTurn"]:
notify_send("Lichess ("+opponent+")","It is your turn !\n Your oppenent played "+lastMove)