aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--auto-server/auto_server.pl13
-rw-r--r--feature-tests/getchan.pl165
-rw-r--r--longify/longify-urls.pl21
3 files changed, 185 insertions, 14 deletions
diff --git a/auto-server/auto_server.pl b/auto-server/auto_server.pl
index 447a131..c409e5d 100644
--- a/auto-server/auto_server.pl
+++ b/auto-server/auto_server.pl
@@ -104,8 +104,8 @@ sub haxy_print_hook {
sub parse_channel_map {
#my $data = Irssi::settings_get_str('joinplus_server_maps');
- unbind_completion();
my $data = retrieve_channels();
+ unbind_completion();
my @items = split /\s+/, $data;
if (@items % 2 == 0) {
$channel_map = { @items }; # risky?
@@ -209,13 +209,14 @@ sub do_channel_join {
my $channel = $pending_joins->{$serv->{address}};
$channel = $pending_joins->{$serv->{tag}} unless $channel;
+ if ($channel) {
+ _debug_print ("attempting to join $channel");
- _debug_print ("attempting to join $channel");
+ Irssi::server_find_tag($serv->{tag})->command("JOIN $channel");
- Irssi::server_find_tag($serv->{tag})->command("JOIN $channel");
-
- delete $pending_joins->{$serv->{address}};
- delete $pending_joins->{$serv->{tag}};
+ delete $pending_joins->{$serv->{address}};
+ delete $pending_joins->{$serv->{tag}};
+ }
}
diff --git a/feature-tests/getchan.pl b/feature-tests/getchan.pl
new file mode 100644
index 0000000..7d4ee55
--- /dev/null
+++ b/feature-tests/getchan.pl
@@ -0,0 +1,165 @@
+=pod
+
+=head1 NAME
+
+template.pl
+
+=head1 DESCRIPTION
+
+A minimalist template useful for basing actual scripts on.
+
+=head1 INSTALLATION
+
+Copy into your F<~/.irssi/scripts/> directory and load with
+C</SCRIPT LOAD F<filename>>.
+
+=head1 USAGE
+
+None, since it doesn't actually do anything.
+
+=head1 AUTHORS
+
+Copyright E<copy> 2011 Tom Feist C<E<lt>shabble+irssi@metavore.orgE<gt>>
+
+=head1 LICENCE
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+=head1 BUGS
+
+=head1 TODO
+
+Use this template to make an actual script.
+
+=cut
+
+use strict;
+use warnings;
+
+use Irssi;
+use Irssi::Irc;
+use Irssi::TextUI;
+
+use Data::Dumper;
+
+our $VERSION = '0.1';
+our %IRSSI = (
+ authors => 'shabble',
+ contact => 'shabble+irssi@metavore.org',
+ name => '',
+ description => '',
+ license => 'MIT',
+ updated => '$DATE'
+ );
+
+
+my $line_format;
+my $head_format;
+my $foot_format;
+
+my $channels = {};
+my @errors;
+my $state;
+
+sub get_format_string {
+ return Irssi::current_theme->get_format(@_);
+}
+
+
+sub get_channels {
+ # see here: https://github.com/shabble/irssi-docs/wiki/complete_themes
+ $line_format = get_format_string('fe-common/core', 'chansetup_line');
+ $head_format = get_format_string('fe-common/core', 'chansetup_header');
+ $foot_format = get_format_string('fe-common/core', 'chansetup_footer');
+
+ my $parse_line_format = "channel:\$0\tnet:\$1\tpass:\$2\tsettings:\$3";
+ Irssi::command("^FORMAT chansetup_line $parse_line_format");
+ Irssi::command("^FORMAT chansetup_header START");
+ Irssi::command("^FORMAT chansetup_footer END");
+
+ $state = 0;
+ Irssi::signal_add_first('print text', 'sig_print_text');
+ Irssi::command("CHANNEL LIST");
+ Irssi::signal_remove('print text', 'sig_print_text');
+
+}
+
+sub restore_formats {
+ Irssi::command("^FORMAT chansetup_line $line_format");
+ Irssi::command("^FORMAT chansetup_header $head_format");
+ if ($foot_format =~ m/^\s*$/) {
+ Irssi::command("^FORMAT -reset chansetup_footer");
+ } else {
+ Irssi::command("^FORMAT chansetup_footer $foot_format");
+ }
+}
+
+sub sig_print_text {
+ my ($dest, $text, $stripped) = @_;
+
+ my $entry = {};
+
+ if ($state == 0 && $text =~ m/START/) {
+ $state = 1;
+ } elsif ($state == 1) {
+ # TODO: might we get multiple lines at once?
+ if ($text =~ m/channel:([^\t]+)\tnet:([^\t]+)\tpass:([^\t]*)\tsettings:(.*)$/) {
+ $entry->{channel} = $1;
+ $entry->{network} = $2;
+ $entry->{password} = $3;
+ $entry->{settings} = $4;
+
+ my $tag = "$2/$1";
+ $channels->{$tag} = $entry;
+
+ } elsif ($text =~ m/END/) {
+ $state = 0;
+ } else {
+ push @errors, "Failed to parse: '$text'";
+ }
+ }
+ Irssi::signal_stop();
+}
+
+sub go {
+ eval {
+ get_channels();
+ };
+ if ($@) {
+ print "Error: $@. Reloading theme to restore format";
+ Irssi::themes_reload();
+ } else {
+ restore_formats();
+ }
+ if (@errors) {
+ @errors = map { s/\t/ /g } @errors;
+ print Dumper(\@errors);
+ }
+ print Dumper($channels);
+}
+
+Irssi::command_bind('getchan', \&go);
+# in fe-common/core
+#
+# chansetup_not_found = "Channel {channel $0} not found";
+# chansetup_added = "Channel {channel $0} saved";
+# chansetup_removed = "Channel {channel $0} removed";
+# chansetup_header = "%#Channel Network Password Settings";
+# chansetup_line = "%#{channel $[15]0} %|$[10]1 $[10]2 $3";
+# chansetup_footer = "";
diff --git a/longify/longify-urls.pl b/longify/longify-urls.pl
index 8b2691f..38e8ba8 100644
--- a/longify/longify-urls.pl
+++ b/longify/longify-urls.pl
@@ -87,6 +87,7 @@ use Data::Dumper;
use IrssiX::Async qw(fork_off);
use LWP::UserAgent;
use URI;
+use File::Spec;
our $VERSION = '0.1';
our %IRSSI = (
@@ -106,7 +107,16 @@ my $domains;
sub sig_public_message {
- my ($server, $msg, @rest) = @_;
+ _handle_messages(@_);
+}
+
+sub sig_private_message {
+ _handle_messages(@_);
+}
+
+sub _handle_messages {
+
+ my $msg = $_[1];
if ($flushing_message) { # don't interrupt it a second time.
delete $pending_msg_params->{$flushing_message};
@@ -129,12 +139,6 @@ sub sig_public_message {
Irssi::signal_stop;
}
-sub sig_private_message {
- my ($server, $msg, $nick, $addr, $target) = @_;
-
-}
-
-
sub expand_url {
my ($url) = @_;
fork_off $url, \&expand_url_request, \&expand_url_callback;
@@ -235,7 +239,8 @@ sub match_uri {
}
sub cmd_reload {
- my $filename = shift || Irssi::get_irssi_dir . '/longify-urls.list';
+ my $filename = shift
+ || File::Spec->catfile(Irssi::get_irssi_dir, 'longify-urls.list');
$domains = {};
open my $fh, '<', $filename
or die "Couldn't open file containing shorteners list $filename: $!";