Skip to content

Instantly share code, notes, and snippets.

@kojira
Created August 6, 2019 19:45
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 kojira/dd3e91d8e24f57055a87214d1f648613 to your computer and use it in GitHub Desktop.
Save kojira/dd3e91d8e24f57055a87214d1f648613 to your computer and use it in GitHub Desktop.
標準入力から受けた文字列をwebhookに投げるやつ
import requests
import json
def post_webhook(name, content):
request = {
"username": "",
"content": ""
}
headers = {'content-type': 'application/json'}
url="replace webhookurl"
request['username'] = name
request['content'] = content
response = requests.post(url, data=json.dumps(request), headers=headers)
import sys
index = 0
text = ""
for line in iter(sys.stdin.readline, ""):
text += line
post_webhook("hoge",text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment