irssi-scripts-20131030/0000755000000000000000000000000012234341564011455 5ustar irssi-scripts-20131030/scripts/0000755000000000000000000000000012234334112013133 5ustar irssi-scripts-20131030/scripts/wlstat.pl0000644000000000000000000005110012143537176015021 0ustar use strict; # use warnings; # FIXME COULD SOMEONE PLEASE TELL ME HOW TO SHUT UP # # ... # Variable "*" will not stay shared at (eval *) line *. # Variable "*" will not stay shared at (eval *) line *. # ... # Can't locate package Irssi::Nick for @Irssi::Irc::Nick::ISA at (eval *) line *. # ... # # THANKS use Irssi (); # which is the minimum required version of Irssi ? use Irssi::TextUI; use vars qw($VERSION %IRSSI); $VERSION = '0.5'; %IRSSI = ( authors => 'BC-bd, Veli, Timo \'cras\' Sirainen, Wouter Coekaerts, Nei', contact => 'bd@bc-bd.org, veli@piipiip.net, tss@iki.fi, wouter@coekaerts.be, Nei@QuakeNet', name => 'wlstat', description => 'Adds a window list in the status area. Based on chanact.pl by above authors.', license => 'GNU GPLv2 or later', ); # adapted by Nei ############### # original comment # ########### # # Adds new powerful and customizable [Act: ...] item (chanelnames,modes,alias). # # Lets you give alias characters to windows so that you can select those with # # meta-. # # # # for irssi 0.8.2 by bd@bc-bd.org # # # # inspired by chanlist.pl by 'cumol@hammerhart.de' # # # ######### # # Contributors # ######### # # # # veli@piipiip.net /window_alias code # # qrczak@knm.org.pl chanact_abbreviate_names # # qerub@home.se Extra chanact_show_mode and chanact_chop_status # # # # FURTHER THANKS TO # ############ # # buu, fxn, Somni, Khisanth, integral, tybalt89 for much support in any aspect perl # # and the channel in general ( #perl @ freenode ) and especially the ir_* functions # # # # Valentin 'senneth' Batz ( vb@g-23.org ) for the pointer to grep.pl, continuous support # # and help in digging up ir_strip_codes # # # # OnetrixNET technology networks for the debian environment # # # # Monkey-Pirate.com / Spaceman Spiff for the webspace # # # ###### # M A I N P R O B L E M ##### # # It is impossible to place the wlstat on a statusbar together with other items, because I # do not know how to calculate the size that it is going to get granted, and therefore I # cannot do the linebreaks properly. # This is what is missing to make a nice script out of wlstat. # If you have any ideas, please contact me ASAP :). # ###### ###### # UTF-8 PROBLEM ##### # # Please help me find a solution to this: # this be your statusbar, it is using up the maximum term size # [[1=1]#abc [2=2]#defghi] # # now consider this example: "ascii" characters are marked with ., utf-8 characters with * # [[1=1]#... [2=2]#...***] # # you should think that this is how it would be displayed? WRONG! # [[1=1]#... [2=2]#...*** ] # # this is what Irssi does.. I believe my length calculating code to be correct, however, I'd # love to be proven wrong (or receive any other fix, too, of course!) # ###### ######### # USAGE ### # # copy the script to ~/.irssi/scripts/ # # In irssi: # # /script load wlstat # # # Hint: to get rid of the old [Act:] display # /statusbar window remove act # # to get it back: # /statusbar window add -after lag -priority 10 act # ########## # OPTIONS ######## # # /set wlstat_display_nokey # /set wlstat_display_key # * string : Format String for one window. The following $'s are expanded: # $C : Name # $N : Number of the Window # $Q : meta-Keymap # $H : Start highlighting # $S : Stop highlighting # IMPORTANT: don't forget to use $S if you used $H before! # # /set wlstat_separator # * string : Charater to use between the channel entries # you'll need to escape " " space and "$" like this: # "/set wlstat_separator \ " # "/set wlstat_separator \$" # and {}% like this: # "/set wlstat_separator %{" # "/set wlstat_separator %}" # "/set wlstat_separator %%" # (reason being, that the separator is used inside a {format }) # # /set wlstat_hide_data # * num : hide the window if its data_level is below num # set it to 0 to basically disable this feature, # 1 if you don't want windows without activity to be shown # 2 to show only those windows with channel text or hilight # 3 to show only windows with hilight # # /set wlstat_maxlines # * num : number of lines to use for the window list (0 to disable) # # /set wlstat_sort <-data_level|-last_line|refnum> # * you can change the window sort order with this variable # -data_level : sort windows with hilight first # -last_line : sort windows in order of activity # refnum : sort windows by window number # # /set wlstat_placement # /set wlstat_position # * these settings correspond to /statusbar because wlstat will create # statusbars for you # (see /help statusbar to learn more) # # /set wlstat_all_disable # * if you set wlstat_all_disable to ON, wlstat will also remove the # last statusbar it created if it is empty. # As you might guess, this only makes sense with wlstat_hide_data > 0 ;) # ### # WISHES #### # # if you fiddle with my mess, provide me with your fixes so I can benefit as well # # Nei =^.^= ( QuakeNet accountname: ailin ) # my $actString = []; # statusbar texts my $currentLines = 0; my $resetNeeded; # layout/screen has changed, redo everything my $needRemake; # "normal" changes #my $callcount = 0; my $globTime = undef; # timer to limit remake() calls my %statusbars; # currently active statusbars # maybe I should just tie the array ? sub add_statusbar { for (@_) { # add subs for my $l ($_) { eval { no strict 'refs'; # :P *{"wlstat$l"} = sub { wlstat($l, @_) }; }; } Irssi::command("statusbar wl$_ reset"); Irssi::command("statusbar wl$_ enable"); if (lc Irssi::settings_get_str('wlstat_placement') eq 'top') { Irssi::command("statusbar wl$_ placement top"); } if ((my $x = int Irssi::settings_get_int('wlstat_position')) != 0) { Irssi::command("statusbar wl$_ position $x"); } Irssi::command("statusbar wl$_ add -priority 100 -alignment left barstar"); Irssi::command("statusbar wl$_ add wlstat$_"); Irssi::command("statusbar wl$_ add -priority 100 -alignment right barend"); Irssi::command("statusbar wl$_ disable"); Irssi::statusbar_item_register("wlstat$_", '$0', "wlstat$_"); $statusbars{$_} = {}; } } sub remove_statusbar { for (@_) { Irssi::command("statusbar wl$_ reset"); Irssi::statusbar_item_unregister("wlstat$_"); # XXX does this actually work ? # DO NOT REMOVE the sub before you have unregistered it :)) for my $l ($_) { eval { no strict 'refs'; undef &{"wlstat$l"}; }; } delete $statusbars{$_}; } } sub syncLines { my $temp = $currentLines; $currentLines = @$actString; #Irssi::print("current lines: $temp new lines: $currentLines"); my $currMaxLines = Irssi::settings_get_int('wlstat_maxlines'); if ($currMaxLines > 0 and @$actString > $currMaxLines) { $currentLines = $currMaxLines; } return if ($temp == $currentLines); if ($currentLines > $temp) { for ($temp .. ($currentLines - 1)) { add_statusbar($_); Irssi::command("statusbar wl$_ enable"); } } else { for ($_ = ($temp - 1); $_ >= $currentLines; $_--) { Irssi::command("statusbar wl$_ disable"); remove_statusbar($_); } } } my %keymap; sub get_keymap { my ($textDest, undef, $cont_stripped) = @_; if ($textDest->{'level'} == 524288 and $textDest->{'target'} eq '' and !defined($textDest->{'server'})) { if ($cont_stripped =~ m/meta-(.)\s+change_window (\d+)/) { $keymap{$2} = "$1"; } Irssi::signal_stop(); } } sub update_keymap { %keymap = (); Irssi::signal_remove('command bind' => 'watch_keymap'); Irssi::signal_add_first('print text' => 'get_keymap'); Irssi::command('bind'); # stolen from grep Irssi::signal_remove('print text' => 'get_keymap'); Irssi::signal_add('command bind' => 'watch_keymap'); Irssi::timeout_add_once(100, 'eventChanged', undef); } # watch keymap changes sub watch_keymap { Irssi::timeout_add_once(1000, 'update_keymap', undef); } update_keymap(); sub expand { my ($string, %format) = @_; my ($exp, $repl); $string =~ s/\$$exp/$repl/g while (($exp, $repl) = each(%format)); return $string; } # FIXME implement $get_size_only check, and user $item->{min|max-size} ?? sub wlstat { my ($line, $item, $get_size_only) = @_; if ($needRemake) { $needRemake = undef; remake(); } my $text = $actString->[$line]; # DO NOT set the actual $actString->[$line] to '' here or $text = '' unless defined $text; # you'll screw up the statusbar counter ($currentLines) $item->default_handler($get_size_only, $text, '', 1); } my %strip_table = ( # fe-common::core::formats.c:format_expand_styles # delete format_backs format_fores bold_fores other stuff (map { $_ => '' } (split //, '04261537' . 'kbgcrmyw' . 'KBGCRMYW' . 'U9_8:|FnN>#[')), # escape (map { $_ => $_ } (split //, '{}%')), ); sub ir_strip_codes { # strip %codes my $o = shift; $o =~ s/(%(.))/exists $strip_table{$2} ? $strip_table{$2} : $1/gex; $o } sub ir_parse_special { my $o; my $i = shift; my $win = Irssi::active_win(); my $server = Irssi::active_server(); if (ref $win and ref $win->{'active'}) { $o = $win->{'active'}->parse_special($i); } elsif (ref $win and ref $win->{'active_server'}) { $o = $win->{'active_server'}->parse_special($i); } elsif (ref $server) { $o = $server->parse_special($i); } else { $o = Irssi::parse_special($i); } $o } sub sb_expand { # expand {format }s (and apply parse_special for $vars) ir_parse_special( Irssi::current_theme->format_expand( shift, ( Irssi::EXPAND_FLAG_IGNORE_REPLACES | Irssi::EXPAND_FLAG_IGNORE_EMPTY ) ) ) } sub sb_strip { ir_strip_codes( sb_expand(shift) ); # does this get us the actual length of that s*ty bar :P ? } sub sb_length { # unicode cludge, d*mn broken Irssi # screw it, this will fail from broken joining anyway (and cause warnings) if (lc Irssi::settings_get_str('term_type') eq 'utf-8') { my $temp = sb_strip(shift); # try to switch on utf8 eval { no warnings; require Encode; #$temp = Encode::decode_utf8($temp); # thanks for the hint, but I have my reasons for _utf8_on Encode::_utf8_on($temp); }; length($temp) } else { length(sb_strip(shift)) } } # !!! G*DD*MN Irssi is adding an additional layer of backslashitis per { } layer # !!! AND I still don't know what I need to escape. # !!! and NOONE else seems to know or care either. # !!! f*ck open source. I mean it. # XXX any Irssi::print debug statement leads to SEGFAULT - why ? # major parts of the idea by buu (#perl @ freenode) # thanks to fxn and Somni for debugging # while ($_[0] =~ /(.)/g) { # my $c = $1; # XXX sooo... goto kills $1 # if ($q eq '%') { goto ESC; } ## s/%(.)|(\{)|(\})|(\\|\$)/$1?$1:$2?($level++,$2):$3?($level>$min_level&&$level--,$3):'\\'x(2**$level-1).$4/ge; # untested... sub ir_escape { my $min_level = $_[1] || 0; my $level = $min_level; my $o = shift; $o =~ s/ ( %. ) | # $1 ( \{ ) | # $2 ( \} ) | # $3 ( \\ ) | # $4 ( \$(?=.) ) | # $5 ( \$ ) # $6 / if ($1) { $1 } # %. escape elsif ($2) { $level++; $2 } # { nesting start elsif ($3) { if ($level > $min_level) { $level--; } $3 } # } nesting end elsif ($4) { '\\'x(2**$level) } # \ needs \\escaping elsif ($5) { '\\'x(2**$level-1) . '$' . '\\'x(2**$level-1) } # and $ needs even more because of "parse_special" else { '\\'x(2**$level-1) . '$' } # $ needs \$ escaping /gex; $o } #sub ir_escape { # my $min_level = $_[1] || 0; my $level = $min_level; # my $o = shift; # $o =~ s/ # ( %. ) | # $1 # ( \{ ) | # $2 # ( \} ) | # $3 # ( \\ | \$ ) # $4 # / # if ($1) { $1 } # %. escape # elsif ($2) { $level++; $2 } # { nesting start # elsif ($3) { if ($level > $min_level) { $level--; } $3 } # } nesting end # else { '\\'x(2**($level-1)-1) . $4 } # \ or $ needs \\escaping # /gex; # $o #} sub ir_fe { # try to fix format stuff my $x = shift; # XXX why do I have to use two/four % here instead of one/two ?? answer: you screwed up in ir_escape $x =~ s/([%{}])/%$1/g; $x =~ s/(\\|\$)/\\$1/g; #$x =~ s/(\$(?=.))|(\$)/$1?"\\\$\\":"\\\$"/ge; # I think this should be here (logic), but it doesn't work that way :P #$x =~ s/\\/\\\\/g; # that's right, escape escapes $x } sub remake () { #$callcount++; #my $xx = $callcount; Irssi::print("starting remake [ $xx ]"); my ($hilight, $number, $display); my $separator = '{sb_act_sep ' . Irssi::settings_get_str('wlstat_separator') . '}'; my $custSort = Irssi::settings_get_str('wlstat_sort'); my $custSortDir = 1; if ($custSort =~ /^[-!](.*)/) { $custSortDir = -1; $custSort = $1; } $actString = []; my ($line, $width) = (0, [Irssi::windows]->[0]{'width'} - sb_length('{sb x}')); foreach my $win ( sort { ( ( (int($a->{$custSort}) <=> int($b->{$custSort})) * $custSortDir ) || ($a->{'refnum'} <=> $b->{'refnum'}) ) } Irssi::windows ) { $actString->[$line] = '' unless defined $actString->[$line] or Irssi::settings_get_bool('wlstat_all_disable'); # all stolen from chanact, what does this code do and why do we need it ? !ref($win) && next; my $name = $win->get_active_name; my $active = $win->{'active'}; my $colour = $win->{'hilight_color'}; if (!defined $colour) { $colour = ''; } if ($win->{'data_level'} < Irssi::settings_get_int('wlstat_hide_data')) { next; } # for Geert if ($win->{'data_level'} == 0) { $hilight = '{sb_act_none '; } elsif ($win->{'data_level'} == 1) { $hilight = '{sb_act_text '; } elsif ($win->{'data_level'} == 2) { $hilight = '{sb_act_msg '; } elsif ($colour ne '') { $hilight = "{sb_act_hilight_color $colour "; } elsif ($win->{'data_level'} == 3) { $hilight = '{sb_act_hilight '; } else { $hilight = '{sb_act_special '; } $number = $win->{'refnum'}; $display = (defined $keymap{$number} and $keymap{$number} ne '') ? ( Irssi::settings_get_str('wlstat_display_key') || Irssi::settings_get_str('wlstat_display_nokey') ) : Irssi::settings_get_str('wlstat_display_nokey') ; my $add = expand($display, C => ir_fe($name), N => $number, Q => ir_fe($keymap{$number}), H => $hilight, S => '}{sb_background}' ); #$temp =~ s/\{\S+?(?:\s(.*?))?\}/$1/g; #$temp =~ s/\\\\\\\\/\\/g; # XXX I'm actually guessing here, someone point me to docs please $actString->[$line] = '' unless defined $actString->[$line]; # XXX how can I check whether the content still fits in the bar? this would allow # XXX wlstatus to reside on a statusbar together with other items... if (sb_length(ir_escape($actString->[$line] . $add)) >= $width) { # XXX doesn't correctly handle utf-8 multibyte ... help !!? $actString->[$line] .= ' ' x ($width - sb_length(ir_escape($actString->[$line]))); $line++; } $actString->[$line] .= $add . $separator; # XXX if I use these prints, output layout gets screwed up... why ? #Irssi::print("line $line: ".$actString->[$line]); #Irssi::print("temp $line: ".$temp); } # XXX the Irssi::print statements lead to the MOST WEIRD results # e.g.: the loop gets executed TWICE for p > 0 ?!? for (my $p = 0; $p < @$actString; $p++) { # wrap each line in {sb }, escape it properly, etc. my $x = $actString->[$p]; $x =~ s/\Q$separator\E([ ]*)$/$1/; #Irssi::print("[$p]".'current:'.join'.',split//,sb_strip(ir_escape($x,0))); #Irssi::print("assumed length before:".sb_length(ir_escape($x,0))); $x = "{sb $x}"; #Irssi::print("[$p]".'new:'.join'.',split//,sb_expand(ir_escape($x,0))); #Irssi::print("[$p]".'new:'.join'.',split//,ir_escape($x,0)); #Irssi::print("assumed length after:".sb_length(ir_escape($x,0))); $x = ir_escape($x); #Irssi::print("[$p]".'REALnew:'.join'.',split//,sb_strip($x)); $actString->[$p] = $x; # XXX any Irssi::print debug statement leads to SEGFAULT (sometimes) - why ? } #Irssi::print("remake [ $xx ] finished"); } sub wlstatHasChanged () { $globTime = undef; my $temp = Irssi::settings_get_str('wlstat_placement').Irssi::settings_get_int('wlstat_position'); if ($temp ne $resetNeeded) { wlreset(); return; } #Irssi::print("wlstat has changed, calls to remake so far: $callcount"); $needRemake = 1; #remake(); if ( ($needRemake and Irssi::settings_get_bool('wlstat_all_disable')) or (!Irssi::settings_get_bool('wlstat_all_disable') and $currentLines < 1) ) { $needRemake = undef; remake(); } # XXX Irssi crashes if I try to do this without timer, why ? What's the minimum delay I need to use in the timer ? Irssi::timeout_add_once(100, 'syncLines', undef); for (keys %statusbars) { Irssi::statusbar_items_redraw("wlstat$_"); } } sub eventChanged () { # Implement a change queue/blocker -.-) if (defined $globTime) { Irssi::timeout_remove($globTime); } # delay the update further $globTime = Irssi::timeout_add_once(10, 'wlstatHasChanged', undef); } #$needRemake = 1; sub resizeTerm () { Irssi::timeout_add_once(100, 'eventChanged', undef); } Irssi::settings_add_str('wlstat', 'wlstat_display_nokey', '[$N]$H$C$S'); Irssi::settings_add_str('wlstat', 'wlstat_display_key', '[$Q=$N]$H$C$S'); Irssi::settings_add_str('wlstat', 'wlstat_separator', "\\ "); Irssi::settings_add_int('wlstat', 'wlstat_hide_data', 0); Irssi::settings_add_int('wlstat', 'wlstat_maxlines', 9); Irssi::settings_add_str('wlstat', 'wlstat_sort', 'refnum'); Irssi::settings_add_str('wlstat', 'wlstat_placement', 'bottom'); Irssi::settings_add_int('wlstat', 'wlstat_position', 0); Irssi::settings_add_bool('wlstat', 'wlstat_all_disable', 0); # remove old statusbars my %killBar; sub get_old_status { my ($textDest, $cont, $cont_stripped) = @_; if ($textDest->{'level'} == 524288 and $textDest->{'target'} eq '' and !defined($textDest->{'server'})) { if ($cont_stripped =~ m/^wl(\d+)\s/) { $killBar{$1} = {}; } Irssi::signal_stop(); } } sub killOldStatus { %killBar = (); Irssi::signal_add_first('print text' => 'get_old_status'); Irssi::command('statusbar'); Irssi::signal_remove('print text' => 'get_old_status'); remove_statusbar(keys %killBar); } #killOldStatus(); sub wlreset { $actString = []; $currentLines = 0; # 1; # mhmmmm .. we actually enable one line down there so let's try this. $resetNeeded = Irssi::settings_get_str('wlstat_placement').Irssi::settings_get_int('wlstat_position'); #update_keymap(); killOldStatus(); # Register statusbar #add_statusbar(0); #Irssi::command('statusbar wl0 enable'); resizeTerm(); } wlreset(); my $Unload; sub unload ($$$) { $Unload = 1; Irssi::timeout_add_once(10, sub { $Unload = undef; }, undef); # pretend we didn't do anything ASAP } Irssi::signal_add_first('gui exit' => sub { $Unload = undef; }); # last try to catch a sigsegv sub UNLOAD { if ($Unload) { # this might well crash Irssi... try /eval /script unload someotherscript ; /quit (= SEGFAULT !) $actString = ['']; # syncLines(); # XXX Irssi crashes when trying to disable all statusbars ? killOldStatus(); } } sub addPrintTextHook { # update on print text return if $_[0]->{'level'} == 262144 and $_[0]->{'target'} eq '' and !defined($_[0]->{'server'}); if (Irssi::settings_get_str('wlstat_sort') =~ /^[-!]?last_line$/) { Irssi::timeout_add_once(100, 'eventChanged', undef); } } #sub _x { my ($x, $y) = @_; ($x, sub { Irssi::print('-->signal '.$x); eval "$y();"; }) } #sub _x { @_ } Irssi::signal_add_first( 'command script unload' => 'unload' ); Irssi::signal_add_last({ 'setup changed' => 'eventChanged', 'print text' => 'addPrintTextHook', 'terminal resized' => 'resizeTerm', 'setup reread' => 'wlreset', 'window hilight' => 'eventChanged', }); Irssi::signal_add({ 'window created' => 'eventChanged', 'window destroyed' => 'eventChanged', 'window name changed' => 'eventChanged', 'window refnum changed' => 'eventChanged', 'window changed' => 'eventChanged', 'window changed automatic' => 'eventChanged', }); #Irssi::signal_add('nick mode changed', 'chanactHasChanged'); # relicts ############### ### # # Changelog # # 0.5a # - add setting to also hide the last statusbar if empty (wlstat_all_disable) # - reverted to old utf8 code to also calculate broken utf8 length correctly # - simplified dealing with statusbars in wlreset # # 0.4d # - fixed order of disabling statusbars # - several attempts at special chars, without any real success # and much more weird new bugs caused by this # - setting to specify sort order # - reduced timeout values # - added wlstat_hide_data for Geert Hauwaerts ( geert@irssi.org ) :) # - make it so the dynamic sub is actually deleted # - fix a bug with removing of the last separator # - take into consideration parse_special # # 0.3b # - automatically kill old statusbars # - reset on /reload # - position/placement settings # # 0.2 # - automated retrieval of key bindings (thanks grep.pl authors) # - improved removing of statusbars # - got rid of status chop # # 0.1 # - rewritten to suit my needs # - based on chanact 0.5.5 irssi-scripts-20131030/scripts/cron.pl0000644000000000000000000002031312143537176014446 0ustar # # Short help/usage: # /jobadd hour minute day_of_month month day_of_week command # Possibile switches for jobadd: # -disabled # -server # - # /jobs [-v] # /jobdel [-finished] | job_number # /jobdisable job_number # /jobenable job_number # /jobssave # /jobsload # # Examples of usage: # /jobadd 17 45 * * * /echo This will be executed at 17:45 # /jobadd -5 17 45 * * * /echo The same as above but only 5 times # /jobadd * 05 * * * /echo Execute this every hour 5 minutes after the hour # /jobadd */6 0 * * * /echo Execute at 0:0, 6:0, 12:0, 18:0 # /jobadd * */30,45 * * * /echo Execute every hour at 00, 30, 45 minute # /jobadd * 1-15/5 * * * /echo at 1,6,11 # # The servertag in -server usually is name from /ircnet, but # should work with servers not in any ircnet (hmm probably) # # The format was taken from crontab(5). # The only differences are: # 1) hour field is before minute field (why the hell minute is first in # crontab?). But this could be changed in final version. # 2) day of week is 0..6. 0 is Sunday, 1 is Monday, 6 is Saturday. # 7 is illegal value while in crontab it's the same as 0 (i.e. Sunday). # I might change this, depends on demand. # 3) you can't use names in month and day of week. You must use numbers # Type 'man 5 crontab' to know more about allowed values etc. # # TODO: # - add full (or almost full) cron functionality # - probably more efficient checking for job in timeout # - imput data validation # ? should we remember if the server was given with -server # # Changelog: # 0.11 (2004.12.12) # Job are executed exactly at the time (+- 1s), not up to 59s late # # 0.10 (2003.03.25): # Added - to execute job only times. Initial patch from # Marian Schubert (M dot Schubert at sh dot cvut dot cz) # # 0.9: # Bugfix: according to crontab(5) when both DoM and DoW are restricted # it's enough to only one of fields to match # # 0.8: # Added -disabled to /jobadd # Added jobs loading and saving to file # # 0.7: # Bugfixes. Should work now ;) # # 0.6: # Added month, day of month, day of week # # 0.5: # Initial testing release # use Irssi; use strict; use vars qw($VERSION %IRSSI); $VERSION = "0.11"; %IRSSI = ( authors => 'Piotr Krukowiecki', contact => 'piotr \at/ krukowiecki /dot\ net', name => 'cron aka jobs', description => 'cron implementation, allows to execute commands at given interval/time', license => 'GNU GPLv2', changed => '2004.12.12', url => 'http://www.krukowiecki.net/code/irssi/' ); my @jobs = (); my $seconds = (gmtime(time()))[0]; my $timeout_tag; my $stop_timeout_tag; if ($seconds > 0) { $stop_timeout_tag = Irssi::timeout_add((60-$seconds)*1000, sub { Irssi::timeout_remove($stop_timeout_tag); $timeout_tag = Irssi::timeout_add(60000, 'sig_timeout', undef); }, undef); } else { $timeout_tag = Irssi::timeout_add(60000, 'sig_timeout', undef); } my $savefile = Irssi::get_irssi_dir() . "/cron.save"; # First arg - current hour or minute. # Second arg - hour or minute specyfications. sub time_matches($$) { my ($current, $spec) = @_; foreach my $h (split(/,/, $spec)) { if ($h =~ /(.*)\/(\d+)/) { # */number or number-number/number my $step = $2; if ($1 eq '*') { # */number return 1 if ($current % $step == 0); next; } if ($1 =~ /(\d+)-(\d+)/) { # number-number/number my ($from, $to) = ($1, $2); next if ($current < $from or $current > $to); # not in range my $current = $current; if ($from > 0) { # shift time $to -= $from; $current -= $from; $from = 0; } return 1 if ($current % $step == 0); next; } next; } if ($h =~ /(\d+)-(\d+)/) { # number-number return 1 if ($current >= $1 and $current <= $2); next } return 1 if ($h eq '*' or $h == $current); # '*' or exact hour } return 0; } sub sig_timeout { my $ctime = time(); my ($cminute, $chour, $cdom, $cmonth, $cdow) = (localtime($ctime))[1,2,3,4,6]; $cmonth += 1; foreach my $job (@jobs) { next if ($job->{'disabled'}); next if ($job->{'repeats'} == 0); next if (not time_matches($chour, $job->{'hour'})); next if (not time_matches($cminute, $job->{'minute'})); next if (not time_matches($cmonth, $job->{'month'})); if ($job->{'dom'} ne '*' and $job->{'dow'} ne '*') { next if (not (time_matches($cdom, $job->{'dom'}) or time_matches($cdow, $job->{'dow'}))); } else { next if (not time_matches($cdom, $job->{'dom'})); next if (not time_matches($cdow, $job->{'dow'})); } my $server = Irssi::server_find_tag($job->{'server'}); if (!$server) { Irssi::print("cron.pl: could not find server '$job->{server}'"); next; } $server->command($job->{'commands'}); if ($job->{'repeats'} > 0) { $job->{'repeats'} -= 1; } } } sub cmd_jobs { my ($data, $server, $channel) = @_; my $verbose = ($data eq '-v'); Irssi::print("Current Jobs:"); foreach (0 .. $#jobs) { my $repeats = $jobs[$_]{'repeats'}; my $msg = "$_) "; if (!$verbose) { next if ($repeats == 0); $msg .= "-$repeats " if ($repeats != -1); } else { $msg .= "-$repeats " if ($repeats != -1); } $msg .= ($jobs[$_]{'disabled'}?"-disabled ":"") ."-server $jobs[$_]{server} " ."$jobs[$_]{hour} $jobs[$_]{minute} $jobs[$_]{dom} " ."$jobs[$_]{month} $jobs[$_]{dow} " ."$jobs[$_]{commands}"; Irssi::print($msg); } Irssi::print("End of List"); } # /jobdel job_number sub cmd_jobdel { my ($data, $server, $channel) = @_; if ($data eq "-finished") { foreach (reverse(0 .. $#jobs)) { if ($jobs[$_]{'repeats'} == 0) { splice(@jobs, $_, 1); Irssi::print("Removed Job #$_"); } } return; } elsif ($data !~ /\d+/ or $data < 0 or $data > $#jobs) { Irssi::print("Bad Job Number"); return; } splice(@jobs, $data, 1); Irssi::print("Removed Job #$data"); } # /jobdisable job_number sub cmd_jobdisable { my ($data, $server, $channel) = @_; if ($data < 0 || $data > $#jobs) { Irssi::print("Bad Job Number"); return; } $jobs[$data]{'disabled'} = 1; Irssi::print("Disabled job number $data"); } # /jobenable job_number sub cmd_jobenable { my ($data, $server, $channel) = @_; if ($data < 0 || $data > $#jobs) { Irssi::print("Bad Job Number"); return; } $jobs[$data]{'disabled'} = 0; Irssi::print("Enabled job number $data"); } # /jobadd [-X] [-disabled] [-server servertag] hour minute day_of_month month day_of_week command sub cmd_jobadd { my ($data, $server, $channel) = @_; $server = $server->{tag}; my $disabled = 0; my $repeats = -1; while ($data =~ /^\s*-/) { if ($data =~ s/^\s*-disabled\s+//) { $disabled = 1; next; } if ($data =~ s/^\s*-(\d+)\s+//) { $repeats = $1; next; } my $comm; ($comm, $server, $data) = split(' ', $data, 3); if ($comm ne '-server') { Irssi::print("Bad switch: '$comm'"); return; } } my ($hour, $minute, $dom, $month, $dow, $commands) = split(' ', $data, 6); push (@jobs, { 'hour' => $hour, 'minute' => $minute, 'dom' => $dom, 'month' => $month, 'dow' => $dow, 'server' => $server, 'commands' => $commands, 'disabled' => $disabled, 'repeats' => $repeats } ); Irssi::print("Job added"); } sub cmd_jobssave { if (not open (FILE, "> $savefile")) { Irssi::print("Could not open file '$savefile': $!"); return; } foreach (0 .. $#jobs) { next if ($jobs[$_]->{'repeats'} == 0); # don't save finished jobs print FILE ($jobs[$_]->{'repeats'}>0 ? "-$jobs[$_]->{'repeats'} " : "") . ($jobs[$_]{'disabled'}?"-disabled ":"") ."-server $jobs[$_]{server} " ."$jobs[$_]{hour} $jobs[$_]{minute} $jobs[$_]{dom} " ."$jobs[$_]{month} $jobs[$_]{dow} " ."$jobs[$_]{commands}\n"; } close FILE; Irssi::print("Jobs saved"); } sub cmd_jobsload { if (not open (FILE, "$savefile")) { Irssi::print("Could not open file '$savefile': $!"); return; } @jobs = (); while () { chomp; cmd_jobadd($_, undef, undef); } close FILE; Irssi::print("Jobs loaded"); } Irssi::command_bind('jobs', 'cmd_jobs', 'Cron'); Irssi::command_bind('jobadd', 'cmd_jobadd', 'Cron'); Irssi::command_bind('jobdel', 'cmd_jobdel', 'Cron'); Irssi::command_bind('jobdisable', 'cmd_jobdisable', 'Cron'); Irssi::command_bind('jobenable', 'cmd_jobenable', 'Cron'); Irssi::command_bind('jobssave', 'cmd_jobssave', 'Cron'); Irssi::command_bind('jobsload', 'cmd_jobsload', 'Cron'); # vim:noexpandtab:ts=4 irssi-scripts-20131030/scripts/showhilight.pl0000644000000000000000000000176312143537176016046 0ustar # Print hilighted messages with MSGLEVEL_PUBLIC to active window # for irssi 0.7.99 by Pawe³ 'Styx' Chuchma³a based on hilightwin.pl by Timo Sirainen use Irssi; use vars qw($VERSION %IRSSI); $VERSION = "0.1"; %IRSSI = ( authors => "Pawe³ \'Styx\' Chuchma³a", contact => "styx\@irc.pl", name => "showhilight", description => "Show hilight messages in active window", license => "GNU GPLv2", changed => "Fri Jun 28 11:09:42 CET 2002" ); sub sig_printtext { my ($dest, $text, $stripped) = @_; my $window = Irssi::active_win(); if (($dest->{level} & MSGLEVEL_HILIGHT) && ($dest->{level} & MSGLEVEL_PUBLIC) && ($window->{refnum} != $dest->{window}->{refnum}) && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0) { $text = $dest->{target}.":%K[".Irssi::settings_get_str(hilight_color).$dest->{window}->{refnum}."%K]:".$text; $window->print($text, MSGLEVEL_CLIENTCRAP); } } Irssi::signal_add('print text', 'sig_printtext'); irssi-scripts-20131030/scripts/sysinfo_dg.pl0000644000000000000000000002172212143537176015656 0ustar #!/usr/bin/perl use Irssi 20011210.0250 (); $VERSION = "1.2"; %IRSSI = ( authors => 'David Leadbeater', contact => 'dgl@dgl.cx', name => 'sysinfo-dg', description => 'Adds a /sysinfo command which prints system information (linux only).', license => 'GNU GPLv2 or later', url => 'http://irssi.dgl.yi.org/', ); #This script is mostly my own work but some ideas where taken from /sinfo by #Laurens Buhler and Alain van Acker. Please leave this credit in the script and #if you edit it and think the change is worthwhile tell me and i may add it into #the script and credit you use strict; use vars qw/$colour $graphs $graphs2 $colour2 $style/; Irssi::command_bind("sysinfo","sysinfo"); sub sysinfo{ my @options = split(/ /,$_[0]); my %info; my($hostname,$uname,$procs) = basicinfo(); my($distro) = distro(); my($uptime,$users,$loadavg) = uptime(); my($memsize,$memfree) = meminfo(); my($swapsize,$swapfree) = swapinfo(); my($cpumodel,$cpumhz,$cpucache,$bogomips) = cpuinfo(); my %netinfo = netinfo(); my($disktotal,$diskused,$hddtype) = df(); my($videocard,$ethernet) = pciinfo(); my($screenres,$screendepth); ($screenres,$screendepth) = screenres() if $ENV{DISPLAY}; ($colour,$graphs,$graphs2,$colour2,$style) = parseoptions(\%netinfo,@options); %info = ( 'os' => "$uname - $distro", 'up' => $uptime, 'cpu' => "$cpumodel, $cpumhz MHz ($bogomips bogomips)", 'cache' => $cpucache, 'mem' => ($memsize-$memfree) . "/$memsize MB (" . percent(($memsize-$memfree),$memsize) . ")", 'host' => $hostname, 'users' => $users, 'load' => $loadavg, 'procs' => $procs, 'swap' => ($swapsize-$swapfree) . "/$swapsize MB (" . percent(($swapsize-$swapfree),$swapsize) . ")", 'disk' => "$diskused/$disktotal MB (" . percent($diskused,$disktotal) . ") ($hddtype)", 'video' => "$videocard at $screenres ($screendepth bits)", 'ethernet' => $ethernet, ); for(keys %netinfo){ $info{$_} = "in: $netinfo{$_}{in} MB, out: $netinfo{$_}{out} MB"; } my $tmp; for(split(/ /,$style)){ $tmp .= ircbit($_,$info{$_}) . " "; } $tmp =~ s/ $//; Irssi::active_win()->command('say ' . $tmp); ($colour,$graphs,$graphs2,$colour2,$style) = undef; } sub parseoptions{ my($netinfo,@options) = @_; my $tmp = shift(@options) if $options[0] =~ /^\-/; $tmp =~ s/^\-//; for(split //,$tmp){ if($_ eq "c"){ $tmp =~ /c(\d+)/; $colour = $1; if(!$colour){ $colour = 3; } }elsif($_ eq "g"){ $tmp =~ /g(\d+)/; $graphs = $1; if(!$graphs){ $graphs = 9; } }elsif($_ eq "G"){ $tmp =~ /G(\d+)/; $graphs2 = $1; }elsif($_ eq "C"){ $tmp =~ /C(\d+)/; $colour2 = $1; } } if(!defined $colour2 && $colour){ $colour2 = 15; } if(defined $graphs && !defined $graphs2){ $graphs2 = 3; } # We got the names on the command line if($options[1]){ $style = join(" ",@options); # style name }elsif($options[0]){ if($options[0] eq "std"){ $style = "os up cpu mem video"; }elsif($options[0] eq "bigger"){ $style = "os up cpu cache mem load procs disk video"; }elsif($options[0] eq "full"){ $style = "host os up cpu cache mem users load procs swap disk video ethernet ".join(" ",keys %{$netinfo}); }elsif($options[0] eq "net"){ $style = join(" ",keys %{$netinfo}); }elsif($options[0] eq "uptime"){ $style = "os up"; }elsif($options[0] eq "use"){ $style = "mem swap disk"; } }else{ # no input - default $style = "os up cpu mem video"; } return($colour,$graphs,$graphs2,$colour2,$style); } sub ircbit{ my($name,$text) = @_; $name = " " . $name if $name =~ /^\d/; $text = " " . $text if $text =~ /^\d/; if($colour){ return "$colour$name$colour2\[$text$colour2\]"; }else{ return "$name\[$text\]"; } } sub percent{ my $percent = sprintf("%.1f",(($_[0]/$_[1])*100)); if($graphs){ my $tmp = "["; for(1..10){ if($_ > sprintf("%.0f",$percent / 10)){ $tmp .= "-" if !defined $colour; $tmp .= "$graphs2-" if defined $colour; }else{ $tmp .= "|" if !defined $colour; $tmp .= "$graphs|" if defined $colour; } } $tmp .= "]"; return $percent."% ".$tmp; } return $percent."%"; } sub uptime{ my $uptimeinfo = `uptime`; if ($uptimeinfo =~ /^\s+(\d+:\d+\w+|\d+:\d+:\d+)\s+up\s+(\d+)\s+day.?\W\s+(\d+):(\d+)\W\s+(\d+)\s+\w+\W\s+\w+\s+\w+\W\s+(\d+).(\d+)/igx) { return("$2 days, $3 hours, $4 minutes", $5, "$6.$7"); }elsif ($uptimeinfo =~ /^\s+(\d+:\d+\w+|\d+:\d+:\d+)\s+up+\s+(\d+):(\d+)\W\s+(\d+)\s+\w+\W\s+\w+\s+\w+\W\s+(\d+).(\d+)/igx) { return("$2 hours, $3 minutes", $4, "$5.$6"); }elsif ($uptimeinfo =~ /^\s+(\d+:\d+\w+|\d+:\d+:\d+)\s+up\s+(\d+)\s+day.?\W\s+(\d+)\s+min\W\s+(\d+)\s+\w+\W\s+\w+\s+\w+\W\s+(\d+).(\d+)/igx) { return("$2 days, $3 minutes", $4, "$5.$6"); }elsif ($uptimeinfo =~ /^\s+(\d+:\d+\w+|\d+:\d+:\d+)\s+up+\s+(\d+)\s+min\W\s+(\d+)\s+\w+\W\s+\w+\s+\w+\W\s+(\d+).(\d+)/igx) { return("$2 minutes", $3, "$4.$5"); } return undef; } sub meminfo{ my($memsize,$memfree); open(MEMINFO, "/proc/meminfo") or return undef; while(){ chomp; if(/^MemTotal:\s+(\d+)/){ $memsize = sprintf("%.2f",$1/1024); }elsif(/^MemFree:\s+(\d+)/){ $memfree = sprintf("%.2f",$1/1024); } } close(MEMINFO); return($memsize,$memfree); } sub swapinfo{ my($swapsize,$swapused); open(SWAPINFO, "/proc/swaps"); while(){ chomp; next if !/^\//; /\S+\s+\S+\s+(\S+)\s+(\S+)/; $swapsize += $1; $swapused += $2; } close(SWAPINFO); my $swapfree = sprintf("%.2f",($swapsize - $swapused) / 1024); $swapsize = sprintf("%.2f", $swapsize / 1024); return($swapsize,$swapfree); } sub netinfo{ my(%netinfo); open(NETINFO, "/proc/net/dev") or return undef; while(){ chomp; next if /^(\s+)?(Inter|face|lo)/; /^\s*(\w+):\s*(\d+)\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)\s+/; $netinfo{$1}{in} = sprintf("%.2f",$2 / 1048576); $netinfo{$1}{out} = sprintf("%.2f",$3 / 1048576); } close(NETINFO); return %netinfo; } sub distro{ my $distro; if(-f "/etc/coas"){ $distro = firstline("/etc/coas"); }elsif(-f "/etc/environment.corel"){ $distro = firstline("/etc/environment.corel"); }elsif(-f "/etc/debian_version"){ $distro = "Debian ".firstline("/etc/debian_version"); }elsif(-f "/etc/mandrake-release"){ $distro = firstline("/etc/mandrake-release"); }elsif(-f "/etc/SuSE-release"){ $distro = firstline("/etc/SuSE-release"); }elsif(-f "/etc/turbolinux-release"){ $distro = firstline("/etc/turbolinux-release"); }elsif(-f "/etc/slackware-release"){ $distro = firstline("/etc/slackware-release"); }elsif(-f "/etc/redhat-release"){ $distro = firstline("/etc/redhat-release"); } return $distro; } sub df{ my($disktotal,$diskused,$mainhd); for(`df`){ chomp; next if !/^\/dev\/\S+/; next if /(cd|cdrom|fd|floppy)/; /^(\S+)\s+(\S+)\s+(\S+)/; $mainhd = $1 if !defined $mainhd; next if not defined $1 or not defined $2; $disktotal += $2; $diskused += $3; } $disktotal = sprintf("%.2f",$disktotal / 1024); $diskused = sprintf("%.2f",$diskused / 1024); $mainhd =~ s/\/dev\/([a-z]+)\d+/$1/; my $hddtype = firstline("/proc/ide/$mainhd/model"); return($disktotal,$diskused,$hddtype); } sub basicinfo{ my($hostname,$sysinfo,$procs); chomp($hostname = `hostname`); chomp($sysinfo = `uname -sr`); opendir(PROC, "/proc"); $procs = scalar grep(/^\d/,readdir PROC); return($hostname,$sysinfo,$procs); } sub cpuinfo{ my($cpumodel,$cpusmp,$cpumhz,$cpucache,$bogomips); open(CPUINFO, "/proc/cpuinfo") or return undef; while(){ if(/^model name\s+\:\s+(.*?)$/){ if(defined $cpumodel){ if(defined $cpusmp){ $cpusmp++; }else{ $cpusmp=2; } }else{ $cpumodel = $1; } }elsif(/^cpu MHz\s+:\s+([\d\.]*)/){ $cpumhz = $1; }elsif(/^cache size\s+:\s+(.*)/){ $cpucache = $1; }elsif(/^bogomips\s+:\s+([\d\.]*)/){ $bogomips += $1; } } $cpumodel .= " SMP ($cpusmp processors)" if defined $cpusmp; return($cpumodel,$cpumhz,$cpucache,$bogomips); } sub pciinfo{ my($videocard,$ethernet); open(PCI, "/proc/pci") or return undef; while(){ chomp; if(/VGA compatible controller: (.*?)$/){ $videocard .= "${1}+ "; }elsif(/Ethernet controller: (.*?)$/){ $ethernet = $1; } } close(PCI); $videocard =~ s/\+ $//; return($videocard,$ethernet); } sub screenres{ my ($res,$depth); for(`xdpyinfo`){ if(/\s+dimensions:\s+(\S+)/){ $res = $1; }elsif(/\s+depth:\s+(\S+)/){ $depth = $1; } } return($res,$depth); } sub firstline{ my $file = shift; open(FILE, "$file") or return undef; chomp(my $line = ); close(FILE); return $line; } irssi-scripts-20131030/scripts/randaway.pl0000644000000000000000000000634412143537176015323 0ustar #!/usr/bin/perl -w # $Id: randaway.pl,v 1.12 2003/01/10 10:47:04 lkarsten Exp lkarsten $ # Irssi script for random away-messages. # # adds /raway, /awayadd, /awayreasons and /awayreread. # # Based on simular script written by c0ffee. # original version made public in march 2002. # # changelog: # sep/02 - kuba wszolek (hipis@linux.balta.pl) reported problems with multiple # servers in v1.8 .. proposed fix is imported. # jan/03 - Wouter Coekaerts (wouter@coekaerts.be) provided fix using # get_irssi_dir() instead of $ENV[]. imported. # use Irssi 20011116; use Irssi::Irc; $VERSION = '1.13'; %IRSSI = ( authors => "Lasse Karstensen", contact => "lkarsten\@stud.ntnu.no", name => "randaway.pl", description => "Random away-messages", license => "Public Domain", url => "http://www.stud.ntnu.no/~lkarsten/irssi/", ); # file to read random reasons from. It should contain one # reason at each line, empty lines and lines starting with # is # skipped. $reasonfile = Irssi::get_irssi_dir() . "/awayreasons"; my @awayreasons; sub readreasons { undef @awayreasons; if (-f $reasonfile) { Irssi::print("=> Trying to read awayreasons from $reasonfile"); open F, $reasonfile; # this actually makes the while() work like a while and not # like a read() .. ie, stopping at each \n. local $/ = "\n"; while () { $reason = $_; # remove any naughty linefeeds. chomp($reason); # skips reason if it's an empty line or line starts with # if ($reason =~ /^$/ ) { next; } if ($reason =~ /^#/ ) { next; } Irssi::print("\"$reason\""); # adds to array. push(@awayreasons, $reason); } close F; Irssi::print("=> Read " . scalar(@awayreasons) . " reasons."); } else { # some default away-reasons. Irssi::print("Unable to find $reasonfile, no reasons loaded."); push(@awayreasons, "i\'m pretty lame!"); push(@awayreasons, "i think i forgot something!"); }; } sub cmd_away { # only do our magic if we're not away already. if (Irssi::active_server()->{usermode_away} == 0) { my ($reason) = @_; # using supplied reason if .. eh, supplied, else find a random one if not. if (!$reason) { $reason = $awayreasons[rand @awayreasons]; } Irssi::print("awayreason used: $reason"); my $server = Irssi::servers(); $server->command('AWAY '.$reason); } else { Irssi::print("you're already away"); } } sub add_reason { my ($reason) = @_; if (!$reason) { Irssi::print("Refusing to add empty reason."); } else { chomp($reason); # adding to current environment. push(@awayreasons, $reason); # and also saving it for later. open(F, ">> $reasonsfile"); print F $reason; close F; Irssi::print("Added: $reason"); } } sub reasons { Irssi::print("Listing current awayreasons"); foreach $var (@awayreasons) { Irssi::print("=> \"$var\""); } } # -- main program -- readreasons(); Irssi::command_bind('raway', 'cmd_away'); Irssi::command_bind('awayreread', 'readreasons'); Irssi::command_bind('awayadd', 'add_reason'); Irssi::command_bind('awayreasons', 'reasons'); # -- end of script -- irssi-scripts-20131030/scripts/history_search.pl0000644000000000000000000001061512143537176016537 0ustar # Search within your typed history as you type (like ctrl-R in bash) # Usage: # * First do: /bind ^R /history_search # * Then type ctrl-R and type what you're searching for # * Optionally, you can bind something to "/history_search -forward" to go forward in the results # Copyright 2007-2009 Wouter Coekaerts # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA use strict; use Irssi 20070804; use Irssi::TextUI; use vars qw($VERSION %IRSSI); $VERSION = '2.0'; %IRSSI = ( authors => 'Wouter Coekaerts', contact => 'coekie@irssi.org', name => 'history_search', description => 'Search within your typed history as you type (like ctrl-R in bash)', license => 'GPLv2 or later', url => 'http://wouter.coekaerts.be/irssi/', changed => '17/01/09' ); # is the searching enabled? my $enabled = 0; # the typed text (the query) last time a key was pressed my $prev_typed; # the position in the input of where the typed text started. # everything before it is not typed by the user but added by this script as part of the result my $prev_startpos; # the current list of matches my @matches; # at what place are we in @matches? my $current_match_index; Irssi::command_bind('history_search', sub { my ($data, $server, $item) = @_; if ($data !~ /^ *(-forward)? *$/) { Irssi::print("history_search: Unknown arguments: $data"); return; } my $forward = $1 eq '-forward'; if (! $enabled) { $enabled = 1; $prev_typed = ''; $prev_startpos = 0; @matches = (); $current_match_index = -1; } else { if ($forward) { if ($current_match_index + 1 < scalar(@matches)) { $current_match_index++; } } else { # backwards if ($current_match_index > 0) { $current_match_index--; } } } }); Irssi::signal_add_last 'gui key pressed' => sub { my ($key) = @_; if ($key == 10 || $key == 27) { # enter or escape $enabled = 0; } return unless $enabled; # get the content of the input line my $prompt = Irssi::parse_special('$L'); my $pos = Irssi::gui_input_get_pos(); # stop if the cursor is before the position where the typing started (e.g. if user pressed backspace more than he typed characters) if ($pos < $prev_startpos) { $enabled = 0; return; } # get the part of the input line that the user typed (strip the part before and after which this script added) my $typed = substr($prompt, $prev_startpos, ($pos-$prev_startpos)); if ($typed ne $prev_typed) { # something changed # find matches find_matches($typed); # start searching from the end again $current_match_index = scalar(@matches) - 1; } # if nothing was found, just show what the user typed # else, show the current match my $result = ($current_match_index == -1) ? $typed : $matches[$current_match_index]; # update the input line my $startpos = index(lc($result), lc($typed)); Irssi::gui_input_set($result); Irssi::gui_input_set_pos($startpos + length($typed)); # remember for next time $prev_typed = $typed; $prev_startpos = $startpos; }; # find matches for the given user-typed text, and put it in @matches sub find_matches($) { my ($typed) = @_; if (Irssi::version() > 20090117) { $typed = lc($typed); my @history; if ($prev_typed ne '' && index($typed, lc($prev_typed)) != -1) { # previous typed plus more @history = @matches; # only search in previous results } else { @history = Irssi::active_win->get_history_lines(); } @matches = (); for my $history_line (@history) { my $startpos = index(lc($history_line), $typed); if ($startpos != -1) { push @matches, $history_line; } } } else { # older irssi version, can only get the last match @matches = (); my $last_match = Irssi::parse_special('$!' . $typed . '!'); if ($last_match ne '') { push @matches, $last_match; } } } irssi-scripts-20131030/scripts/watch.pl0000644000000000000000000000753512143537176014626 0ustar # Watch script para irssi # watch script consiste en un pequeño script que interpreta # este novedoso sistema de notify que nos evita la tarea de # tener que comprobar cada X tiempo si alguien de nuestro notify # esta en el irc, este script solamente podra ser usado en redes # que lo permitan, como por ejemplo irc-hispano. $VERSION = '1.0'; %IRSSI = ( authors => 'ThEbUtChE', contact => 'thebutche@interec.org', name => 'Watch script', description => 'Uso del comando watch para irssi.', license => 'BSD', url => 'http://www.nebulosa.org', changed => 'viernes, 17 de enero de 2003, 03:19:15 CET', bugs => 'ninguno' ); use Irssi; use Irssi::Irc; use POSIX qw(floor); sub watch_list { my($file) = Irssi::get_irssi_dir."/watch"; my($nick); local(*FILE); open FILE, "< $file"; while () { @nick = split; Irssi::print "Notify \002@nick[0]\002"; } close FILE; } sub esta_notify { my ($ni) = @_; my($file) = Irssi::get_irssi_dir."/watch"; my($nick); local(*FILE); open FILE, "< $file"; while () { @nick = split; if (@nick[0] eq $ni) { return 1; } } close FILE; return 0; } sub watch_add { my ($nick) = @_; my($file) = Irssi::get_irssi_dir."/watch"; local(*FILE); if ($nick eq "") { Irssi::print "Debes decir un nick a incluir en la lista."; return; } elsif (esta_notify($nick)) { Irssi::print "El nick ya esta en el notify."; return; } open FILE, ">> $file"; print FILE join("\t","$nick\n"); close FILE; Irssi::print "El nick $nick ha sido metido en el notify"; Irssi::active_win()->command("quote watch +$nick"); } sub watch_del { my ($ni) = @_; my($file) = Irssi::get_irssi_dir."/watch"; my($file2) = Irssi::get_irssi_dir."/watch2"; local(*FILE); local(*FILE2); if ($ni eq "") { Irssi::print "Debes decir un nick a borrar de la lista."; return; } elsif (!esta_notify($ni)) { Irssi::print "El nick no esta en el notify."; return; } open FILE2, "> $file2"; print FILE2 ""; close FILE2; open FILE, "< $file"; open FILE2, ">> $file2"; while () { @nick = split; if (@nick[0] eq $ni) { } else { print FILE2 join("\t","@nick[0]\n"); } } close FILE; close FILE2; open FILE, "> $file"; print FILE ""; close FILE; open FILE, ">> $file"; open FILE2, "< $file2"; while () { @nick = split; print FILE join("\t","@nick[0]\n"); } close FILE; close FILE2; Irssi::active_win()->command("quote watch -$ni"); Irssi::print "Usuario \002$ni\002 Borrado de la lista de notify"; } sub watch_list_online { Irssi::active_win()->command("quote watch l"); } sub watch { my ($arg) = @_; my ($cmd, $nick) = split(/ /, $arg); if ($cmd eq "list") { watch_list(); } elsif ($cmd eq "add") { watch_add($nick); } elsif ($cmd eq "del") { watch_del($nick); } else { watch_list_online(); } } sub mete_lista { my($file) = Irssi::get_irssi_dir."/watch"; my($nick); local(*FILE); my $ret; open FILE, "< $file"; while () { @nick = split; $ret .= "+@nick[0],"; } chop $ret; Irssi::active_win()->command("quote watch $ret"); close FILE; } sub event_is_online { my ($server, $data) = @_; my ($me, $nick, $ident, $host) = split(/ /, $data); Irssi::print "\002$nick\002 \0034[\003$ident\@$host\0034]\003 has joined to IRC"; } sub event_is_offline { my ($server, $data) = @_; my ($me, $nick) = split(/ /, $data); Irssi::print "\002$nick\002 has left IRC"; } sub null { } Irssi::command_bind('watch', 'watch'); Irssi::signal_add_last('event connected', 'mete_lista'); Irssi::signal_add('event 604', 'event_is_online'); Irssi::signal_add('event 605', 'null'); Irssi::signal_add('event 601', 'event_is_offline'); Irssi::signal_add('event 600', 'event_is_online'); irssi-scripts-20131030/scripts/postpone.pl0000644000000000000000000000670012143537176015360 0ustar # by Stefan 'tommie' Tomanek # # use strict; use vars qw($VERSION %IRSSI); $VERSION = "20030208"; %IRSSI = ( authors => "Stefan 'tommie' Tomanek", contact => "stefan\@pico.ruhr.de", name => "postpone", description => "Postpones messages sent to a splitted user and resends them when the nick rejoins", license => "GPLv2", changed => "$VERSION", commands => "postpone" ); use Irssi 20020324; use vars qw(%messages); sub draw_box ($$$$) { my ($title, $text, $footer, $colour) = @_; my $box = ''; $box .= '%R,--[%n%9%U'.$title.'%U%9%R]%n'."\n"; foreach (split(/\n/, $text)) { $box .= '%R|%n '.$_."\n"; } $box .= '%R`--<%n'.$footer.'%R>->%n'; $box =~ s/%.//g unless $colour; return $box; } sub show_help() { my $help="Postpone $VERSION /postpone help Display this help /postpone flush Flush postponed messages to /postpone list List postponed messages "; my $text = ''; foreach (split(/\n/, $help)) { $_ =~ s/^\/(.*)$/%9\/$1%9/; $text .= $_."\n"; } print CLIENTCRAP &draw_box("Postpone", $text, "help", 1); } sub event_send_text ($$$) { my ($line, $server, $witem) = @_; return unless ($witem && $witem->{type} eq "CHANNEL"); if ($line =~ /^(\w+?): (.*)$/) { my ($target, $msg) = ($1,$2); if ($witem->nick_find($target)) { # Just leave me alone return; } else { $witem->print("%B>>%n %U".$target."%U is not here, message has been postponed: \"".$line."\"", MSGLEVEL_CLIENTCRAP); push @{$messages{$server->{tag}}{$witem->{name}}{$target}}, $line; Irssi::signal_stop(); } } } sub event_message_join ($$$$) { my ($server, $channel, $nick, $address) = @_; return unless (defined $messages{$server->{tag}}); return unless (defined $messages{$server->{tag}}{$channel}); return unless (defined $messages{$server->{tag}}{$channel}{$nick}); return unless (scalar(@{$messages{$server->{tag}}{$channel}{$nick}}) > 0); my $chan = $server->channel_find($channel); $chan->print("%B>>%n Sending postponed messages for ".$nick, MSGLEVEL_CLIENTCRAP); while (scalar(@{$messages{$server->{tag}}{$channel}{$nick}}) > 0) { my $msg = pop @{$messages{$server->{tag}}{$channel}{$nick}}; $server->command('MSG '.$channel.' '.$msg); } } sub cmd_postpone ($$$) { my ($args, $server, $witem) = @_; my @arg = split(/ /, $args); if (scalar(@arg) < 1) { #foo } elsif ($arg[0] eq 'flush' && defined $arg[1]) { return unless ($witem && $witem->{type} eq "CHANNEL"); while (scalar(@{$messages{$server->{tag}}{$witem->{name}}{$arg[1]}}) > 0) { my $msg = pop @{$messages{$server->{tag}}{$witem->{name}}{$arg[1]}}; $server->command('MSG '.$witem->{name}.' '.$msg); } } elsif ($arg[0] eq 'list') { my $text; foreach (keys %messages) { $text .= $_."\n"; foreach my $channel (keys %{$messages{$_}}) { $text .= " %U".$channel."%U \n"; foreach my $nick (sort keys %{$messages{$_}{$channel}}) { $text .= ' |'.$_."\n" foreach @{$messages{$_}{$channel}{$nick}}; } } } print CLIENTCRAP &draw_box('Postpone', $text, 'messages', 1); } elsif ($arg[0] eq 'help') { show_help(); } } Irssi::command_bind('postpone', \&cmd_postpone); Irssi::signal_add('send text', \&event_send_text); Irssi::signal_add('message join', \&event_message_join); print CLIENTCRAP "%B>>%n Postpone ".$VERSION." loaded: /postpone help for help"; irssi-scripts-20131030/scripts/xmms.pl0000644000000000000000000001155012143537176014474 0ustar # XMMS-InfoPipe front-end - allow /np [dest] # # Thanks to ak for suggestions and even changes. # # /set xmms_fifo # /set xmms_format # /set xmms_format_streaming # /set xmms_print_if_stopped # /set xmms_format_time