-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify.py
35 lines (25 loc) · 983 Bytes
/
notify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
from dotenv import load_dotenv
from linebot.v3 import messaging # type: ignore
load_dotenv(override=True)
def main():
access_token = os.getenv("LINE_CHANNEL_ACCESS_TOKEN")
configuration = messaging.Configuration(access_token=access_token)
with open("num.txt", "r", encoding="utf-8") as file:
num = file.read().strip()
text = f"{num} の資料が公開されました。https://www.mhlw.go.jp/stf/shingi/shingi-chuo_128154.html"
message_dict = {
"messages": [
{"type": "text", "text": text},
],
}
with messaging.ApiClient(configuration=configuration) as client:
messaging_api = messaging.MessagingApi(client)
broadcast_request = messaging.BroadcastRequest.from_dict(obj=message_dict)
try:
resp = messaging_api.broadcast(broadcast_request) # noqa
# print(resp)
except Exception as e:
print(e)
if __name__ == "__main__":
main()