notification manager
This commit is contained in:
20
daemons/management/commands/notification_manager.py
Normal file
20
daemons/management/commands/notification_manager.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from SprintLib.queue import MessagingSupport
|
||||
from daemons.management.commands.bot import bot
|
||||
|
||||
|
||||
class Command(MessagingSupport):
|
||||
help = "starts file notification manager"
|
||||
queue_name = "notifications"
|
||||
|
||||
def process(self, payload: dict):
|
||||
user = User.objects.get(id=payload['user_id'])
|
||||
notification_type = payload['type']
|
||||
text = payload['text']
|
||||
if notification_type == "any" or getattr(user.userinfo, "notification_" + notification_type):
|
||||
bot.send_message(
|
||||
user.userinfo.telegram_chat_id,
|
||||
text,
|
||||
parse_mode="html",
|
||||
)
|
Reference in New Issue
Block a user