Like Silk: Script: MultiChannel

python関連(slack)のメモ

slackで複数のチャンネルに同時にメッセージを送信する

pyslackはpipか,easy_installでインストールしてください.
パスワード認証などを行ってください

code

slackMultiChannel.zip←右クリックで保存できます.
#!/usr/bin/env python
#coding: utf-8

import cgitb; cgitb.enable()

import cgi
from pyslack import SlackClient

slacktoken = ''
bot_icon_url = ''
bot_username = 'bot MultiChannel'
client = SlackClient( slacktoken )

content = ''

try:
	form = cgi.FieldStorage()
	message = form['message'].value
	channels = form.getlist('channels')
	for channel in channels:
		content = content + channel + '
' client.chat_post_message( channel, message, username=bot_username, icon_url=bot_icon_url) content = content + '


' content = content + message except: pass html = '''\ slack MultiChannel ''' html = html + content html = html + '''\


もどる ''' print "Content-type: text/html" print print html

参考URL


Like Silk