Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ZAKI RAIHAN
1606878505_ossd_telegram_notif_bot
Commits
67893ab1
Commit
67893ab1
authored
Sep 26, 2019
by
zakiraihan
Browse files
Add logout function from user
parent
cf745d3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
navigation/navigation.py
View file @
67893ab1
...
...
@@ -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
telebot/mastermind.py
View file @
67893ab1
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment