概要
import requests import json class Payload: def to_json(self): return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) payload = Payload() payload.channel = "【チャンネル名】" payload.username = "【ユーザー名】" payload.text = "【メッセージ】" payload.icon_emoji = "【絵文字アイコン】" payload.icon_url = "【アイコンの URL】" json = payload.to_json() WEB_HOOK_URL = "【Incoming Webhooks の URL】" requests.post(WEB_HOOK_URL, data=json)