Last active
February 13, 2019 05:35
-
-
Save quanon/b3e3fcf74bd408e14ff7e20b9e496c3f to your computer and use it in GitHub Desktop.
「Raspberry Pi 上で J-MOTTO にログインして打刻する Node.js スクリプト」を叩くための Slack Bot
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
from slackbot.bot import Bot | |
from slackbot.bot import listen_to | |
import subprocess | |
import daemon | |
def main(): | |
bot = Bot() | |
bot.run() | |
@listen_to('(出社|退社)') | |
def kintai(message, kintai): | |
channel_info = message.channel._client.channels[message.body['channel']] | |
channel_name = channel_info['name'] | |
if channel_name != 'kintai': | |
return | |
options = {'出社': '--kin', '退社': '--tai'} | |
message.send('打刻中...') | |
result = subprocess.check_output(f'cd /home/quanon/workspace/jmotto && node kintai.js {options[kintai]}', shell=True) | |
message.send(result.decode()) | |
if __name__ == '__main__': | |
with daemon.DaemonContext(): | |
main() |
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
API_TOKEN = 'API トークンをここに入力する' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/lins05/slackbot というライブラリを使っている。