2 Commits 52d744fb1d ... fae63704a4

Author SHA1 Message Date
  foreverpositive fae63704a4 Added user verification 2 years ago
  foreverpositive fd9e2ce9b8 Changed README 2 years ago
3 changed files with 24 additions and 0 deletions
  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
 # 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.
 Telegram bot that helps faculty members of New Phystech work with faculty's public printers.
 
 
 This bot can:
 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