sudah bisa kirim notes untuk mentions, reblog, like

This commit is contained in:
Kusaeni 2024-09-29 21:07:51 +07:00
parent 154ceb7faa
commit a5b5ed580c

26
main.py
View file

@ -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"""
<b>{notif.display_name}</b>\n<i>{notif.handler}</i>\n{flag}\n\n{status_text}\n\n{notif.url}
"""
)