Changeset 18670 for lang/ruby

Show
Ignore:
Timestamp:
09/02/08 22:52:35 (4 months ago)
Author:
drry
Message:
  • 正規表現を修正しました。
  • re コマンドを別名にして reply コマンドに改名しました。
  • wig.rb に習って #api を変更しました。
  • ほか。
Location:
lang/ruby/net-irc/trunk/examples
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/net-irc/trunk/examples/iig.rb

    r17052 r18670  
    133133 
    134134        def api_source 
    135                 "iigrb" 
     135                "iig.rb" 
    136136        end 
    137137 
  • lang/ruby/net-irc/trunk/examples/tig.rb

    r18654 r18670  
    9595Force SSL for API. 
    9696 
     97## Extended commands through the CTCP ACTION 
     98 
     99### list (ls) 
     100 
     101        /me list NICK_or_screen_name 
     102 
     103### fav (favorite, favourite, unfav, unfavorite, unfavourite) 
     104 
     105        /me fav ID [ID...] 
     106        /me unfav ID [ID...] 
     107 
     108### link (ln) 
     109 
     110        /me link ID [ID...] 
     111 
     112### destroy (del, delete, miss, oops, remove, rm) 
     113 
     114        /me destroy ID [ID...] 
     115 
     116### in (location) 
     117 
     118        /me in Tokyo, Japan 
     119 
     120### reply (re) 
     121 
     122        /me reply ID blah, blah... 
     123 
     124### utf7 
     125 
     126   /me utf7 
     127 
    97128## License 
    98129 
     
    327358                                require "iconv" 
    328359                                @utf7 = !@utf7 
    329                                 log "utf7 mode: #{@utf7 ? 'on' : 'off'}" 
     360                                log "UTF-7 mode: #{@utf7 ? 'on' : 'off'}" 
    330361                        rescue LoadError => e 
    331362                                log "Can't load iconv." 
     
    397428                        location = location.empty? ? "nowhere" : "in #{location}" 
    398429                        post server_name, NOTICE, main_channel, "You are #{location} now." 
    399                 when "re" 
     430                when /^re(?:ply)?$/ 
    400431                        tid = args.first 
    401432                        st  = @tmap[tid] 
     
    722753 
    723754                q["source"] ||= api_source 
    724                 q = q.inject([]) {|r,(k,v)| v ? r << "#{k}=#{URI.escape(v, /[^-.!~*'()\w]/n)}" : r }.join("&") 
    725755 
    726756                path = path.sub(%r{^/+}, "") 
     
    731761                end 
    732762                uri.path += "#{path}.json" 
     763                uri.query = q.inject([]) {|r,(k,v)| v ? r << "#{k}=#{URI.escape(v, /[^-.!~*'()\w]/n)}" : r }.join("&") 
    733764                if require_post? path 
    734                         req = Net::HTTP::Post.new(uri.request_uri, headers) 
    735                         req.body = q 
     765                        req = Net::HTTP::Post.new(uri.path, headers) 
     766                        req.body = uri.query 
    736767                else 
    737                         uri.query = q 
    738768                        req = Net::HTTP::Get.new(uri.request_uri, headers) 
    739769                end 
     
    780810 
    781811        def untinyurl(text) 
    782                 text.gsub(%r"http://(?:(?:preview\.)?tinyurl\.com|rubyurl\.com)/[0-9a-z=]+"i) {|m| 
     812                text.gsub(%r"http://(?:(preview\.)?tin|rub)yurl\.com)/[0-9a-z=]+"i) {|m| 
    783813                        uri = URI(m) 
    784814                        uri.host = uri.host.sub($1, "") if $1