aboutsummaryrefslogtreecommitdiff
path: root/notify.py
blob: 87759056c974daafb8036c56196e3a69eb78aa0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python

import berserk, subprocess

# Change ACCESS TOKEN according to your need
ACCESS_TOKEN=""
NOTIFY_DURATION=5*60 # Notification duration in seconds

# Notify using notify-send
def notify_send(summary, message):
    subprocess.Popen(['notify-send', '-u', 'critical','-t', str(NOTIFY_DURATION*1000), 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.org ("+opponent+")","It is your turn !\n Your opponent played "+lastMove)