Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Last active January 14, 2019 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utgwkk/7019f89c589620f460270e04c1e06b24 to your computer and use it in GitHub Desktop.
Save utgwkk/7019f89c589620f460270e04c1e06b24 to your computer and use it in GitHub Desktop.
日報を書くように促してくれるSlack incoming webhook氏
#!/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