Sha256: 916784f40f3259e72d462b1dcdb43aa1bb7ebbb41a8b4458236c35ec6a98f6ee

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

class Helper < Linkbot::Plugin
  
  Linkbot::Plugin.register('help', self,
    {
      :message => {:regex => /!help/, :handler => :on_message},
      :"direct-message" => {:regex => /!help/, :handler => :on_message}
    }
  )
  
  def self.on_message(message, matches)
    messages = [] 
    Linkbot::Plugin.plugins.each {|k,v|
      if(v[:handlers][message.type] && v[:handlers][message.type][:help])
        messages << v[:ptr].send(v[:handlers][message.type][:help])
      end
    }
    messages.sort! do |x,y|
      x =~ /([A-Za-z]+)/
      sort1 = $1
      y =~ /([A-Za-z]+)/
      sort2 = $1
      sort1 <=> sort2
    end
    messages.join("\n")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
protolink-0.2.8 example/linkbot/plugins/help.rb