Last active
January 14, 2019 07:41
-
-
Save utgwkk/7019f89c589620f460270e04c1e06b24 to your computer and use it in GitHub Desktop.
日報を書くように促してくれるSlack incoming webhook氏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import subprocess | |
import json | |
import urllib.parse | |
from datetime import date | |
PROJECT_NAME = 'your-project-name' | |
WEBHOOK_URL = 'SLACK_INCOMING_WEBHOOK_URL' | |
def to_ja_week(week_num: int) -> str: | |
weekday_list = ['月', '火', '水', '木', '金', '土', '日'] | |
return weekday_list[week_num] | |
today = date.today() | |
title = today.strftime("%Y-%m-%d") | |
body = '''[{}曜日] | |
#日報'''.format(to_ja_week(today.weekday())) | |
url = 'https://scrapbox.io/{}/{}?body={}'.format(PROJECT_NAME, title, urllib.parse.quote(body)) | |
payload = { | |
'text': '日報を書きませんか\n{}'.format(url) | |
} | |
subprocess.run(["curl", "-X", "POST", "-H", "Content-type: application/json", "--data", json.dumps(payload), WEBHOOK_URL], check=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment