Sha256: 1c5b620b39a64db8fae083683b14567e7e67dc6dae592f87398638f16efc2905
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
class Search < Linkbot::Plugin Linkbot::Plugin.register('search', self, { :message => {:regex => Regexp.new('!search (.*)'), :handler => :on_message, :help => :help} } ) def self.on_message(message, matches) search = matches[0] rows = nil mess = "" rows = Linkbot.db.execute('select l.url,u.username,l.dt,u.showname from links l, users u where l.url like ? and l.user_id = u.user_id order by l.dt desc limit 10', "%#{search}%") i = 1 if rows.length > 0 rows.each {|row| username = (row[3].nil? || row[3] == '') ? row[1] : row[3] mess = mess + "#{i}. #{row[0]} (#{username} #{::Util.ago_in_words(Time.now, Time.at(row[2]))})\n"; i = i + 1 } else mess = "No links" end # Take the karma hit karma = Linkbot.db.execute("select karma from karma where user_id=#{user['id']}")[0][0] - 1 Linkbot.db.execute("update karma set karma=#{karma} where user_id=#{user['id']}") mess end def self.help "!search query - search for links that you think should be dupes" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
protolink-0.2.8 | example/linkbot/plugins/search.rb |