2 Commits 52d744fb1d ... fae63704a4

Auteur SHA1 Message Date
  foreverpositive fae63704a4 Added user verification il y a 2 ans
  foreverpositive fd9e2ce9b8 Changed README il y a 2 ans
3 fichiers modifiés avec 24 ajouts et 0 suppressions
  1. 4 0
      README.md
  2. 20 0
      printers/members.py
  3. BIN
      src/pic.png

+ 4 - 0
README.md

@@ -1,5 +1,9 @@
 # New Phystech Printers Telegram Bot
 
+<img src="src/pic.png"
+     alt="Picture"
+     style="vertical-align: middle; width: 50%; height: 50%"/>
+
 Telegram bot that helps faculty members of New Phystech work with faculty's public printers.
 
 This bot can:

+ 20 - 0
printers/members.py

@@ -0,0 +1,20 @@
+import json
+import requests
+
+
+with open('printers/access-token', 'r', encoding='utf-8') as token_file:
+    TOKEN = token_file.read()
+
+
+def is_member(telegram_id):
+    url = 'https://physics.itmo.ru/ru/rest/export/json/users-telegram-id-roles'
+    params = {'_format': 'json', 'telegram_id_value': telegram_id}
+    headers = {'Authorization': f'Bearer {TOKEN}'}
+
+    response = requests.get(url, params=params, headers=headers)
+    resp = json.loads(response.text)
+
+    if resp != [] and resp[0]['roles_target_id'] == 'member':
+        return True
+
+    return False

BIN
src/pic.png