Changeset 6478

Show
Ignore:
Timestamp:
02/10/08 14:36:16 (5 years ago)
Author:
drry
Message:

lang/ruby/chokan/branches/citrus/plugins/hatena.rb: 実在IDにデクリメントは気まずい。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/chokan/branches/citrus/plugins/hatena.rb

    r6433 r6478  
    66class Hatena < Citrus::Plugin 
    77        def on_privmsg(prefix, channel, message) 
     8                re_id = /id:([a-zA-Z][\w-]{1,30}[a-zA-Z\d])/ 
    89                case message 
    9                 when /\bg:([a-z][a-z\d]*)(?::id:([a-z][a-z0-9_-]{1,30}[a-z0-9]))?/i 
     10                when /\bg:([a-zA-Z][a-zA-Z\d]{2,23})(?::#{re_id})?/n 
    1011                        g, id = Regexp.last_match.captures 
    1112                        id << '/' if id 
    1213                        notice(channel, "http://#{g}.g.hatena.ne.jp/#{id}") 
    13                 when /\b(?:([a-z][a-z\d]*):)?id:([a-z][a-z0-9_-]{1,30}[a-z0-9])/i 
     14                when /\b(?i:([a-z][a-z\d]*):)?#{re_id}/n 
    1415                        s, id = Regexp.last_match.captures 
    1516                        if exist?(id) 
     
    2526                        end 
    2627                rescue Exception 
    27                         false 
     28                        nil 
    2829                end 
    2930        end 
     
    4849 
    4950                        @socket.string = "" 
    50                         @plugin.on_privmsg(@prefix, "#test", "d:id:jkondo--") 
     51                        @plugin.on_privmsg(@prefix, "#test", "d:id:jkondo++") 
    5152                        @socket.string.should == "NOTICE #test http://d.hatena.ne.jp/jkondo/\r\n" 
    5253