Fakultas Ilmu Komputer UI

Commit 67893ab1 authored by zakiraihan's avatar zakiraihan
Browse files

Add logout function from user

parent cf745d3a
......@@ -15,6 +15,8 @@ def botNavigation(bot, update):
user_login(bot, chat_id)
elif (text == None and contact != None) :
save_user_data(bot, chat_id, contact)
elif (text == "/logout"):
user_logout(bot, chat_id)
else :
command_not_found(bot, chat_id, msg_id)
\ No newline at end of file
......@@ -33,4 +33,13 @@ def save_user_data(bot, chat_id, contact):
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())
\ No newline at end of file
bot.sendMessage(chat_id=chat_id, text="You have been registered", reply_markup=ReplyKeyboardRemove())
def user_logout(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())
\ No newline at end of file
Supports Markdown
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