diff options
Diffstat (limited to 'app/tasks/forumtasks.py')
-rw-r--r-- | app/tasks/forumtasks.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/tasks/forumtasks.py b/app/tasks/forumtasks.py new file mode 100644 index 0000000..e4ddc59 --- /dev/null +++ b/app/tasks/forumtasks.py @@ -0,0 +1,33 @@ +import flask +from flask.ext.sqlalchemy import SQLAlchemy +from app import app +from app.models import * +from app.tasks import celery +from .phpbbparser import getProfile + +@celery.task() +def checkForumAccount(username, token=None): + try: + profile = getProfile("https://forum.minetest.net", username) + except OSError: + return + + user = User.query.filter_by(forums_username=username).first() + + # Create user + needsSaving = False + if user is None: + user = User(username) + user.forums_username = username + db.session.add(user) + + # Get github username + github_username = profile.get("github") + if github_username is not None and github_username.strip() != "": + print("Updated github username") + user.github_username = github_username + needsSaving = True + + # Save + if needsSaving: + db.session.commit() |