mirror of
https://github.com/GaMeNu/HFCNotificator.git
synced 2024-11-16 15:24:51 +02:00
moved class Alert from cog_notificator.py to alert_notifiy.py
This commit is contained in:
parent
72fba9c20b
commit
110ab70349
43
alert_notifiy.py
Normal file
43
alert_notifiy.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
class Alert:
|
||||||
|
"""
|
||||||
|
Represents an HFC Alert
|
||||||
|
"""
|
||||||
|
def __init__(self, id: int, cat: int, title: str, districts: list[str], desc: str):
|
||||||
|
"""
|
||||||
|
Init an Alert instance
|
||||||
|
:param id: Alert ID
|
||||||
|
:param cat: Alert category
|
||||||
|
:param title: Alert title
|
||||||
|
:param districts: districts the alert is running for
|
||||||
|
:param desc: Alert description/extra info
|
||||||
|
"""
|
||||||
|
self.id = id
|
||||||
|
self.category = cat
|
||||||
|
self.title = title
|
||||||
|
self.districts = districts
|
||||||
|
self.description = desc
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, data: dict):
|
||||||
|
"""
|
||||||
|
Return a new Alert instance from an Alert-formatted dict (matching HFC alert requests)
|
||||||
|
|
||||||
|
Dict format:
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": int,
|
||||||
|
"cat": int,
|
||||||
|
"title": str,
|
||||||
|
"data": list[str],
|
||||||
|
"desc": str
|
||||||
|
}
|
||||||
|
|
||||||
|
:param data: A dict of matching format
|
||||||
|
|
||||||
|
:return: The new Alert instance
|
||||||
|
"""
|
||||||
|
return cls(int(data.get('id', '0')),
|
||||||
|
int(data.get('cat', '0')),
|
||||||
|
data.get('title'),
|
||||||
|
data.get('data'),
|
||||||
|
data.get('desc'))
|
@ -13,6 +13,7 @@ import db_access
|
|||||||
import errlogging
|
import errlogging
|
||||||
from db_access import *
|
from db_access import *
|
||||||
from markdown import md
|
from markdown import md
|
||||||
|
from alert_notifiy import Alert
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
AUTHOR_ID = int(os.getenv('AUTHOR_ID'))
|
AUTHOR_ID = int(os.getenv('AUTHOR_ID'))
|
||||||
@ -72,49 +73,6 @@ class AlertReqs:
|
|||||||
return ret_dict
|
return ret_dict
|
||||||
|
|
||||||
|
|
||||||
class Alert:
|
|
||||||
"""
|
|
||||||
Represents an HFC Alert
|
|
||||||
"""
|
|
||||||
def __init__(self, id: int, cat: int, title: str, districts: list[str], desc: str):
|
|
||||||
"""
|
|
||||||
Init an Alert instance
|
|
||||||
:param id: Alert ID
|
|
||||||
:param cat: Alert category
|
|
||||||
:param title: Alert title
|
|
||||||
:param districts: districts the alert is running for
|
|
||||||
:param desc: Alert description/extra info
|
|
||||||
"""
|
|
||||||
self.id = id
|
|
||||||
self.category = cat
|
|
||||||
self.title = title
|
|
||||||
self.districts = districts
|
|
||||||
self.description = desc
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def from_dict(cls, data: dict):
|
|
||||||
"""
|
|
||||||
Return a new Alert instance from an Alert-formatted dict (matching HFC alert requests)
|
|
||||||
|
|
||||||
Dict format:
|
|
||||||
|
|
||||||
{
|
|
||||||
"id": int,
|
|
||||||
"cat": int,
|
|
||||||
"title": str,
|
|
||||||
"data": list[str],
|
|
||||||
"desc": str
|
|
||||||
}
|
|
||||||
|
|
||||||
:param data: A dict of matching format
|
|
||||||
|
|
||||||
:return: The new Alert instance
|
|
||||||
"""
|
|
||||||
return cls(int(data.get('id', '0')),
|
|
||||||
int(data.get('cat', '0')),
|
|
||||||
data.get('title'),
|
|
||||||
data.get('data'),
|
|
||||||
data.get('desc'))
|
|
||||||
|
|
||||||
|
|
||||||
class AlertEmbed:
|
class AlertEmbed:
|
||||||
|
Loading…
Reference in New Issue
Block a user