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
768cdfc6
Commit
768cdfc6
authored
Oct 04, 2019
by
zakiraihan
Browse files
Add activate notification function
parent
815632e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
models/AccountModel.py
View file @
768cdfc6
...
...
@@ -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
()
...
...
telebot/mastermind.py
View file @
768cdfc6
...
...
@@ -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
):
check
User
Existance
=
User
Model
.
query
.
filter
(
User
Model
.
user
Id
==
str
(
chat_id
)).
first
()
if
(
check
User
Existance
is
None
):
check
Account
Existance
=
Account
Model
.
query
.
filter
(
Account
Model
.
chat
Id
==
str
(
chat_id
)).
first
()
if
(
check
Account
Existance
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')
...
...
Write
Preview
Markdown
is supported
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