#!/usr/bin/env python

import argparse
import os
import sys

try:
    import linebot
except:
    print('\n\tpip install line-bot-sdk\n')
    sys.exit(1)


if sys.stdin.isatty():
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.add_argument('message', nargs='+')
    args = parser.parse_args()
    message = ' '.join(args.message)
else:
    message = sys.stdin.read().strip()

api = linebot.LineBotApi(os.environ['LINEBOT_TOKEN'])
api.push_message(
    os.environ['LINEBOT_USER_ID'],
    linebot.models.TextSendMessage(message),
)
