EduForge Verify Bot: SheerID verification TG bot (aiogram, credits, Stars payment, referral, channel bonus, admin)
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""In-process wrapper around the EduForge combine engine (no HTTP server dependency)."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
EF_DIR = os.environ.get("EF_DIR", r"C:/Users/User/tmp/eduforge")
|
||||
if EF_DIR not in sys.path:
|
||||
sys.path.insert(0, EF_DIR)
|
||||
|
||||
from server import config, gendocs # noqa: E402
|
||||
from server.engine.client import SheerIDClient, parse_verification_id # noqa: E402
|
||||
|
||||
PROGRAMS = config.PROGRAMS
|
||||
SCHOOLS = config.SCHOOLS
|
||||
DOC_TYPES = gendocs.DOC_TYPES
|
||||
DEFAULT_SCHOOL = config.DEFAULT_SCHOOL_ID
|
||||
|
||||
|
||||
def verify_sync(vid, program_key="student", doc_type="student_id",
|
||||
school_id=DEFAULT_SCHOOL, first=None, last=None):
|
||||
program = config.PROGRAMS[program_key]
|
||||
school = config.SCHOOLS.get(school_id, config.SCHOOLS[config.DEFAULT_SCHOOL_ID])
|
||||
ident = gendocs.make_identity(first, last, None, None,
|
||||
school.get("domain", "psu.edu").lower())
|
||||
payload, filename, mime = gendocs.generate_doc(
|
||||
doc_type, ident["first_name"], ident["last_name"],
|
||||
school["name"], ident["birth_date"], school_id)
|
||||
client = SheerIDClient()
|
||||
result = client.run(vid, program, ident, school, payload, filename, mime, True)
|
||||
return {
|
||||
"result": result,
|
||||
"identity": {k: ident[k] for k in ("first_name", "last_name", "email", "birth_date")},
|
||||
"doc_bytes": len(payload),
|
||||
}
|
||||
|
||||
|
||||
def status_sync(vid):
|
||||
return SheerIDClient().status(vid)
|
||||
|
||||
|
||||
def generate_sync(doc_type="student_id", school_id=DEFAULT_SCHOOL, first=None, last=None):
|
||||
school = config.SCHOOLS.get(school_id, config.SCHOOLS[config.DEFAULT_SCHOOL_ID])
|
||||
ident = gendocs.make_identity(first, last)
|
||||
payload, filename, mime = gendocs.generate_doc(
|
||||
doc_type, ident["first_name"], ident["last_name"],
|
||||
school["name"], ident["birth_date"], school_id)
|
||||
return payload, filename, mime, ident
|
||||
Reference in New Issue
Block a user