1
Files
irssi-scripts/web_link_saver/link_to_memc.pl
eleksir f4d783107c link_to_memc.pl: fix var name, now it _can_ add links :)
link_to_memc.pl: now it can add all links in string
2018-04-28 15:34:11 +03:00

42 lines
935 B
Perl

#use strict;
#use warnings "all";
use Cache::Memcached;
use Digest::MD5 qw(md5_base64);
use Irssi qw (command_bind
settings_get_bool settings_add_bool
settings_get_str settings_add_str);
use vars qw($VERSION %IRSSI);
sub hookfn;
$VERSION = '1.01';
%IRSSI = (
authors => 'Eleksir',
contact => 'eleksir@exs-elm.ru',
name => 'Image link saver',
description => 'Saves image link to memcache',
license => 'BSD',
changed => 'Sat Apr 28 15:25 CET 2018',
);
Irssi::signal_add_last("message public", "hookfn");
my $mc = '127.0.0.1:11211';
sub hookfn {
my ($a, $text, $b, $c) = @_;
my @words = split(/\s+/, $text);
foreach my $word (@words) {
if ($word =~ m{:?https?://([a-zA-Z0-9.-]+\.[a-zA-Z]+)/(?:.*)}) {
my $memd = new Cache::Memcached { 'servers' => [ $mc ] };
$memd->set(sprintf("irssi_%s", md5_base64($word)), $word);
$memd->disconnect_all;
}
}
return;
}