2 次代碼提交 52d744fb1d ... fae63704a4

作者 SHA1 備註 提交日期
  foreverpositive fae63704a4 Added user verification 2 年之前
  foreverpositive fd9e2ce9b8 Changed README 2 年之前
共有 3 個文件被更改,包括 24 次插入0 次删除
  1. 4 0
      README.md
  2. 20 0
      printers/members.py
  3. 二進制
      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

二進制
src/pic.png