aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2020-04-24 17:20:43 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2020-04-24 17:20:43 +0200
commitbf9c2444942e861c1b5cae24573acb71ac7a4cae (patch)
treefb15559106d2e09704a9a31d83da18f136d0a7ee
Init repo
-rw-r--r--README.md11
-rwxr-xr-xnotify.py24
2 files changed, 35 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..488d217
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+# Lichess Game Notification
+
+### How to use it ?
+
+ 1. Install [Berserk](https://github.com/rhgrant10/berserk) with `pip install berserk`
+ 2. Generate an access token on [Lichess.org](https://lichess.org)
+ 3. Set the value of **ACCESS_TOKEN** variable in *notify.py* to the one use in step 2
+ 4. Now each time you want to check for notification simply run **./notify.py** (use crontab maybe)
+### Dependencies
+- `notify-send` This command should be available!
+- `berserk` The lichess python API
diff --git a/notify.py b/notify.py
new file mode 100755
index 0000000..8a57df5
--- /dev/null
+++ b/notify.py
@@ -0,0 +1,24 @@
+#!/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 not(game["isMyTurn"]):
+ notify_send("Lichess ("+opponent+")","It is your turn !\n Your oppenent played "+lastMove)
+