2 Revīzijas 52d744fb1d ... fae63704a4

Autors SHA1 Ziņojums Datums
  foreverpositive fae63704a4 Added user verification 2 gadi atpakaļ
  foreverpositive fd9e2ce9b8 Changed README 2 gadi atpakaļ
3 mainītis faili ar 24 papildinājumiem un 0 dzēšanām
  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