-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslack_notify.py
64 lines (55 loc) · 1.82 KB
/
slack_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import requests
import json
from dateutil import parser
from datamodel import *
import settings
# Config
DEBUG_MODE = False
CHANNEL = 'C989JV2NN' if DEBUG_MODE else 'CB10PPRP1'
USERNAME = '進捗どうですか?'
ICON = 'https://i.imgur.com/uWrClZN.png'
def notify(obj):
time = obj['time']
title = obj['title']
manager = obj['manager']
published_at = parser.parse(obj['published_at']).date(
) if obj['published_at'] != '' else '未定'
recorded = '✓' if int(obj['recorded']) else '✗'
edited = '✓' if int(obj['edited']) else '✗'
reviewed = '✓' if int(obj['reviewed']) else '✗'
drew_thumbnail = '✓' if int(obj['drew_thumbnail']) else '✗'
reserved = '✓' if int(obj['reserved']) else '✗'
released = '✓' if int(obj['released']) else '✗'
drew_comic = '✓' if int(obj['drew_comic']) else '✗'
tweeted = '✓' if int(obj['tweeted']) else '✗'
progress = '''\
第%s回
「%s」
担当 : %s
公開予定日 : %s
収録 : %s
編集 : %s
検閲 : %s
サムネ画像 : %s
予約投稿 : %s
公開 : %s
4コマ漫画 : %s
ツイート : %s
''' % (time, title, manager, published_at, recorded, edited, reviewed, drew_thumbnail, reserved, released, drew_comic, tweeted)
attachments = [{
"color": "#a3deff",
"text": progress,
"actions": [{
"type": "button",
"text": "ラジオスケジューラーへ飛ぶ",
"url": "http://www.scheduler.kure-rad.io:429/"
}]
}]
data = {
'channel': CHANNEL,
'username': USERNAME,
'icon_url': ICON,
'text': 'ラジオスケジューラーが更新されました',
'attachments': attachments
}
requests.post(settings.INCOMING_WEBHOOK_URL, json.dumps(data))