Fakultas Ilmu Komputer UI

Commit 768cdfc6 authored by zakiraihan's avatar zakiraihan
Browse files

Add activate notification function

parent 815632e9
......@@ -20,6 +20,9 @@ class AccountModel(db.Model):
db.session.add(self)
db.session.commit()
def update(self):
db.session.commit()
def delete(self):
db.session.delete(self)
db.session.commit()
......
......@@ -16,8 +16,8 @@ def command_not_found(bot, chat_id, msg_id):
bot.sendMessage(chat_id=chat_id, text=response, reply_to_message_id=msg_id)
def user_activate_notif(bot, chat_id):
checkUserExistance = UserModel.query.filter(UserModel.userId==str(chat_id)).first()
if (checkUserExistance is None):
checkAccountExistance = AccountModel.query.filter(AccountModel.chatId==str(chat_id)).first()
if (checkAccountExistance is None):
con_keyboard = KeyboardButton(text="Send_contact", request_contact=True)
custom_keyboard = [[ con_keyboard ], [ ]]
reply_markup = ReplyKeyboardMarkup(custom_keyboard, one_time_keyboard=True )
......@@ -29,13 +29,13 @@ def user_activate_notif(bot, chat_id):
bot.sendMessage(chat_id=chat_id, text="You have been registered", reply_markup=ReplyKeyboardRemove())
def save_user_notif_activation_data(bot, chat_id, contact):
checkUserExistance = UserModel.query.filter(UserModel.userId==str(contact.user_id), UserModel.phoneNumber==str(contact.phone_number)).first()
if (checkUserExistance is None):
user = UserModel(str(contact.user_id), str(contact.phone_number), contact.first_name, contact.last_name)
user.save()
bot.sendMessage(chat_id=chat_id, text="Register success!!!", reply_markup=ReplyKeyboardRemove())
checkAccountExistance = AccountModel.query.filter(AccountModel.phoneNumber==str(contact.phone_number)).first()
if (checkAccountExistance is None):
bot.sendMessage(chat_id=chat_id, text="You are not logged in yet", reply_markup=ReplyKeyboardRemove())
else:
bot.sendMessage(chat_id=chat_id, text="You have been registered", reply_markup=ReplyKeyboardRemove())
checkAccountExistance.chatId = chat_id
checkAccountExistance.update()
bot.sendMessage(chat_id=chat_id, text="Register success!!!", reply_markup=ReplyKeyboardRemove())
def user_deactive_notif(bot, chat_id):
checkUserExistance = UserModel.query.filter(UserModel.userId==str(chat_id)).first()
......@@ -58,7 +58,38 @@ def user_logout_sso(bot, chat_id):
URL = sso_url + "/logout?url=" + app_auth_url
response = "Please logout through this link:\n" + URL
bot.sendMessage(chat_id=chat_id, text=response)
# def user_activate_notif(bot, chat_id):
# checkUserExistance = UserModel.query.filter(UserModel.userId==str(chat_id)).first()
# if (checkUserExistance is None):
# con_keyboard = KeyboardButton(text="Send_contact", request_contact=True)
# custom_keyboard = [[ con_keyboard ], [ ]]
# reply_markup = ReplyKeyboardMarkup(custom_keyboard, one_time_keyboard=True )
# bot.sendMessage(chat_id=chat_id,
# text="Would you mind sharing your contact with me?",
# reply_markup=reply_markup)
# else:
# bot.sendMessage(chat_id=chat_id, text="You have been registered", reply_markup=ReplyKeyboardRemove())
# def save_user_notif_activation_data(bot, chat_id, contact):
# checkUserExistance = UserModel.query.filter(UserModel.userId==str(contact.user_id), UserModel.phoneNumber==str(contact.phone_number)).first()
# if (checkUserExistance is None):
# user = UserModel(str(contact.user_id), str(contact.phone_number), contact.first_name, contact.last_name)
# user.save()
# bot.sendMessage(chat_id=chat_id, text="Register success!!!", reply_markup=ReplyKeyboardRemove())
# else:
# bot.sendMessage(chat_id=chat_id, text="You have been registered", reply_markup=ReplyKeyboardRemove())
# def user_deactive_notif(bot, chat_id):
# checkUserExistance = UserModel.query.filter(UserModel.userId==str(chat_id)).first()
# if (checkUserExistance is None):
# bot.sendMessage(chat_id=chat_id, text="You are not registerd yet", reply_markup=ReplyKeyboardRemove())
# else:
# checkUserExistance = UserModel.query.filter(UserModel.userId==str(chat_id)).first()
# checkUserExistance.delete()
# bot.sendMessage(chat_id=chat_id, text="Successfully logged out from bot", reply_markup=ReplyKeyboardRemove())
# def user_login_sso(bot, chat_id):
# base_url = os.environ.get('URL')
# sso_url = os.environ.get('SSO_UI_URL')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment