diff --git a/main.py b/main.py index b5cf9eb..3f15417 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,7 @@ import os import logging import asyncio import telegram -from json import dumps +import re from models import Notifikasi, Session from sqlalchemy import and_, or_, func from sqlalchemy.exc import IntegrityError @@ -80,11 +80,27 @@ async def kirim_ke_tele(): except: print('Ada masalah saat kirim ke Telebot') else: - try: - await bot.send_message(chat_id=str(TELE_CHATID), text=f""" - {notif.display_name}\n{notif.handler} + html_strip = re.compile('<.*?>') + status = str(notif.status) + status_text = re.sub(html_strip,'', status) - {notif.status} + def icon_(type_): + if type_ == 'mention': + return '💬 mention your note' + elif type_ == 'reblog': + return '🚀 boost your note' + elif type_ == 'favourite': + return '💖 falling in love with your note' + elif type_ == 'follow': + return '✋ started to follow you' + else: + return None + + flag = icon_(notif.type) + + try: + await bot.send_message(parse_mode='html',chat_id=str(TELE_CHATID), text=f""" + {notif.display_name}\n{notif.handler}\n{flag}\n\n{status_text}\n\n{notif.url} """ )