From dbaec4df48d99818ad13a25352c991c9ccb529b1 Mon Sep 17 00:00:00 2001 From: ferret Date: Sun, 28 Sep 2014 10:04:05 +0100 Subject: Update go.pl Change tab completion to match /go but not other command beginning with /go (e.g. /google)--- scripts/go.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/go.pl b/scripts/go.pl index 3ca6744..34bf000 100644 --- a/scripts/go.pl +++ b/scripts/go.pl @@ -24,7 +24,7 @@ sub signal_complete_go { my $channel = $window->get_active_name(); my $k = Irssi::parse_special('$k'); - return unless ($linestart =~ /^\Q${k}\Ego/i); + return unless ($linestart =~ /^\Q${k}\Ego\b/i); @$complist = (); foreach my $w (Irssi::windows) { -- cgit v1.2.3 From 582c888142040a34c4262110c8eb76c123ad5fe9 Mon Sep 17 00:00:00 2001 From: ferret Date: Sun, 19 Oct 2014 15:12:04 +0100 Subject: Update go.pl bump go.pl version--- scripts/go.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/go.pl b/scripts/go.pl index 34bf000..b656a0f 100644 --- a/scripts/go.pl +++ b/scripts/go.pl @@ -8,7 +8,7 @@ use Irssi::Irc; # If you are in #irssi you can type /go #irssi or /go irssi or even /go ir ... # also try /go ir and /go (that's two spaces) -$VERSION = '1.00'; +$VERSION = '1.01'; %IRSSI = ( authors => 'nohar', @@ -16,7 +16,7 @@ $VERSION = '1.00'; name => 'go to window', description => 'Implements /go command that activates a window given a name/partial name. It features a nice completion.', license => 'GPLv2 or later', - changed => '08-17-04' + changed => '2014-10-19' ); sub signal_complete_go { -- cgit v1.2.3 From b1837b8c63a9dd0ee36b72aa192fd8d2e236b690 Mon Sep 17 00:00:00 2001 From: Makaze Date: Thu, 30 Oct 2014 17:21:08 -0400 Subject: Added dice_concise.pl --- scripts/dice_concise.pl | 247 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 scripts/dice_concise.pl (limited to 'scripts') diff --git a/scripts/dice_concise.pl b/scripts/dice_concise.pl new file mode 100644 index 0000000..8d5fbe3 --- /dev/null +++ b/scripts/dice_concise.pl @@ -0,0 +1,247 @@ +# dice_concise / Based on Marcel Kossin's 'dice' RP Dice Simulator +# +# What is this? +# +# -- Marcel Kossin's notes: -- +# +# I (mkossin) often Dungeon Master on our Neverwinternights Servers called 'Bund der +# alten Reiche' (eng. 'Alliance of the old realms') at bundderaltenreiche.de +# (German Site) Often idling in our Channel I thought it might be Fun to have +# a script to dice. Since I found nothing for irssi I wrote this little piece +# of script. The script assumes, that if a 'd' for english dice is given it +# should print the output in English. On the other hand if a 'w' for German +# 'Würfel' is given it prints the output in German. +# +# Usage. +# +# Anyone on the Channel kann ask '!roll' to toss the dice for him. He just has +# to say what dice he want to use. The notation should be well known from +# RP :-) Thus +# +# Write: !roll d[or w for german users] +# +# Here are some examples +# +# !roll 2d20 +# !roll 3d6 +# +# OK, I think you got it already :-) +# +# Write: !roll version +# For Version Information +# +# Write: !roll help +# For Information about how to use it +# +# -- Makaze's notes: -- +# +# [Changes in dice_concise:] +# +# Features added: +# +# [ ] Can add bonuses to the roll. e.g. "!roll 3d6+10" +# [ ] Output changed to one line only. e.g. "Makaze rolls the 3d6 and gets: 9 [4, +# 4, 1]" +# [ ] Corrected English grammar. +# [ ] Removed insults. +# [ ] Cleaner code with fewer nested if statements and true case switches. +# [ ] Errors call before the loop, saving clock cycles. +# +# Bugs fixed: +# +# [ ] Rolls within the correct range.* +# +# Edge cases added: +# +# [ ] Catch if rolling less than 1 dice. +# [ ] Catch if dice or sides are above 100 instead of 99. +# +# ----------------------------------------- +# +# * [The original dice.pl rolled a number between 1 and ( - 1)] +# [instead of using the full range. e.g. "!roll 1d6" would output 1 through ] +# [5, but never 6. ] +# +# ----------------------------------------- +# +# Original script 'dice.pl' by mkossin. +# +# Updated script 'dice_concise.pl' by Makaze. + +use strict; +use vars qw($VERSION %IRSSI); +use feature qw(switch); +use Scalar::Util qw(looks_like_number); + +use Irssi qw(command_bind signal_add); + +$VERSION = '0.1.5'; +%IRSSI = ( + authors => 'Marcel Kossin, Makaze', + contact => 'izaya.orihara@gmail', + name => 'dice_concise', + description => 'A concise dice simulator for channels.', + license => 'GNU GPL v2 or later' +); + +sub own_question { + my ($server, $msg, $nick, $address, $target) = @_; + question($server, $msg, $nick, $target); +} + +sub public_question { + my ($server, $msg, $nick, $address, $target) = @_; + question($server, $msg, $nick, $target); +} + +sub question($server, $msg, $nick, $target) { + my ($server, $msg, $nick, $target) = @_; + $_ = $msg; + + my $msgCompare = lc; + + if (substr($msgCompare, 0, 5) ne '!roll') { + return 0; + } + + unless (length $target) { + $target = $nick; + $nick = $server->{nick}; + } + + if (/\d[dw]\d/i) { + my $rnd; + my $forloop; + my $lang; + my @roll = split(/\s/, $_, 2); + my ($dice, $sides) = (@roll[1] =~ /(\d+)[dw](\d+)/i); + my @modifiers = ($roll[1] =~ /([\+\-\*\/]\d+)/gi); + my $modifyType; + my $modifyVal; + my @modifyErrors = ($roll[1] =~ /([\+\-\*\/][^\d\+\-\*\/]+)/); + my $value; + # Plus support added + my @rolls; + + if (/\d[w]\d/i) { + $lang = 'DE'; + } else { + $lang = 'EN'; + } + + if ($dice < 1) { + given ($lang) { + when ('DE') { + $server->command('msg ' . $target . ' ' . $nick . ' macht nichts... Würfeln funktioniert am besten mit Würfeln.'); + } + when ('EN') { + $server->command('msg ' . $target . ' ' . $nick . ' does nothing... Rolling dice works best with dice.'); + } + } + return 0; + } elsif ($dice > 100) { + given ($lang) { + when ('DE') { + $server->command('msg ' . $target . ' ' . $nick . ' scheitert den ' . $roll[1] . ' zu werfen... Versuch es mit weniger Würfeln.'); + } + when ('EN') { + $server->command('msg ' . $target . ' ' . $nick . ' fails to roll the ' . $roll[1] . '... Try fewer dice.'); + } + } + return 0; + } elsif ($sides <= 1) { + if ($sides == 0) { + given ($lang) { + when ('DE') { + $server->command('msg ' . $target . ' ' . $nick . ' verursacht ein Paradox... Oder hat jemand schon mal einen Würfel ohne Seiten gesehen?'); + } + when ('EN') { + $server->command('msg ' . $target . ' ' . $nick . ' causes a paradox... Or has anybody ever seen a die without sides?'); + } + } + return 0; + } elsif ($sides == 1) { + given ($lang) { + when ('DE') { + $server->command('msg ' . $target . ' ' . $nick . ' verursacht ein Paradox... Oder hat jemand schon mal einen Würfel mit nur einer Seite gesehen?'); + } + when ('EN') { + $server->command('msg ' . $target . ' ' . $nick . ' causes a paradox... Or has anybody ever seen a die with only one side?'); + } + } + return 0; + } + } elsif ($sides > 100) { + given ($lang) { + when ('DE') { + $server->command('msg ' . $target . ' ' . $nick . ' scheitert den ' . $roll[1] . ' zu werfen... Versuch es mit weniger Augen.'); + } + when ('EN') { + $server->command('msg ' . $target . ' ' . $nick . ' fails to roll the ' . $roll[1] . '... Try fewer sides.'); + } + } + return 0; + } + for ($forloop = 0; $forloop < $dice; $forloop++) { + $rnd = int(rand($sides)); + if ($rnd == 0) { + $rnd = $sides; + } + $value += $rnd; + $rolls[$forloop] = $rnd; + } + foreach (@modifiers) { + ($modifyType) = ($_ =~ /([\+\-\*\/])/); + ($modifyVal) = ($_ =~ /(\d+)/); + given ($modifyType) { + when ('*') { + $value = $value * $modifyVal; + } + when ('/') { + $value = $value / $modifyVal; + } + when ('+') { + $value = $value + $modifyVal; + } + when ('-') { + $value = $value - $modifyVal; + } + } + } + given ($lang) { + when ('DE') { + $server->command('msg ' . $target . ' '. $nick . ' würfelt mit dem ' . $roll[1] . ' und erhält: ' . $value . ' [' . join(', ', @rolls) . ']'); + } + when ('EN') { + $server->command('msg ' . $target . ' '. $nick . ' rolls the ' . $roll[1] . ' and gets: ' . $value . ' [' . join(', ', @rolls) . ']'); + } + } + if (@modifyErrors) { + given ($lang) { + when ('DE') { + $server->command('msg ' . $target . ' ' . $nick . ' scheitert ihr Ergebnis zu ändern. Versuch es mit Zahlen. [' . join(', ', @modifyErrors) . ']'); + } + when ('EN') { + $server->command('msg ' . $target . ' ' . $nick . ' fails to modify their result. Try using numbers. [' . join(', ', @modifyErrors) . ']'); + } + } + } + return 1; + } elsif (substr($msgCompare, 0, 13) eq '!roll version') { + $server->command('msg ' . $target . " \x039" . $IRSSI{'name'} . ": Version " . $VERSION . " by Makaze & mkossin"); + return 0; + } elsif (substr($msgCompare, 0, 10) eq '!roll help') { + $server->command('msg ' . $target . ' Syntax: "!roll d[<+-*/>modifier]" - e.g. "!roll 2d20", "!roll 2d20*2+10"'); + return 0; + } elsif (substr($msgCompare, 0, 11) eq '!roll hilfe') { + $server->command('msg ' . $target . ' Syntax: "!roll w[<+-*/>Modifikator]" - z.B. "!roll 2w20", "!roll 2w20*2+10"'); + return 0; + } else { + $server->command('msg ' . $target .' "!roll help" - gives the English help'); + $server->command('msg ' . $target . ' "!roll hilfe" - zeigt die deutsche Hilfe an'); + return 0; + } +} + +signal_add('message public', 'public_question'); +signal_add('message own_public', 'own_question'); \ No newline at end of file -- cgit v1.2.3 From ac9347f0006dc9379b1e861a94027f7c774d50dd Mon Sep 17 00:00:00 2001 From: Pablo Martín Báez Echevarría Date: Fri, 7 Nov 2014 13:00:08 -0200 Subject: Fix missing parentheses in frm_outgmsgs.pl --- scripts/frm_outgmsgs.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/frm_outgmsgs.pl b/scripts/frm_outgmsgs.pl index 7e51566..71c9b02 100644 --- a/scripts/frm_outgmsgs.pl +++ b/scripts/frm_outgmsgs.pl @@ -5,7 +5,7 @@ use Scalar::Util qw(looks_like_number); use Irssi; use vars qw($VERSION %IRSSI); -$VERSION = '1.0'; +$VERSION = '1.1'; %IRSSI = ( authors => 'Pablo Martín Báez Echevarría', contact => 'pab_24n@outlook.com', @@ -95,7 +95,7 @@ sub cmd_colors { } sub is_mIRC_color { - my $num = @_; + my ( $num ) = @_; return (looks_like_number($num)) ? ((0 <= $num) && ($num <= 15)) : 0; } -- cgit v1.2.3 From 11c02fdb9b5a0d9f09999c5cde856e19a76ec83f Mon Sep 17 00:00:00 2001 From: Jostein Kjønigsen Date: Fri, 24 Oct 2014 12:54:12 +0200 Subject: Autoop.pl: Add persistance to auto-op'ed nicks. Bump version. --- scripts/autoop.pl | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/autoop.pl b/scripts/autoop.pl index d46d099..b72def1 100644 --- a/scripts/autoop.pl +++ b/scripts/autoop.pl @@ -5,13 +5,13 @@ use Irssi; use strict; use vars qw($VERSION %IRSSI); -$VERSION = "1.00"; +$VERSION = "1.10"; %IRSSI = ( - authors => 'Timo Sirainen', + authors => 'Timo Sirainen & Jostein Kjønigsen', name => 'autoop', description => 'Simple auto-op script', license => 'Public Domain', - changed => 'Sun Mar 10 23:18 EET 2002' + changed => 'Fri Nov 24 12:55 GMT+1 2014' ); my (%opnicks, %temp_opped); @@ -89,3 +89,68 @@ sub event_massjoin { Irssi::command_bind('autoop', 'cmd_autoop'); Irssi::signal_add_last('massjoin', 'event_massjoin'); + +sub load_autoops { + my($file) = Irssi::get_irssi_dir."/autoop"; + my($count) = 0; + local(*CONF); + + %opnicks = (); + open(CONF, "<", "$file") or return; + while (my $line = ) { + if ($line !=~ /^\s*$/) { + cmd_autoop($line); + $count++; + } + } + close(CONF); + + Irssi::print("Loaded $count channels from $file"); +} + +# --------[ save_autoops ]------------------------------------------------ + +sub save_autoops { + my($auto) = @_; + my($file) = Irssi::get_irssi_dir."/autoop"; + my($count) = 0; + my($channel) = ""; + local(*CONF); + + return if $auto; + + open(CONF, ">", "$file"); + foreach $channel (keys %opnicks) { + my $masks = $opnicks{$channel}; + print CONF "$channel\t$masks\n"; + $count++; + } + close(CONF); + + Irssi::print("Saved $count channels to $file") + unless $auto; +} + + +# --------[ sig_setup_reread ]------------------------------------------ + +# main setup is reread, so let us do it too +sub sig_setup_reread { + load_autoops; +} + +# --------[ sig_setup_save ]-------------------------------------------- + +# main config is saved, and so we should save too +sub sig_setup_save { + my($mainconf,$auto) = @_; + save_autoops($auto); +} + +# persistance + +Irssi::signal_add('setup saved', 'sig_setup_save'); +Irssi::signal_add('setup reread', 'sig_setup_reread'); + +# ensure we load persisted values on start +load_autoops; -- cgit v1.2.3 From ea4bd90d31b5ef942a8f56928c451ca0e3528b91 Mon Sep 17 00:00:00 2001 From: tomaw Date: Wed, 12 Nov 2014 12:18:23 +0000 Subject: cron.pl: load jobs when the script loads --- scripts/cron.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/cron.pl b/scripts/cron.pl index 9e1d125..bb761c2 100644 --- a/scripts/cron.pl +++ b/scripts/cron.pl @@ -290,6 +290,8 @@ sub cmd_jobsload { Irssi::print("Jobs loaded"); } +cmd_jobsload(); + Irssi::command_bind('jobs', 'cmd_jobs', 'Cron'); Irssi::command_bind('jobadd', 'cmd_jobadd', 'Cron'); Irssi::command_bind('jobdel', 'cmd_jobdel', 'Cron'); -- cgit v1.2.3 From fd702973e5512d22a63dccf9246dc67ec3365899 Mon Sep 17 00:00:00 2001 From: tomaw Date: Wed, 12 Nov 2014 12:23:06 +0000 Subject: cron.pl: Bump version, update changelog --- scripts/cron.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/cron.pl b/scripts/cron.pl index bb761c2..0d1ac1e 100644 --- a/scripts/cron.pl +++ b/scripts/cron.pl @@ -40,6 +40,9 @@ # ? should we remember if the server was given with -server # # Changelog: +# 0.12 (2014.11.12) +# Automatically load jobs when loaded +# # 0.11 (2004.12.12) # Job are executed exactly at the time (+- 1s), not up to 59s late # @@ -69,7 +72,7 @@ use Irssi; use strict; use vars qw($VERSION %IRSSI); -$VERSION = "0.11"; +$VERSION = "0.12"; %IRSSI = ( authors => 'Piotr Krukowiecki', contact => 'piotr \at/ krukowiecki /dot\ net', -- cgit v1.2.3 From 6224319f82617cf62e96de472ac2b475e7ae69ab Mon Sep 17 00:00:00 2001 From: tka Date: Tue, 25 Nov 2014 12:12:20 +0100 Subject: Make localize.pl use utrace.de All ipdb providers seem to be dead. Using utrace.de, localizing actually works again. --- scripts/localize.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/localize.pl b/scripts/localize.pl index 8d00985..3dac629 100644 --- a/scripts/localize.pl +++ b/scripts/localize.pl @@ -186,16 +186,16 @@ $procs = 0; ); %ipdb = ( - d1localizer=>{ name=>'localizer', + d1utrace=>{ name=>'utrace', active=>1, - url=>'http://jan.kneschke.de/projects/localizer/index.php?query=', - city=>'City<\/b><\/td>(.*?)<\/td>', - province=>'Province<\/b><\/td>(.*?)<\/td>', - country=>'Country<\/b><\/td>(.*?)<\/td>', - provider=>'\(Backbone-\)Provider<\/b><\/td>(.*?)<\/td>', + url=>'http://xml.utrace.de/?query=', + city=>'(.*?)<\/region>', + province=>'(.*?)<\/org>', + country=>'(.*?)<\/countrycode>', + provider=>'(.*?)<\/isp>', failure=>'request-limit-exceeded|Host not found'}, d2ipatlas=> { name=>'IP-Atlas', - active=>1, + active=>0, url=>'http://www.xpenguin.com/plot.php?address=', city=>'is located in (.*?),', province=>'is located in.*, (.*?) \(state\),', -- cgit v1.2.3 From c0c61225213f664d4840fac08288a260a6e1f843 Mon Sep 17 00:00:00 2001 From: Thorsten Leemhuis Date: Tue, 25 Nov 2014 19:34:33 +0100 Subject: fnotify.pl: import v0.0.3 Source: http://www.leemhuis.info/files/fnotify/fnotify Signed-off-by: Serge van Ginderachter --- scripts/fnotify.pl | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 scripts/fnotify.pl (limited to 'scripts') diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl new file mode 100644 index 0000000..983a262 --- /dev/null +++ b/scripts/fnotify.pl @@ -0,0 +1,68 @@ +# todo: grap topic changes + +use strict; +use vars qw($VERSION %IRSSI); + +use Irssi; +$VERSION = '0.0.3'; +%IRSSI = ( + authors => 'Thorsten Leemhuis', + contact => 'fedora@leemhuis.info', + name => 'fnotify', + description => 'Write a notification to a file that shows who is talking to you in which channel.', + url => 'http://www.leemhuis.info/files/fnotify/', + license => 'GNU General Public License', + changed => '$Date: 2007-01-13 12:00:00 +0100 (Sat, 13 Jan 2007) $' +); + +#-------------------------------------------------------------------- +# In parts based on knotify.pl 0.1.1 by Hugo Haas +# http://larve.net/people/hugo/2005/01/knotify.pl +# which is based on osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen +# http://www.irssi.org/scripts/scripts/osd.pl +# +# Other parts based on notify.pl from Luke Macken +# http://fedora.feedjack.org/user/918/ +# +#-------------------------------------------------------------------- + +#-------------------------------------------------------------------- +# Private message parsing +#-------------------------------------------------------------------- + +sub priv_msg { + my ($server,$msg,$nick,$address,$target) = @_; + filewrite($nick." " .$msg ); +} + +#-------------------------------------------------------------------- +# Printing hilight's +#-------------------------------------------------------------------- + +sub hilight { + my ($dest, $text, $stripped) = @_; + if ($dest->{level} & MSGLEVEL_HILIGHT) { + filewrite($dest->{target}. " " .$stripped ); + } +} + +#-------------------------------------------------------------------- +# The actual printing +#-------------------------------------------------------------------- + +sub filewrite { + my ($text) = @_; + # FIXME: there is probably a better way to get the irssi-dir... + open(FILE,">>$ENV{HOME}/.irssi/fnotify"); + print FILE $text . "\n"; + close (FILE); +} + +#-------------------------------------------------------------------- +# Irssi::signal_add_last / Irssi::command_bind +#-------------------------------------------------------------------- + +Irssi::signal_add_last("message private", "priv_msg"); +Irssi::signal_add_last("print text", "hilight"); + +#- end -- cgit v1.2.3 From a11c7830eeb4ad4f32575d87b72012ecaa4c9c98 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Tue, 25 Nov 2014 19:59:07 +0100 Subject: fnotify.pl: Update to version 0.0.4 by James Shubin "Implement Consistent output formatting" Source: https://ttboj.wordpress.com/2013/10/18/desktop-notifications-for-irssi-in-screen-through-ssh-in-gnome-terminal/ Signed-off-by: Serge van Ginderachter --- scripts/fnotify.pl | 90 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 40 deletions(-) (limited to 'scripts') diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index 983a262..58b2957 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -1,68 +1,78 @@ -# todo: grap topic changes - use strict; use vars qw($VERSION %IRSSI); use Irssi; -$VERSION = '0.0.3'; +$VERSION = '0.0.4'; %IRSSI = ( - authors => 'Thorsten Leemhuis', - contact => 'fedora@leemhuis.info', - name => 'fnotify', - description => 'Write a notification to a file that shows who is talking to you in which channel.', - url => 'http://www.leemhuis.info/files/fnotify/', - license => 'GNU General Public License', - changed => '$Date: 2007-01-13 12:00:00 +0100 (Sat, 13 Jan 2007) $' + name => 'fnotify', + authors => 'Thorsten Leemhuis, James Shubin', + description => 'Write notifications to a file in a consistent format.', + license => 'GNU General Public License', ); -#-------------------------------------------------------------------- -# In parts based on knotify.pl 0.1.1 by Hugo Haas +# +# README +# +# To use: +# $ cp fnotify.pl ~/.irssi/scripts/fnotify.pl +# irssi> /load perl +# irssi> /script load fnotify +# + +# +# AUTHORS +# +# Consistent output formatting by James Shubin: +# https://ttboj.wordpress.com/ +# +# Modified from the Thorsten Leemhuis version: +# http://www.leemhuis.info/files/fnotify/fnotify +# +# In parts based on knotify.pl 0.1.1 by Hugo Haas: # http://larve.net/people/hugo/2005/01/knotify.pl -# which is based on osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen +# +# Which is based on osd.pl 0.3.3 by Jeroen Coekaerts, Koenraad Heijlen: # http://www.irssi.org/scripts/scripts/osd.pl # -# Other parts based on notify.pl from Luke Macken +# Other parts based on notify.pl from Luke Macken: # http://fedora.feedjack.org/user/918/ # -#-------------------------------------------------------------------- - -#-------------------------------------------------------------------- -# Private message parsing -#-------------------------------------------------------------------- +# +# catch private messages +# sub priv_msg { - my ($server,$msg,$nick,$address,$target) = @_; - filewrite($nick." " .$msg ); + my ($server, $msg, $nick, $address, $target) = @_; + my $network = $server->{tag}; + filewrite('' . $network . ' ' . $nick . ' ' . $msg); } -#-------------------------------------------------------------------- -# Printing hilight's -#-------------------------------------------------------------------- - +# +# catch 'hilight's +# sub hilight { - my ($dest, $text, $stripped) = @_; - if ($dest->{level} & MSGLEVEL_HILIGHT) { - filewrite($dest->{target}. " " .$stripped ); - } + my ($dest, $text, $stripped) = @_; + if ($dest->{level} & MSGLEVEL_HILIGHT) { + my $server = $dest->{server}; + my $network = $server->{tag}; + filewrite($network . ' ' . $dest->{target} . ' ' . $stripped); + } } -#-------------------------------------------------------------------- -# The actual printing -#-------------------------------------------------------------------- - +# +# write to file +# sub filewrite { my ($text) = @_; # FIXME: there is probably a better way to get the irssi-dir... - open(FILE,">>$ENV{HOME}/.irssi/fnotify"); + open(FILE, ">>$ENV{HOME}/.irssi/fnotify"); print FILE $text . "\n"; - close (FILE); + close(FILE); } -#-------------------------------------------------------------------- -# Irssi::signal_add_last / Irssi::command_bind -#-------------------------------------------------------------------- - +# +# irssi signals +# Irssi::signal_add_last("message private", "priv_msg"); Irssi::signal_add_last("print text", "hilight"); -#- end -- cgit v1.2.3 From 4de929f87ba2bf90177ac03d8df6b708c4acb73d Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Tue, 25 Nov 2014 21:00:23 +0100 Subject: fnotify.pl: Strip non-parsed left over codes (Bitlbee otr messages) Signed-off-by: Serge van Ginderachter --- scripts/fnotify.pl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index 58b2957..f53205e 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -1,11 +1,11 @@ use strict; use vars qw($VERSION %IRSSI); - use Irssi; -$VERSION = '0.0.4'; + +$VERSION = '0.0.5'; %IRSSI = ( name => 'fnotify', - authors => 'Thorsten Leemhuis, James Shubin', + authors => 'Thorsten Leemhuis, James Shubin, Serge van Ginderachter', description => 'Write notifications to a file in a consistent format.', license => 'GNU General Public License', ); @@ -22,10 +22,17 @@ $VERSION = '0.0.4'; # # AUTHORS # +# Strip non-parsed left over codes (Bitlbee otr messages) +# version: 0.0.5 +# Serge van Ginderachter +# # Consistent output formatting by James Shubin: +# version: 0.0.4 # https://ttboj.wordpress.com/ +# note: changed license back to original GPL from Thorsten Leemhuis (svg) # -# Modified from the Thorsten Leemhuis version: +# Modified from the Thorsten Leemhuis +# version: 0.0.3 # http://www.leemhuis.info/files/fnotify/fnotify # # In parts based on knotify.pl 0.1.1 by Hugo Haas: @@ -43,8 +50,9 @@ $VERSION = '0.0.4'; # sub priv_msg { my ($server, $msg, $nick, $address, $target) = @_; + my $msg_stripped = Irssi::strip_codes($msg); my $network = $server->{tag}; - filewrite('' . $network . ' ' . $nick . ' ' . $msg); + filewrite('' . $network . ' ' . $nick . ' ' . $msg_stripped); } # -- cgit v1.2.3 From 3a92a5e3d05d2eee78fc9202a673b1861563c60c Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Wed, 26 Nov 2014 13:57:28 +0100 Subject: fnotify.pl: fix perlcritic errors --- scripts/fnotify.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index f53205e..42a7eb8 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -1,4 +1,5 @@ use strict; +use warnings; use vars qw($VERSION %IRSSI); use Irssi; @@ -73,9 +74,14 @@ sub hilight { sub filewrite { my ($text) = @_; # FIXME: there is probably a better way to get the irssi-dir... - open(FILE, ">>$ENV{HOME}/.irssi/fnotify"); + my $fnfile = "$ENV{HOME}/.irssi/fnotify"; + if (!open(FILE, ">>", $fnfile)) { + print_err("cannot open $fnfile: $!"); + } print FILE $text . "\n"; - close(FILE); + if (!close(FILE)) { + print_err("cannot close $fnfile: $!"); + } } # -- cgit v1.2.3 From 840fb2565fe2b912d2077f6c2c62a12e517c8c66 Mon Sep 17 00:00:00 2001 From: Michal Rus Date: Sun, 23 Nov 2014 22:50:23 +0000 Subject: Support UTF-8 in rainbow.pl --- scripts/rainbow.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/rainbow.pl b/scripts/rainbow.pl index 3fc2375..4b0361b 100644 --- a/scripts/rainbow.pl +++ b/scripts/rainbow.pl @@ -20,7 +20,7 @@ use strict; use vars qw($VERSION %IRSSI); -$VERSION = "1.4"; +$VERSION = "1.5"; %IRSSI = ( authors => 'Jakub Jankowski', contact => 'shasta@atn.pl', @@ -47,6 +47,7 @@ my @colors = ('0', '4', '8', '9', '11', '12', '13'); # returns random-coloured string sub make_colors { my ($string) = @_; + Encode::_utf8_on($string); my $newstr = ""; my $last = 255; my $color = 0; @@ -144,3 +145,4 @@ Irssi::command_bind("rkick", "rkick"); # 29.01.2002: /rsay works with dcc chats now (v1.2) # 02.02.2002: make_colors() doesn't assign any color to spaces (v1.3) # 23.02.2002: /rkick added +# 26.11.2014: utf-8 support -- cgit v1.2.3 From 8c80ff735d60ce8bb3f8c7267682a55d1f8065bb Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Thu, 27 Nov 2014 18:34:31 +0100 Subject: fnotify.pl: fixes: fix proper way to get the irssi-dir replace unknown err function, and do better error handling --- scripts/fnotify.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/fnotify.pl b/scripts/fnotify.pl index 42a7eb8..76e46b4 100644 --- a/scripts/fnotify.pl +++ b/scripts/fnotify.pl @@ -51,7 +51,7 @@ $VERSION = '0.0.5'; # sub priv_msg { my ($server, $msg, $nick, $address, $target) = @_; - my $msg_stripped = Irssi::strip_codes($msg); + my $msg_stripped = Irssi::strip_codes($msg); my $network = $server->{tag}; filewrite('' . $network . ' ' . $nick . ' ' . $msg_stripped); } @@ -73,15 +73,15 @@ sub hilight { # sub filewrite { my ($text) = @_; - # FIXME: there is probably a better way to get the irssi-dir... - my $fnfile = "$ENV{HOME}/.irssi/fnotify"; - if (!open(FILE, ">>", $fnfile)) { - print_err("cannot open $fnfile: $!"); - } - print FILE $text . "\n"; - if (!close(FILE)) { - print_err("cannot close $fnfile: $!"); - } + my $fnfile = Irssi::get_irssi_dir() . "/fnotify"; + if (!open(FILE, ">>", $fnfile)) { + print CLIENTCRAP "Error: cannot open $fnfile: $!"; + } else { + print FILE $text . "\n"; + if (!close(FILE)) { + print CLIENTCRAP "Error: cannot close $fnfile: $!"; + } + } } # -- cgit v1.2.3 From d6d3e5c3111ebcb6215687a57feee26c983c69ab Mon Sep 17 00:00:00 2001 From: Mike Rix Wolfe Date: Mon, 1 Dec 2014 13:04:58 -0600 Subject: Add rknockout Added rknockout function for colorful knockouts.--- scripts/rainbow.pl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/rainbow.pl b/scripts/rainbow.pl index 4b0361b..0dd292d 100644 --- a/scripts/rainbow.pl +++ b/scripts/rainbow.pl @@ -13,6 +13,9 @@ # # /RKICK [reason] # - kicks nick from the current channel with coloured reason +# +# /RKNOCKOUT [time] [reason] +# - knockouts nicks from the current channel with coloured reason for time # Written by Jakub Jankowski # for Irssi 0.7.98.4 and newer @@ -20,7 +23,7 @@ use strict; use vars qw($VERSION %IRSSI); -$VERSION = "1.5"; +$VERSION = "1.6"; %IRSSI = ( authors => 'Jakub Jankowski', contact => 'shasta@atn.pl', @@ -133,10 +136,30 @@ sub rkick { } } +# void rknockout($text, $server, $destination) +# handles /rknockout +sub rknockout { + my ($text, $server, $dest) = @_; + + if (!$server || !$server->{connected}) { + Irssi::print("Not connected to server"); + return; + } + + if ($dest && $dest->{type} eq "CHANNEL") { + my ($time, $nick, $reason) = split(/ +/, $text, 3); + ($time, $nick, $reason) = (300, $time, $nick . " " . $reason) if ($time !~ m/^\d+$/); + return unless $nick; + $reason = "See you in " . $time . " seconds!" if ($reason =~ /^[\ ]*$/); + $dest->command("/knockout " . $time . " " . $nick . " " . make_colors($reason)); + } +} + Irssi::command_bind("rsay", "rsay"); Irssi::command_bind("rtopic", "rtopic"); Irssi::command_bind("rme", "rme"); Irssi::command_bind("rkick", "rkick"); +Irssi::command_bind("rknockout", "rknockout"); # changes: # @@ -146,3 +169,4 @@ Irssi::command_bind("rkick", "rkick"); # 02.02.2002: make_colors() doesn't assign any color to spaces (v1.3) # 23.02.2002: /rkick added # 26.11.2014: utf-8 support +# 01.12.2014: /rknockout added (v1.6) -- cgit v1.2.3 From be44f72d3c04ebc933feb121d51b4556a441d36d Mon Sep 17 00:00:00 2001 From: tka Date: Sat, 6 Dec 2014 11:57:45 +0100 Subject: Version Update - Changed Version to last change date - Added API documentation URL for utrace.de --- scripts/localize.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/localize.pl b/scripts/localize.pl index 3dac629..7aabe9f 100644 --- a/scripts/localize.pl +++ b/scripts/localize.pl @@ -52,11 +52,15 @@ # # 03.07.2002 # *switched to Data::Dumper +# +# 25.11.2014 +# Added utrace.de as a localizer +# http://www.utrace.de/ use strict; use vars qw($VERSION %IRSSI); -$VERSION = "2003112301"; +$VERSION = "2014112501"; %IRSSI = ( authors => "Stefan 'tommie' Tomanek", contact => "stefan\@pico.ruhr.de", @@ -186,6 +190,7 @@ $procs = 0; ); %ipdb = ( + # For utrace.de API documentation, see http://en.utrace.de/api.php d1utrace=>{ name=>'utrace', active=>1, url=>'http://xml.utrace.de/?query=', -- cgit v1.2.3 From 1ffde379dfa2b3674af1695b5d1639f6843e7bb5 Mon Sep 17 00:00:00 2001 From: Mantas Mikulėnas Date: Thu, 18 Dec 2014 08:54:54 +0200 Subject: Add auth_quakenet.pl --- scripts/auth_quakenet.pl | 197 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 scripts/auth_quakenet.pl (limited to 'scripts') diff --git a/scripts/auth_quakenet.pl b/scripts/auth_quakenet.pl new file mode 100644 index 0000000..53f8b96 --- /dev/null +++ b/scripts/auth_quakenet.pl @@ -0,0 +1,197 @@ +# vim: ft=perl +use strict; +use Irssi; +use vars qw($VERSION %IRSSI); + +## Settings: +# +# quakenet_account (string) = ( [:]: )* +# +# Your QuakeNet account details, in format :. Example: +# +# /set quakenet_account [fishking]:iLOVEfish12345 +# +# Different accounts for different Irssi "networks" ("server tags") can be +# set in format :: (space-separated). The +# account with empty (or missing) will be used as the default +# account for all other connections.) +# +# quakenet_auth_allowed_mechs (string) = any +# +# List of allowed mechanisms, separated by spaces. +# Can be "any" to allow all supported mechanisms. +# +# Currently supported: +# HMAC-SHA-256 (Digest::SHA) +# HMAC-SHA-1 (Digest::SHA1) +# HMAC-MD5 (Digest::MD5) +# LEGACY-MD5 (Digest::MD5 without HMAC) +# +# Note: LEGACY-MD5 is excluded from "any"; if you want to use it, specify +# it manually. +# +## To trigger the script manually, use: +## /msg Q@cserve.quakenet.org challenge + +$VERSION = "1.0"; +%IRSSI = ( + authors => 'Mantas Mikulėnas', + contact => 'grawity@gmail.com', + name => 'auth_quakenet_challenge.pl', + description => "Implements QuakeNet's CHALLENGE authentication", + license => 'WTFPL v2 ', + url => 'http://purl.net/net/grawity/irssi.html', +); + +require Digest::HMAC; + +my @preferred_mechs = qw(HMAC-SHA-256 HMAC-SHA-1 HMAC-MD5); + +my %supported_mechs = (); + +eval { + require Digest::SHA; + $supported_mechs{"HMAC-SHA-256"} = sub { + hmac(\&Digest::SHA::sha256_hex, \&Digest::SHA::sha256, @_); + }; +}; + +eval { + require Digest::SHA1; + $supported_mechs{"HMAC-SHA-1"} = sub { + hmac(\&Digest::SHA1::sha1_hex, \&Digest::SHA1::sha1, @_); + }; +}; + +eval { + require Digest::MD5; + $supported_mechs{"HMAC-MD5"} = sub { + hmac(\&Digest::MD5::md5_hex, \&Digest::MD5::md5, @_); + }; + $supported_mechs{"LEGACY-MD5"} = sub { + Irssi::print("WARNING: LEGACY-MD5 should not be used."); + my ($challenge, $username, $password) = @_; + Digest::MD5::md5_hex($password . " " . $challenge); + }; +}; + +if (scalar keys %supported_mechs == 0) { + die "No mechanisms available. Please install these Perl modules:\n" + ." - Digest::HMAC\n" + ." - Digest::SHA, Digest::SHA1, Digest::MD5 (at least one)\n"; +} + +sub hmac { + my ($fnhex, $fnraw, $challenge, $username, $password) = @_; + my $key = &$fnhex($username . ":" . &$fnhex($password)); + Digest::HMAC::hmac_hex($challenge, $key, $fnraw); +} + +sub lcnick { + my $str = shift; + $str =~ tr/[\\]/{|}/; + lc $str; +} + +sub get_account { + my ($servertag) = @_; + my $accounts = Irssi::settings_get_str("quakenet_account"); + my ($defuser, $defpass) = (undef, undef); + for my $acct (split /\s+/, $accounts) { + my ($tag, $user, $pass); + + my @acct = split(/:/, $acct); + if (@acct == 3) { + ($tag, $user, $pass) = @acct; + } elsif (@acct == 2) { + ($tag, $user, $pass) = ("*", @acct); + } else { + next; + } + + if (lc $tag eq lc $servertag) { + return ($user, $pass); + } + elsif ($tag eq "*" or $tag eq "") { + ($defuser, $defpass) = ($user, $pass); + } + } + return ($defuser, $defpass); +} + +Irssi::signal_add_last("event 001" => sub { + my ($server, $evargs, $srcnick, $srcaddr) = @_; + return unless $srcnick =~ /\.quakenet\.org$/; + + my ($user, $pass) = get_account($server->{tag}); + return if !length($pass); + + $server->print("", "Authenticating to Q"); + $server->send_message('Q@cserve.quakenet.org', "CHALLENGE", 1); +}); + +Irssi::signal_add_first("message irc notice" => sub { + my ($server, $msg, $nick, $address, $target) = @_; + return unless $server->mask_match_address('Q!*@cserve.quakenet.org', $nick, $address); + + if ($msg =~ /^CHALLENGE ([0-9a-f]+) (.+)$/) { + Irssi::signal_stop(); + + my $challenge = $1; + my @server_mechs = split(" ", $2); + + my ($user, $pass) = get_account($server->{tag}); + return if !length($pass); + + $user = lcnick($user); + $pass = substr($pass, 0, 10); + + my $mech; + my @allowed_mechs = (); + my $allowed_mechs = uc Irssi::settings_get_str("quakenet_auth_allowed_mechs"); + if ($allowed_mechs eq "ANY") { + # @preferred_mechs is sorted by strength + @allowed_mechs = @preferred_mechs; + } else { + @allowed_mechs = split(/\s+/, $allowed_mechs); + } + + # choose first mech supported by both sides + for my $m (@allowed_mechs) { + if (grep {$_ eq $m} @server_mechs && + grep {$_ eq $m} (keys %supported_mechs)) { + $mech = $m; + last; + } + } + + if (!defined $mech) { + $server->print("", "Authentication failed (no mechanisms available)"); + $server->print("", " Server offers: ".join(", ", @server_mechs)); + $server->print("", " Client supports: ".join(", ", keys %supported_mechs)); + $server->print("", " Restricted to: ".join(", ", @allowed_mechs)); + return; + } + + my $authfn = $supported_mechs{$mech}; + + my $response = &$authfn($challenge, $user, $pass); + $server->send_message('Q@cserve.quakenet.org', "CHALLENGEAUTH $user $response $mech", 1); + } + + elsif ($msg =~ /^You are now logged in as (.+?)\.$/) { + Irssi::signal_stop(); + $server->print("", "Authentication successful, logged in as $1"); + } + + elsif ($msg =~ /^Username or password incorrect\.$/) { + Irssi::signal_stop(); + $server->print("", "Authentication failed (username or password incorrect)"); + } +}); + +Irssi::settings_add_str("misc", "quakenet_auth_allowed_mechs", "any"); +Irssi::settings_add_str("misc", "quakenet_account", ""); +if (Irssi::settings_get_str("quakenet_account") eq "") { + Irssi::print("Set your QuakeNet account using /set quakenet_account username:password"); +} -- cgit v1.2.3 From f71df20f3fb22d9e8b90cb32f6f7010585c99a25 Mon Sep 17 00:00:00 2001 From: Mantas Mikulėnas Date: Thu, 18 Dec 2014 09:12:50 +0200 Subject: Add cap_sasl.pl This is a copy of Atheme's `contrib/cap_sasl.pl` 1.8a. --- scripts/cap_sasl.pl | 385 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 385 insertions(+) create mode 100644 scripts/cap_sasl.pl (limited to 'scripts') diff --git a/scripts/cap_sasl.pl b/scripts/cap_sasl.pl new file mode 100644 index 0000000..ad6df45 --- /dev/null +++ b/scripts/cap_sasl.pl @@ -0,0 +1,385 @@ +use strict; +use Irssi; +use MIME::Base64; +use vars qw($VERSION %IRSSI); +use constant CHALLENGE_SIZE => 32; + +$VERSION = "1.8a"; +%IRSSI = ( + authors => 'Michael Tharp (gxti), Jilles Tjoelker (jilles), Mantas Mikulėnas (grawity)', + contact => 'grawity@gmail.com', + name => 'cap_sasl.pl', + description => 'Implements SASL authentication and enables CAP "multi-prefix"', + license => 'GPLv2', + url => 'http://ircv3.atheme.org/extensions/sasl-3.1', +); + +my %sasl_auth = (); +my %mech = (); + +sub timeout; + +sub server_connected { + my $server = shift; + if (uc $server->{chat_type} eq 'IRC') { + $server->send_raw_now("CAP LS"); + } +} + +sub event_cap { + my ($server, $args, $nick, $address) = @_; + my ($subcmd, $caps, $tosend, $sasl); + + $tosend = ''; + $sasl = $sasl_auth{$server->{tag}}; + if ($args =~ /^\S+ (\S+) :(.*)$/) { + $subcmd = uc $1; + $caps = ' '.$2.' '; + if ($subcmd eq 'LS') { + $tosend .= ' multi-prefix' if $caps =~ / multi-prefix /i; + $tosend .= ' sasl' if $caps =~ / sasl /i && defined($sasl); + $tosend =~ s/^ //; + $server->print('', "CLICAP: supported by server:$caps"); + if (!$server->{connected}) { + if ($tosend eq '') { + $server->send_raw_now("CAP END"); + } else { + $server->print('', "CLICAP: requesting: $tosend"); + $server->send_raw_now("CAP REQ :$tosend"); + } + } + Irssi::signal_stop(); + } elsif ($subcmd eq 'ACK') { + $server->print('', "CLICAP: now enabled:$caps"); + if ($caps =~ / sasl /i) { + $sasl->{buffer} = ''; + $sasl->{step} = 0; + if ($mech{$sasl->{mech}}) { + $server->send_raw_now("AUTHENTICATE " . $sasl->{mech}); + Irssi::timeout_add_once(7500, \&timeout, $server->{tag}); + } else { + $server->print('', 'SASL: attempted to start unknown mechanism "' . $sasl->{mech} . '"'); + } + } + elsif (!$server->{connected}) { + $server->send_raw_now("CAP END"); + } + Irssi::signal_stop(); + } elsif ($subcmd eq 'NAK') { + $server->print('', "CLICAP: refused:$caps"); + if (!$server->{connected}) { + $server->send_raw_now("CAP END"); + } + Irssi::signal_stop(); + } elsif ($subcmd eq 'LIST') { + $server->print('', "CLICAP: currently enabled:$caps"); + Irssi::signal_stop(); + } + } +} + +sub event_authenticate { + my ($server, $args, $nick, $address) = @_; + my $sasl = $sasl_auth{$server->{tag}}; + return unless $sasl && $mech{$sasl->{mech}}; + + $sasl->{buffer} .= $args; + return if length($args) == 400; + + my $data = ($sasl->{buffer} eq '+') ? '' : decode_base64($sasl->{buffer}); + my $out = $mech{$sasl->{mech}}($sasl, $data); + + if (defined $out) { + $out = ($out eq '') ? '+' : encode_base64($out, ''); + while (length $out >= 400) { + my $subout = substr($out, 0, 400, ''); + $server->send_raw_now("AUTHENTICATE $subout"); + } + if (length $out) { + $server->send_raw_now("AUTHENTICATE $out"); + } else { + # Last piece was exactly 400 bytes, we have to send + # some padding to indicate we're done. + $server->send_raw_now("AUTHENTICATE +"); + } + } else { + $server->send_raw_now("AUTHENTICATE *"); + } + + $sasl->{buffer} = ""; + Irssi::signal_stop(); +} + +sub event_saslend { + my ($server, $args, $nick, $address) = @_; + + my $data = $args; + $data =~ s/^\S+ :?//; + # need this to see it, ?? -- jilles + + $server->print('', $data); + if (!$server->{connected}) { + $server->send_raw_now("CAP END"); + } +} + +sub event_saslfail { + my ($server, $args, $nick, $address) = @_; + + my $data = $args; + $data =~ s/^\S+ :?//; + + if (Irssi::settings_get_bool('sasl_disconnect_on_fail')) { + $server->print('', "$data - disconnecting from server", MSGLEVEL_CLIENTERROR); + $server->disconnect(); + } else { + $server->print('', "$data - continuing anyway"); + if (!$server->{connected}) { + $server->send_raw_now("CAP END"); + } + } +} + +sub timeout { + my $tag = shift; + my $server = Irssi::server_find_tag($tag); + if ($server && !$server->{connected}) { + $server->print('', "SASL: authentication timed out", MSGLEVEL_CLIENTERROR); + $server->send_raw_now("CAP END"); + } +} + +sub cmd_sasl { + my ($data, $server, $item) = @_; + + if ($data ne '') { + Irssi::command_runsub ('sasl', $data, $server, $item); + } else { + cmd_sasl_show(@_); + } +} + +sub cmd_sasl_set { + my ($data, $server, $item) = @_; + + if (my ($net, $u, $p, $m) = $data =~ /^(\S+) (\S+) (\S+) (\S+)$/) { + if ($mech{uc $m}) { + $sasl_auth{$net}{user} = $u; + $sasl_auth{$net}{password} = $p; + $sasl_auth{$net}{mech} = uc $m; + Irssi::print("SASL: added $net: [$m] $sasl_auth{$net}{user} *"); + } else { + Irssi::print("SASL: unknown mechanism $m", MSGLEVEL_CLIENTERROR); + } + } elsif ($data =~ /^(\S+)$/) { + $net = $1; + if (defined($sasl_auth{$net})) { + delete $sasl_auth{$net}; + Irssi::print("SASL: deleted $net"); + } else { + Irssi::print("SASL: no entry for $net"); + } + } else { + Irssi::print("SASL: usage: /sasl set "); + } +} + +sub cmd_sasl_show { + #my ($data, $server, $item) = @_; + my @nets = keys %sasl_auth; + for my $net (@nets) { + Irssi::print("SASL: $net: [$sasl_auth{$net}{mech}] $sasl_auth{$net}{user} *"); + } + Irssi::print("SASL: no networks defined") if !@nets; +} + +sub cmd_sasl_save { + #my ($data, $server, $item) = @_; + my $file = Irssi::get_irssi_dir()."/sasl.auth"; + if (open(my $fh, ">", $file)) { + chmod(0600, $file); + for my $net (keys %sasl_auth) { + printf $fh ("%s\t%s\t%s\t%s\n", + $net, + $sasl_auth{$net}{user}, + $sasl_auth{$net}{password}, + $sasl_auth{$net}{mech}); + } + close($fh); + Irssi::print("SASL: auth saved to '$file'"); + } else { + Irssi::print("SASL: couldn't access '$file': $@"); + } +} + +sub cmd_sasl_load { + #my ($data, $server, $item) = @_; + my $file = Irssi::get_irssi_dir()."/sasl.auth"; + if (open(my $fh, "<", $file)) { + %sasl_auth = (); + while (<$fh>) { + chomp; + my ($net, $u, $p, $m) = split(/\t/, $_, 4); + $m ||= "PLAIN"; + if ($mech{uc $m}) { + $sasl_auth{$net}{user} = $u; + $sasl_auth{$net}{password} = $p; + $sasl_auth{$net}{mech} = uc $m; + } else { + Irssi::print("SASL: unknown mechanism $m", MSGLEVEL_CLIENTERROR); + } + } + close($fh); + Irssi::print("SASL: cap_sasl $VERSION, auth loaded from '$file'"); + } +} + +sub cmd_sasl_mechanisms { + Irssi::print("SASL: mechanisms supported: " . join(", ", sort keys %mech)); +} + +Irssi::settings_add_bool('server', 'sasl_disconnect_on_fail', 1); + +Irssi::signal_add_first('server connected', \&server_connected); +Irssi::signal_add('event cap', \&event_cap); +Irssi::signal_add('event authenticate', \&event_authenticate); +Irssi::signal_add('event 903', \&event_saslend); +Irssi::signal_add('event 904', \&event_saslfail); +Irssi::signal_add('event 905', \&event_saslend); +Irssi::signal_add('event 906', \&event_saslfail); +Irssi::signal_add('event 907', \&event_saslend); + +Irssi::command_bind('sasl', \&cmd_sasl); +Irssi::command_bind('sasl load', \&cmd_sasl_load); +Irssi::command_bind('sasl save', \&cmd_sasl_save); +Irssi::command_bind('sasl set', \&cmd_sasl_set); +Irssi::command_bind('sasl show', \&cmd_sasl_show); +Irssi::command_bind('sasl mechanisms', \&cmd_sasl_mechanisms); + +$mech{PLAIN} = sub { + my ($sasl, $data) = @_; + my $u = $sasl->{user}; + my $p = $sasl->{password}; + return join("\0", $u, $u, $p); +}; + +$mech{EXTERNAL} = sub { + my ($sasl, $data) = @_; + return $sasl->{user} // ""; +}; + +if (eval {require Crypt::PK::ECC}) { + $mech{'ECDSA-NIST256P-CHALLENGE'} = sub { + my ($sasl, $data) = @_; + my $u = $sasl->{user}; + my $k = $sasl->{password}; + if ($k !~ m!^/!) { + $k = Irssi::get_irssi_dir()."/".$k; + } + if (!-f $k) { + Irssi::print("SASL: key file '$k' not found", MSGLEVEL_CLIENTERROR); + return; + } + my $pk = eval {Crypt::PK::ECC->new($k)}; + if ($@ || !$pk || !$pk->is_private) { + Irssi::print("SASL: no private key in file '$k'", MSGLEVEL_CLIENTERROR); + return; + } + my $step = ++$sasl->{step}; + if ($step == 1) { + if (length $data == CHALLENGE_SIZE) { + my $sig = $pk->sign_hash($data); + return $u."\0".$u."\0".$sig; + } elsif (length $data) { + return; + } else { + return $u."\0".$u; + } + } + elsif ($step == 2) { + if (length $data == CHALLENGE_SIZE) { + return $pk->sign_hash($data); + } else { + return; + } + } + }; + + sub cmd_sasl_keygen { + my ($data, $server, $witem) = @_; + + my $mech = "ECDSA-NIST256P-CHALLENGE"; + my $net; + my $print; + + if ($server) { + $net = $server->{tag}; + $print = sub { $server->print("", shift) }; + } else { + $net = $data; + $print = sub { Irssi::print(shift) }; + } + + if (!length $net) { + $print->("Please connect to a server first."); + return; + } + + my $f_name = lc "sasl-ecdsa-$net"; + $f_name =~ s![ /]+!_!g; + my $f_priv = Irssi::get_irssi_dir()."/$f_name.key"; + my $f_pub = Irssi::get_irssi_dir()."/$f_name.pub"; + if (-e $f_priv) { + $print->("SASL: refusing to overwrite '$f_priv'"); + return; + } + + $print->("SASL: generating keypair for '$net'..."); + my $pk = Crypt::PK::ECC->new; + $pk->generate_key("prime256v1"); + + my $priv = $pk->export_key_pem("private"); + my $pub = encode_base64($pk->export_key_raw("public_compressed"), ""); + my $cmd = "/msg NickServ SET PROPERTY pubkey $pub"; + + if (open(my $fh, ">", $f_priv)) { + chmod(0600, $f_priv); + print $fh $priv; + close($fh); + $print->("SASL: wrote private key to '$f_priv'"); + } else { + $print->("SASL: could not write '$f_priv': $!"); + return; + } + + if (open(my $fh, ">", $f_pub)) { + print $fh $pub."\n"; + close($fh); + } else { + $print->("SASL: could not write '$f_pub': $!"); + } + + if ($server) { + $print->("SASL: updating your Irssi settings..."); + $sasl_auth{$net}{user} //= $server->{nick}; + $sasl_auth{$net}{password} = "$f_name.key"; + $sasl_auth{$net}{mech} = $mech; + cmd_sasl_save(@_); + + $print->("SASL: submitting key to NickServ..."); + $server->command($cmd); + } else { + $print->("SASL: update your Irssi settings:"); + $print->("%P/sasl set $net $f_name.key $mech"); + + $print->("SASL: submit your public key to $net:"); + $print->("%P$cmd"); + } + } + + Irssi::command_bind('sasl keygen', \&cmd_sasl_keygen); +}; + +cmd_sasl_load(); + +# vim: ts=4:sw=4 -- cgit v1.2.3 From aee64e31a503530d1ad44ae86dbeb9c0fe9fe143 Mon Sep 17 00:00:00 2001 From: Mantas Mikulėnas Date: Thu, 18 Dec 2014 22:59:16 +0200 Subject: cap_sasl 1.9: support different cmdchars --- scripts/cap_sasl.pl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/cap_sasl.pl b/scripts/cap_sasl.pl index ad6df45..a9dc237 100644 --- a/scripts/cap_sasl.pl +++ b/scripts/cap_sasl.pl @@ -4,7 +4,7 @@ use MIME::Base64; use vars qw($VERSION %IRSSI); use constant CHALLENGE_SIZE => 32; -$VERSION = "1.8a"; +$VERSION = "1.9"; %IRSSI = ( authors => 'Michael Tharp (gxti), Jilles Tjoelker (jilles), Mantas Mikulėnas (grawity)', contact => 'grawity@gmail.com', @@ -340,7 +340,9 @@ if (eval {require Crypt::PK::ECC}) { my $priv = $pk->export_key_pem("private"); my $pub = encode_base64($pk->export_key_raw("public_compressed"), ""); - my $cmd = "/msg NickServ SET PROPERTY pubkey $pub"; + + my $cmdchar = substr(Irssi::settings_get_str("cmdchars"), 0, 1); + my $cmd = "msg NickServ SET PROPERTY pubkey $pub"; if (open(my $fh, ">", $f_priv)) { chmod(0600, $f_priv); @@ -370,10 +372,10 @@ if (eval {require Crypt::PK::ECC}) { $server->command($cmd); } else { $print->("SASL: update your Irssi settings:"); - $print->("%P/sasl set $net $f_name.key $mech"); + $print->("%P".$cmdchar."sasl set $net $f_name.key $mech"); $print->("SASL: submit your public key to $net:"); - $print->("%P$cmd"); + $print->("%P".$cmdchar.$cmd); } } -- cgit v1.2.3 From 40994b2724d52631a2bd74ea7a5bab50d51b45a4 Mon Sep 17 00:00:00 2001 From: aapa Date: Sat, 20 Dec 2014 18:54:59 +0200 Subject: $STY won't get changed if sessionname is changed during the session, worked around it --- scripts/screen_away.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/screen_away.pl b/scripts/screen_away.pl index 86e3087..b1f913d 100644 --- a/scripts/screen_away.pl +++ b/scripts/screen_away.pl @@ -18,6 +18,7 @@ $VERSION = "0.9.7.1"; # written by Andreas 'ads' Scherbaum # # changes: +# 20.12.2014 fix the bug when screenname is changed during the session # 07.02.2004 fix error with away mode # thanks to Michael Schiansky for reporting and fixing this one # 07.08.2004 new function for changing nick on away @@ -83,7 +84,7 @@ if (!defined($ENV{STY})) { return; } -my ($socket_name, $socket_path); +my ($socket_pid, $socket_name, $socket_path); # search for socket # normal we could search the socket file, ... if we know the path @@ -99,9 +100,13 @@ my $running_in_screen = 0; # locale doesnt seems to be an problem (yet) if ($socket !~ /^No Sockets found/s) { # ok, should have only one socket - $socket_name = $ENV{'STY'}; + # $STY won't change if sessionname is changed during session + # therefore first find the pid and use that to find the actual sessionname + $socket_pid = substr($ENV{'STY'}, 0, index($ENV{'STY'}, '.')); $socket_path = $socket; $socket_path =~ s/^.+\d+ Sockets? in ([^\n]+)\.\n.+$/$1/s; + $socket_name = $socket; + $socket_name =~ s/^.+?($socket_pid\.\S+).+$/$1/s; if (length($socket_path) != length($socket)) { # only activate, if string length is different # (to make sure, we really got a dir name) -- cgit v1.2.3 From 5b9a4d686fb2905dd2463be309a0dc9a8d275d41 Mon Sep 17 00:00:00 2001 From: aapa Date: Sat, 20 Dec 2014 20:38:24 +0200 Subject: Updated version number to script and scripts.yml, it was difficult to decide what part I should increase --- scripts/screen_away.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/screen_away.pl b/scripts/screen_away.pl index b1f913d..722ceed 100644 --- a/scripts/screen_away.pl +++ b/scripts/screen_away.pl @@ -4,7 +4,7 @@ use FileHandle; use vars qw($VERSION %IRSSI); -$VERSION = "0.9.7.1"; +$VERSION = "0.9.8.1"; %IRSSI = ( authors => 'Andreas \'ads\' Scherbaum ', name => 'screen_away', -- cgit v1.2.3 From 1966c07afa2c77e0da59a60b34b1a9e12eadcbde Mon Sep 17 00:00:00 2001 From: Pablo Martín Báez Echevarría Date: Sat, 20 Dec 2014 22:35:14 -0200 Subject: Add clones_scanner.pl --- scripts/clones_scanner.pl | 297 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 scripts/clones_scanner.pl (limited to 'scripts') diff --git a/scripts/clones_scanner.pl b/scripts/clones_scanner.pl new file mode 100644 index 0000000..1f31fbb --- /dev/null +++ b/scripts/clones_scanner.pl @@ -0,0 +1,297 @@ +use strict; +use warnings; + +{ package Irssi::Nick } +# just in case, to avoid Irssi::Nick warnings ( see http://bugs.irssi.org/index.php?do=details&task_id=242 ) + +use Irssi; +use vars qw($VERSION %IRSSI); + +# Thanks to noi_esportista!#Girona@chathispano for his suggestions about how this script should work. + +$VERSION = '1.5'; +%IRSSI = ( + authors => 'Pablo Martín Báez Echevarría', + contact => 'pab_24n@outlook.com', + name => 'clones_scanner', + description => 'when a nick joins #channel, notifies you if there is (or there has been) someone in #channel with the same hostname', + license => 'Public Domain', + url => 'http://reirssi.wordpress.com', + changed => '22:30:25, Dec 20th, 2014 UYT', +); + +# +# USAGE +# ===== +# Copy the script to ~/.irssi/scripts/ +# +# In irssi: +# /run clones_scanner +# +# +# OPTIONS +# ======= +# Settings can be resetted to defaults with /set -default +# +# /set clones_scanner_maxtime