Fakultas Ilmu Komputer UI

Commit 29523c8c authored by zakiraihan's avatar zakiraihan
Browse files

adding template notif for sisurat

parent a70bb7aa
......@@ -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()
......
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
sisuratEnum = {
0:"Diajukan",
1:"Ditolak",
2:"PersetujuanDosen",
3:"Proses",
4:"Selesai"
}
\ No newline at end of file
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