lib/cinch/plugins/links.rb
def command_link(m, uri_string)
        if uri_string.empty?
          command_help(m)
        else
          # Verify this is a valid URI
          uri = Addressable::URI::parse(uri_string)

          if uri.scheme.nil?
            # No scheme for URI, parse it again with http in front
            uri = Addressable::URI.parse("http://#{uri.to_s}")
          end

          new_link = Link.create(
            :uri  => uri,
            :user => m.user.nick
          )

          if new_link.saved?
            m.user.send "Added link suggestion #{new_link.uri}"
          else
            new_link.errors.each do |e|
              m.user.send e.first
            end
          end
        end

      end
# Add the user's link to the database
Add the user's link to the database
Add the user ' s link to the database
def command_link(m, uri_string)
        if uri_string.empty?
          command_help(m)
        else
          uri = Addressable::URI::parse(uri_string)
          if uri.scheme.nil?
            uri = Addressable::URI.parse("http://#{uri.to_s}")
          end
          new_link = Link.create(
            :uri  => uri,
            :user => m.user.nick
          )
          if new_link.saved?
            m.user.send "Added link suggestion #{new_link.uri}"
          else
            new_link.errors.each do |e|
              m.user.send e.first
            end
          end
        end
      end
def command_link ( m , uri_string ) if uri_string . empty? command_help ( m ) else uri = Addressable :: URI :: parse ( uri_string ) if uri . scheme . nil? uri = Addressable :: URI . parse ( "http://#{uri.to_s}" ) end new_link = Link . create ( :uri => uri , :user => m . user . nick ) if new_link . saved? m . user . send "Added link suggestion #{new_link.uri}" else new_link . errors . each do | e | m . user . send e . first end end end end
Add the user's link to the database
Add the user ' s link to the database
# Verify this is a valid URI # No scheme for URI, parse it again with http in front
m
uri_string