Browse files

server/shorten: improve speed a bit

  • Loading branch information...
1 parent eecac8f commit 25750c229b15948afae1e52437361a69825ff9ac @meh committed Jul 20, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/failirc/server/modules/shorten.rb
View
11 lib/failirc/server/modules/shorten.rb
@@ -17,15 +17,22 @@
# You should have received a copy of the GNU Affero General Public License
# along with failirc. If not, see <http://www.gnu.org/licenses/>.
-require 'timeout'
require 'shortie'
version '0.0.1'
+class Shortie::Service
+ class << self
+ memoize :find_by_key
+ end
+
+ memoize :shorten
+end
+
on :message, priority: -100 do |chain=:input, from, to, message|
return unless chain == :input
- message.scan(%r{https?://\S+}).each {|uri|
+ message.scan(%r{https?://\S+}).uniq.each {|uri|
next if uri.length <= (options[:length] ? options[:length].to_i : 42)
begin timeout(options[:timeout] ? options[:timeout].to_f : 5) {

0 comments on commit 25750c2

Please sign in to comment.