[追è¨] å¤æ´ãå¤ããªã£ã¦ãããããwiki ã§æ å ±ã管çãããã¨ã«ãã¾ããã
以ä¸ã®æ å ±ã¯å¤ãã§ãã
å
é±æ«ã«ãããã¬ã¤ã¯ãã flagtter ã«ã¤ãã¦ã以åã®æ
å ±ãå¤ããªã£ã¦ãããããææ°ã®æ
å ±ãæ¸ãã¦ããã
ã¤ãã£ã¦ãããã 8 ã¶æãçµã£ã¦ãããã©ãå®ã¯ããããããããå¤ãã£ã¦ããã
- cron ã§åããã¦ãããµã¼ããå ã ããã»ã©ã¹ããã¯ãé«ããªããã®ã§ 5 åæ¯ã«å®è¡ã¨ããã¦ããããããªã½ã¼ã¹ãæå¤ã¨é£ã£ã¦ãã¾ããã¢ã«ã¦ã³ãã ban ããã¦ãã¾ã£ãããã®ãããä»ã¯ã¬ã³ã¿ã«ãµã¼ã (sakura) ã§åããã¦ããã
- 使ç¨ãã¦ãã http://twitter.1x1.jp/search/ ãããã¾ããã¡ãã¨åããªããªã£ã¦ãããããhttp://pcod.no-ip.org/yats/ ãå©ç¨ããããã«å¤æ´ãããRSS ã®ä¸èº«ããã£ããéã£ã¦ãããããç¾ç¶ã®ããã«ãããªãã«åãããã«ããã«ã¯ã¡ãã£ã¨è¦å´ããã
- æ¤ç´¢æ¡ä»¶ã®ã²ã¨ã¤ã®ããããã ãããããã ããããã ãã«ãã¦ãææããç¯å²ãåºãããã¨æã£ã¦ãããããããã ãã ã¨ä½æ ããããããçºè¨ããªãã¨è¨ããã¦ãããããã ãã ã¨å ¨ç¶éãã®ãæ¾ã£ã¦ãã¾ããã¨ããçç±ããçµå±ããããã ãã«è½ã¡çãã¦ããããæè¿ã¯ãããã ãããããããããã«ãªã£ã¦ããã®ã§ãããã ãã«å¤æ´ããã
ã¨ããããä¿®æ£å¾ã®ã½ã¼ã¹ãæãã
#!/usr/local/bin/ruby -Ku # -*- coding: utf-8 -*- require 'net/http' require 'rexml/document' require 'time' require 'timeout' FILE = ENV["HOME"] + "/var/log/flagtter.log" USERNAME = "flagtter" PASSWORD = "********" Net::HTTP.version_1_2 #log = File.open(FILE, "a") result = "" # æ¤ç´¢çµæã® RSS ãå ¥æ begin timeout(60) { result = Net::HTTP.get("pcod.no-ip.org", "/yats/search?query=俺+ãã+ããã &lang=ja&rss") } rescue # RSS ãå ¥æã§ããªãã£ããçµäº log.close exit(0) rescue TimeoutError # RSS ãå ¥æã§ããªãã£ããçµäº log.close exit(0) end # RSS ããæååãæ½åº â æ稿 rexml = REXML::Document.new(result) rexml.elements.each("//feed/entry") { |item| name = item.elements["title"].text if ((name <=> "flagtter") != 0) time = Time.parse(item.elements["updated"].text.gsub(/T/, " ").gsub(/Z/, "")) if ((log.mtime - 9 * 60 * 60) < time) text = item.elements["summary"].text if (text.match(/俺.*ãã.*ããã /)) text.gsub!(/.*俺/, "俺").gsub!(/ããã .*/, "ããã ") status = "ã#{text}ãã¨ã¤ã¶ããã @#{name} ã«ãã©ã°ãã»ããããã¾ããã" # æ稿 begin timeout(120) { request1 = Net::HTTP::Post.new('/statuses/update.json') request1.basic_auth(USERNAME, PASSWORD) request1.body = "status=" + status Net::HTTP.start("twitter.com", 80) { |http| response1 = http.request(request1) } # çºè¨è ããã©ãã¼ # æ稿ã«æåããå ´åã ããã©ãã¼ããããã«ãã request2 = Net::HTTP::Post.new("/friendships/create/#{name}.json") request2.basic_auth(USERNAME, PASSWORD) Net::HTTP.start("twitter.com", 80) { |http| response2 = http.request(request2) } } rescue # ignore rescue Timeout::Error # ignore end log.puts "#{time} - #{status}" # 失æãã¦ããã°ã«ã¯è¿½è¨ end break # 1 åã«ã¤ã 1 æ稿ã®ã¿ end end } log.flush log.close
åºæ¬çã«æ¤ç´¢æã«ãããããçºè¨ã®ä¸ã®ææ°ã® 1 件ãã対象ã¨ããªããããçæéã«è¤æ°ããã¨åããã¼ããããã解決ããããã«ä¸åº¦ DB ã«çªã£è¾¼ãã§ãããé£æ㧠ban ãããªãç¨åº¦ã«ãã¹ããããããªä»çµã¿ã«ããã¹ãããªã¨æã£ã¦ããã
ãã¨ãmecab ã使ã£ãããå¤åçãªã俺ããããããããã ãã«ã対å¿ã§ããããªã¨ãæã£ã¦ããã®ã§ã調ã¹ã¦ã¿ããããªã¨æã£ã¦ããã