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 logging
import asyncio import asyncio
import telegram import telegram
from json import dumps import re
from models import Notifikasi, Session from models import Notifikasi, Session
from sqlalchemy import and_, or_, func from sqlalchemy import and_, or_, func
from sqlalchemy.exc import IntegrityError from sqlalchemy.exc import IntegrityError
@ -80,11 +80,27 @@ async def kirim_ke_tele():
except: except:
print('Ada masalah saat kirim ke Telebot') print('Ada masalah saat kirim ke Telebot')
else: else:
try: html_strip = re.compile('<.*?>')
await bot.send_message(chat_id=str(TELE_CHATID), text=f""" status = str(notif.status)
{notif.display_name}\n{notif.handler} 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}
""" """
) )