26 lines
647 B
Python
26 lines
647 B
Python
import os
|
|
|
|
import requests
|
|
|
|
|
|
class LineNotifier:
|
|
def __init__(self) -> None:
|
|
self.url = 'https://api.line.me/v2/bot/message/push'
|
|
self.headers = {
|
|
'Authorization': 'Bearer ' + os.environ['LINE_TOKEN'],
|
|
'Content-Type': 'application/json',
|
|
}
|
|
self.group_id = os.environ['LINE_GROUP_ID']
|
|
|
|
def notify(self, msg: str):
|
|
data = {
|
|
"to": self.group_id,
|
|
'messages': [
|
|
{
|
|
'type': 'text',
|
|
'text': msg,
|
|
}
|
|
]
|
|
}
|
|
requests.post(self.url, headers=self.headers, json=data)
|