{"id":515,"date":"2018-02-14T21:34:00","date_gmt":"2018-02-14T12:34:00","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=515"},"modified":"2018-02-11T00:38:21","modified_gmt":"2018-02-10T15:38:21","slug":"line-nofity-tutorials","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=515","title":{"rendered":"LINE notify\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb \u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3 Ruby\u3067\u306e\u5b9f\u884c \u8907\u6570\u30b0\u30eb\u30fc\u30d7\u3078\u306e\u540c\u6642\u6295\u7a3f"},"content":{"rendered":"<p>LINE notify\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u3059\u3002\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u306e\u5b9f\u884c\u304b\u3089\u3001Ruby\u3067\u306e\u5b9f\u884c\u3001\u8907\u6570\u30b0\u30eb\u30fc\u30d7\u3078\u306e\u540c\u6642\u6295\u7a3f\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#LINE_notify\"><span class=\"toc_number toc_depth_1\">1<\/span> LINE notify \u30c8\u30fc\u30af\u30f3\u306e\u767a\u884c\u65b9\u6cd5<\/a><\/li><li><a href=\"#LINE_notify-2\"><span class=\"toc_number toc_depth_1\">2<\/span> LINE notify \u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c<\/a><\/li><li><a href=\"#LINE_notify_Ruby\"><span class=\"toc_number toc_depth_1\">3<\/span> LINE notify Ruby\u3067\u5b9f\u884c<\/a><\/li><li><a href=\"#LINE_notify-3\"><span class=\"toc_number toc_depth_1\">4<\/span> LINE notify \u8907\u6570\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u9001\u4fe1<\/a><\/li><\/ul><\/div>\n<h2><span id=\"LINE_notify\">LINE notify \u30c8\u30fc\u30af\u30f3\u306e\u767a\u884c\u65b9\u6cd5<\/span><\/h2>\n<p>\u30c8\u30fc\u30af\u30f3\u3092\u767a\u884c\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u307e\u305aLINE\u5074\u3067\u3001notify\u3092\u5229\u7528\u3057\u305f\u3044\u30b0\u30eb\u30fc\u30d7\u3092\u9069\u5f53\u306b\u65b0\u898f\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n[get_title https:\/\/notify-bot.line.me\/my\/] > \u30c8\u30fc\u30af\u30f3\u3092\u767a\u884c\u3059\u308b \u3067\u3001\u30b0\u30eb\u30fc\u30d7\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<p>\u9032\u3093\u3067\u3044\u304f\u3068\u3001API\u30ad\u30fc\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u3053\u308c\u3092\u30b3\u30d4\u30fc\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2><span id=\"LINE_notify-2\">LINE notify \u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c<\/span><\/h2>\n<p>LINE notify\u3092Bash\u306e\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<p>\u5148\u7a0b\u53d6\u5f97\u3057\u305fAPI\u30ad\u30fc\u3092\u3001\u4ee5\u4e0b\u306eYOUR_API_KEY\u306b\u57cb\u3081\u8fbc\u3093\u3067\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><code>curl https:\/\/notify-api.line.me\/api\/notify -X POST -H 'Authorization: Bearer YOUR_API_KEY' -F 'message=\u30e1\u30c3\u30bb\u30fc\u30b8\u3002'<\/code><\/p>\n<p>\u30e1\u30c3\u30bb\u30fc\u30b8\u3002\u3068\u30e9\u30a4\u30f3\u304c\u6765\u305f\u3089\u6210\u529f\u3067\u3059\u3002<\/p>\n<h2><span id=\"LINE_notify_Ruby\">LINE notify Ruby\u3067\u5b9f\u884c<\/span><\/h2>\n<p>LINE notify\u3092Ruby\u3067\u5b9f\u884c\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<pre><code>require 'open3'\n\n@token = 'YOUR_API_KEY'\nOpen3.popen3(\"curl https:\/\/notify-api.line.me\/api\/notify -X POST -H \\'Authorization: Bearer #{@token}\\' -F 'message=#{ARGV[0]}'\")\n<\/code><\/pre>\n<p><code>ruby \/mnt\/f\/__HDD_BACKUP__\/pg\/create_apps\/line_notify\/notify.rb hoge<\/code>\u3068\u7b2c\u4e00\u5f15\u6570\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3092\u30b3\u30de\u30f3\u30c9\u306b\u767b\u9332\u3057\u3066\u304a\u3051\u3070\u3001\u7c21\u5358\u306b\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<h2><span id=\"LINE_notify-3\">LINE notify \u8907\u6570\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u9001\u4fe1<\/span><\/h2>\n<p>\u4ee5\u524d\u4f5c\u3063\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u8907\u6570\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u540c\u6642\u306b\u540c\u3058\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3057\u305f\u3044\u5834\u5408\u306b\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<p><em>README.md<\/em><\/p>\n<pre><code><br \/># What?\nTerminal App of Line notify api.\n\n# usage\n$ ruby line_notify.rb 'Enter your message.' '1'\n\n*help*\n$ ruby line_notify.rb help\n\n*methods*\n\\````rb\nnotify=LINE_notify.new\nnotify.verification_argv # if argv is \"help\" then puts help.\nnotify.confirm # for confirm\n# notify.message='your good message.'\n# notify.token=YOUR_TOKEN\n# notify.token_select='123' # select token number of yaml\np notify.help #puts help\nnotify.multi_post\n\\````\n\n*yaml*\n\\````yaml\nconfig:\n  keys:\n    group_1: '' #share\n    group_2: '' #dev\n    group_3: '' #notify_3\n    group_4: '' #notify_4\n\\````\n\n<\/code><\/pre>\n<p><em>main.rb<\/em><\/p>\n<pre><code><br \/>require 'open3'\nrequire 'yaml'\n\nclass LINE_notify\nattr_accessor :message, :token, :token_select\n\ndef initialize\n@config=YAML.load_file(File.expand_path('..\/config.yaml',__FILE__))\n@message,@token_select = ARGV[0],ARGV[1]\nend\n\ndef confirm\nif @token_select.nil? then puts %(\"argv2 is nil. to exit.\");exit\nelsif @message.nil? then puts %(\"argv1 is nil. to exit.\") ;exit\nend\nend\n\ndef notify\n    @command=%(curl https:\/\/notify-api.line.me\/api\/notify -X POST -H 'Authorization: Bearer #{@token}' -F 'message=#{@message}')\n    Open3.popen3(@command)\nend #notify end\n\ndef multi_post\n9.times do |index_num|\n    if @token_select.match(\/#{index_num}\/)\n        @token=@config[\"config\"][\"keys\"][\"group_#{index_num}\"]\n        notify()\n    puts %(group_#{index_num}: #{@message})\n    else\n        puts %(Skip to group_#{index_num}.)\n    end\nend\nend\n\ndef verification_argv\n  if ARGV[0] =~ \/help|-h|--h\/ then puts help() end\nend\n\ndef help\n  open(File.expand_path('..\/README.md',__FILE__)).read\nend\n\nend\n\n\n<\/code><\/pre>\n<p><em>config.yaml<\/em><\/p>\n<pre><code>config:\n  keys:\n    group_1: '' #share\n    group_2: '' #dev\n    group_3: '' #notify_3\n    group_4: '' #notify_4\n\n<\/code><\/pre>\n<p><em>ctl.rb<\/em><\/p>\n<pre><code><br \/>require_relative 'main'\n\n\nnotify=LINE_notify.new\nnotify.verification_argv # if argv is \"help\" then puts help.\nnotify.confirm # for confirm\n# notify.message='your good message.'\n# notify.token=YOUR_TOKEN\n# notify.token_select='123' # select token number of yaml\n# p notify.help #puts help\nnotify.multi_post\n\n\n<\/code><\/pre>\n<p><em>\u7c21\u5358\u306a\u4f7f\u3044\u65b9<\/em><\/p>\n<p>README\u304c\u308f\u304b\u308a\u306b\u304f\u3044\u306e\u3067\u7c21\u5358\u306a\u4f7f\u3044\u65b9\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001ctl\u306f\u3044\u3058\u3089\u306a\u304f\u3066\u3044\u3044\u3067\u3059\u3002\u672c\u5f53\u306f\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3058\u3083\u306a\u304f\u3066\u76f4\u63a5\u5b9f\u884c\u3067\u3082\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u4f7f\u308f\u306a\u3044\u3060\u308d\u3046\u3057\u3002<br \/>\n\u3088\u3063\u3066\u3001README\u3082\u8aad\u307e\u306a\u304f\u3066\u3044\u3044\u3067\u3059\u3002<\/p>\n<p>\u5927\u4e8b\u306a\u306e\u306f\u3001config.yaml\u306bAPI\u30ad\u30fc\u3092\u8a18\u8f09\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3068\u3001\u5f15\u6570\u306e\u66f8\u304d\u65b9\u3067\u3059\u3002<\/p>\n<p>\u5f15\u6570\u306f\u3001\u7b2c\u4e00\u5f15\u6570\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3001\u7b2c\u4e8c\u5f15\u6570\u306bconfig.yaml\u306b\u57fa\u3065\u3044\u305f\u3001\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3057\u305f\u3044\u756a\u53f7\u3092\u7f85\u5217\u3057\u307e\u3059\u3002<\/p>\n<p><code>ruby ctl.rb \u30e1\u30c3\u30bb\u30fc\u30b8\u3002 '13'<\/code><\/p>\n<p>\u3053\u308c\u3060\u3068\u30011\u30683\u306eAPI\u30ad\u30fc\u306b\u5fdc\u3058\u305f\u30b0\u30eb\u30fc\u30d7\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u9001\u4fe1\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code>yuis@DESKTOP-UHU8FSH:\/mnt\/c\/ContaCam$ ruby \/mnt\/f\/__HDD_BACKUP__\/_document\/poblic\/files\/pg\/ruby\/LINE_notify\/ctl.rb hoge 1234\nSkip to group_0.\n\/usr\/lib\/ruby\/2.3.0\/open3.rb:199: warning: Insecure world writable dir \/home\/yuis\/.local\/bin in PATH, mode 040777\ngroup_1: hoge\ngroup_2: hoge\ngroup_3: hoge\ngroup_4: hoge\nSkip to group_5.\nSkip to group_6.\nSkip to group_7.\nSkip to group_8.\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>LINE notify\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u3059\u3002\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u306e\u5b9f\u884c\u304b\u3089\u3001Ruby\u3067\u306e\u5b9f\u884c\u3001\u8907\u6570\u30b0\u30eb\u30fc\u30d7\u3078\u306e\u540c\u6642 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"acf":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8Rxwo-8j","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/515"}],"collection":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=515"}],"version-history":[{"count":0,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/515\/revisions"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}