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
29523c8c
Commit
29523c8c
authored
Oct 09, 2019
by
zakiraihan
Browse files
adding template notif for sisurat
parent
a70bb7aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
app.py
View file @
29523c8c
...
...
@@ -63,6 +63,7 @@ def sendNotifCustom():
@
app
.
route
(
'/sendNotification/sisurat'
,
methods
=
[
'POST'
])
def
sendNotifSisurat
():
from
models.AccountModel
import
AccountModel
from
telebot.sisuratNotif
import
createNotifSisurat
req_data
=
request
.
get_json
()
user
=
AccountModel
.
query
.
filter
(
AccountModel
.
ssoId
==
req_data
[
'username'
]).
first
()
if
(
user
is
None
):
...
...
@@ -70,7 +71,8 @@ def sendNotifSisurat():
elif
(
user
.
chatId
==
None
):
return
{
'status'
:
500
,
'message'
:
'User notification is being turned off'
}
else
:
param
=
urllib
.
parse
.
urlencode
({
'chat_id'
:
user
.
chatId
,
'text'
:
req_data
[
'message'
]})
textNotif
=
createNotifSisurat
(
req_data
)
param
=
urllib
.
parse
.
urlencode
({
'chat_id'
:
user
.
chatId
,
'text'
:
textNotif
})
url
=
"https://api.telegram.org/bot"
+
TOKEN
+
"/sendMessage?"
+
param
r
=
requests
.
get
(
url
=
url
)
return
r
.
json
()
...
...
telebot/sisuratNotif.py
View file @
29523c8c
def
createNotifSisurat
(
data
):
if
(
data
[
'type'
]
==
0
):
return
'surat diproses'
elif
(
data
[
'type'
]
==
1
):
return
'surat ditolak'
elif
(
data
[
'type'
]
==
2
):
return
'surat menunggu persetujuan dosen'
elif
(
data
[
'type'
]
==
3
):
return
'surat di proses'
elif
(
data
[
'type'
]
==
4
):
return
'surat telah selesai dibuat'
\ No newline at end of file
telebot/sisuratStatusEnum.py
0 → 100644
View file @
29523c8c
sisuratEnum
=
{
0
:
"Diajukan"
,
1
:
"Ditolak"
,
2
:
"PersetujuanDosen"
,
3
:
"Proses"
,
4
:
"Selesai"
}
\ No newline at end of file
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