aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feature-tests/key_sig.pl26
-rw-r--r--fixery/awayproxy.pl22
-rw-r--r--flood-detect/flood_detect.pl8
-rw-r--r--growl-notify/growl_notify.pl20
-rw-r--r--longify/longify-urls.pl85
5 files changed, 134 insertions, 27 deletions
diff --git a/feature-tests/key_sig.pl b/feature-tests/key_sig.pl
index ef69d45..3da50ac 100644
--- a/feature-tests/key_sig.pl
+++ b/feature-tests/key_sig.pl
@@ -25,12 +25,22 @@ Irssi::signal_add('key created', \&sig_key_created);
Irssi::signal_register({'key command' => [qw/string/]});
Irssi::signal_add_first('key command' => \&sig_key_cmd);
+Irssi::signal_register({'key key' => [qw/string/]});
+Irssi::signal_add_first('key key' => \&sig_key_key);
+
Irssi::signal_register({'key nothing' => [qw/string/]});
-Irssi::signal_add_first('key nothing' => \&sig_key_cmd);
+Irssi::signal_add_first('key nothing' => \&sig_key_nothing);
Irssi::signal_register({'keyboard created' => [qw/Irssi::UI::Keyboard/]});
Irssi::signal_add_first('keyboard created' => \&sig_keyboard);
+Irssi::signal_register({'key bacon' => [qw/string int int/]});
+Irssi::signal_add_first('key bacon' => \&sig_key_bacon);
+
+sub sig_key_bacon {
+ print "baconkey: " . Dumper(\@_);
+}
+
sub sig_keyboard {
my ($data) = @_;
print "keyboard: " . Dumper($data);
@@ -42,10 +52,22 @@ sub sig_key_cmd {
}
+sub sig_key_nothing {
+ my ($data) = @_;
+ print "key nothing: " . Dumper($data);
+
+}
+
+sub sig_key_key {
+ my ($data) = @_;
+ print "key key: " . Dumper($data);
+
+}
+
sub sig_key_created {
my @args = @_;
print "Key Created, Args: " . Dumper(\@args);
}
-Irssi::command("bind meta-q /echo moo");
+Irssi::command("bind meta-q key bacon");
diff --git a/fixery/awayproxy.pl b/fixery/awayproxy.pl
index b60eff4..d0b33dd 100644
--- a/fixery/awayproxy.pl
+++ b/fixery/awayproxy.pl
@@ -9,7 +9,7 @@
## Other hand if you dont use irssi-proxy you still have a good reason to
## use this if you want to forward messages that come to you while
## you are away to email box.
-## This is usefull for forwarding messages to an SMS-gateway ;)
+## This is useful for forwarding messages to an SMS-gateway ;)
##
## btw.. if you find any bugs or have any ideas for development of this
## script dont hesitate to send msg to BCOW@IrcNET
@@ -311,7 +311,19 @@ sub msg_pri {
}
}
-Irssi::signal_add_last('proxy client connected', \&client_connect);
-Irssi::signal_add_last('proxy client disconnected', \&client_disconnect);
-Irssi::signal_add_last('message public', \&msg_pub);
-Irssi::signal_add_last('message private', \&msg_pri);
+sub init {
+
+ Irssi::settings_add_string('awayproxy', 'awayproxy_send_mode', MODE_EMAIL);
+
+ Irssi::signal_add_last('proxy client connected', \&sig_client_connect);
+ Irssi::signal_add_last('proxy client disconnected', \&sig_client_disconnect);
+ Irssi::signal_add_last('message public', \&sig_msg_public);
+ Irssi::signal_add_last('message private', \&sig_msg_private);
+ Irssi::signal_add('setup changed', \&sig_setup_changed);
+
+ sig_setup_changed();
+}
+
+sub sig_setup_changed {
+ # load values from settings.
+}
diff --git a/flood-detect/flood_detect.pl b/flood-detect/flood_detect.pl
index f34c7ae..d2eeb95 100644
--- a/flood-detect/flood_detect.pl
+++ b/flood-detect/flood_detect.pl
@@ -72,6 +72,8 @@ our %IRSSI = (
my $NAME = $IRSSI{name};
my $DEBUG = 0;
+my $activity;
+
sub DEBUG () { $DEBUG }
sub setup_changed {
@@ -111,6 +113,12 @@ sub init {
init();
+sub update_activity {
+ my ($nick, $channel, $server) = @_;
+}
+
+sub prune_activity_list {
+}
sub apply_flood_action {
diff --git a/growl-notify/growl_notify.pl b/growl-notify/growl_notify.pl
index 47a85bc..604c027 100644
--- a/growl-notify/growl_notify.pl
+++ b/growl-notify/growl_notify.pl
@@ -50,13 +50,29 @@ THE SOFTWARE.
=item *
-
+Stuff.
=back
-
=cut
+# Plan
+# Notes
+# * Main target is remote screen+irssi, accessed via ssh on local OSX/iTerm2
+# (Because that's what I use :p)
+# * Might work on windows (growl has windows port afaik)
+# * iterm active feature: "[iterm2-discuss] iTerm2 1.0.0.20111020 canary released"
+# "Add support for reporting focus lost/gained. esc[?1004h turns it on;
+# then the terminal sends esc[I when focusing, esc[O when de-focusing.
+# Send esc[?1004l to disable."
+
+# Main features are:
+# * detect activity from irssi similarly to existing activity (crap, text, hilight)
+# * configurable white/blacklists for nicks, masks, activities?
+# * use the Growl remote protocol (GNTP) via optional ssh backchannel?
+# * easy to configure other parts (ssh tunnel, etc?)
+
+
use strict;
use warnings;
diff --git a/longify/longify-urls.pl b/longify/longify-urls.pl
index cd36503..83adc36 100644
--- a/longify/longify-urls.pl
+++ b/longify/longify-urls.pl
@@ -104,7 +104,13 @@ my $pending_msg_params = {};
my $lookup_in_progress;
my $flushing_message;
my $domains;
+my $DEBUG;
+sub _debug_print($) {
+ return unless $DEBUG;
+ my ($msg) = @_;
+ Irssi::active_win->print($msg, MSGLEVEL_CLIENTCRAP);
+}
sub sig_public_message {
_handle_messages(@_);
@@ -116,7 +122,7 @@ sub sig_private_message {
sub _handle_messages {
- my $msg = $_[1];
+ my ($server, $msg) = @_;
if ($flushing_message) { # don't interrupt it a second time.
delete $pending_msg_params->{$flushing_message};
@@ -139,11 +145,13 @@ sub _handle_messages {
$pending_msg_params->{$url} = [@_];
$lookup_in_progress = 1;
+
expand_url($url);
- Irssi::signal_stop;
+ Irssi::signal_stop if $server;
}
+
sub expand_url {
my ($url) = @_;
fork_off $url, \&expand_url_request, \&expand_url_callback;
@@ -158,16 +166,28 @@ sub expand_url_request {
$user_agent->timeout(2); # TODO: make this a setting.
$user_agent->max_size(0);
my $request = HTTP::Request->new(GET => $url);
- my $result = $user_agent->request($request);
-
- print "$url\n";
-
- if ($result->is_error) {
+ my $result = $user_agent->simple_request($request);
+
+ if ($result->is_redirect) {
+ my $location = $result->header('Location');
+ if ($location) {
+ print "$location\n";
+ } else {
+ print "ERROR: no Location header\n";
+ }
+ } elsif ($result->is_error) {
print "ERROR: " . $result->as_string . "\n";
- return;
+ } elsif ($result->is_success) {
+ print "$url\n";
}
+#elsif ($result->is_success) {
+ # print "
+# return;
+# }
+
my @redirects = $result->redirects;
+ #_debug_print(join (" => ", map { $_->header('Location') } @redirects));
if (@redirects) {
print $redirects[-1]->header('Location') . "\n";
}
@@ -177,26 +197,40 @@ sub expand_url_callback {
my ($result) = @_;
chomp $result;
+
my ($orig_url, $long_url) = split /\n/, $result;
$long_url = '' unless $long_url;
+
+ # l/rtrim to clean up whitespace
$long_url =~ s/\s*(\S*)\s*/$1/;
my $pending_message_data = $pending_msg_params->{$orig_url};
my @new_signal = @$pending_message_data;
- #Irssi::print("Result: orignal: $orig_url, new: $long_url");
-
- if ($long_url && $long_url !~ /^ERROR/ && $long_url ne $orig_url) {
- $new_signal[1] =~ s/\Q$orig_url\E/$long_url [was: $orig_url]/;
- #print "Printing with: " . Dumper(@new_signal[1..$#new_signal]);
- } elsif ($long_url && $long_url =~ /^ERROR/) {
- $new_signal[1] =~ s/\Q$orig_url\E/$long_url while expanding "$orig_url"/;
+ _debug_print("Result: orignal: $orig_url, new: $long_url");
+
+ if ($long_url) {
+ if ($long_url !~ /^ERROR/ && $long_url ne $orig_url) {
+ $new_signal[1]
+ =~ s/\Q$orig_url\E/$long_url [was: $orig_url]/;
+ _debug_print("Printing with: "
+ . Dumper(@new_signal[1..$#new_signal]));
+ } elsif ($long_url =~ /^ERROR/) {
+ $new_signal[1]
+ =~ s/\Q$orig_url\E/$long_url while expanding "$orig_url"/;
+ }
}
- $flushing_message = $orig_url;
- Irssi::signal_emit 'message public', @new_signal;
+ if (defined $new_signal[0]) {
+ $flushing_message = $orig_url;
+ Irssi::signal_emit 'message public', @new_signal;
+ } else {
+ delete $pending_msg_params->{$orig_url};
+ Irssi::print("URL: $orig_url expands to $new_signal[1]");
+ }
+ $lookup_in_progress = 0;
}
sub match_uri {
@@ -244,7 +278,7 @@ sub match_uri {
}
sub cmd_reload {
- my $filename = shift
+ my $filename = shift
|| File::Spec->catfile(Irssi::get_irssi_dir, 'longify-urls.list');
$domains = {};
open my $fh, '<', $filename
@@ -257,16 +291,31 @@ sub cmd_reload {
Irssi::active_win->print('%_Longify:%_ List of domains has been reloaded.');
}
+sub cmd_longify {
+ my ($args, $server, $witem) = @_;
+
+ # _handle_messages expects $_[1] to contain message content.
+ _handle_messages(undef, $args);
+}
+
sub init {
+ Irssi::settings_add_bool 'longify', 'longify-debug', 0;
+
Irssi::signal_add_first 'message public', \&sig_public_message;
Irssi::signal_add_first 'message private', \&sig_private_message;
Irssi::signal_add 'setup changed', \&sig_setup_changed;
Irssi::command_bind 'longify-reload', \&cmd_reload;
+ Irssi::command_bind 'longify', \&cmd_longify;
cmd_reload();
+ sig_setup_changed();
}
sub sig_setup_changed {
+
+ $DEBUG = Irssi::settings_get_bool 'longify-debug';
+ $DEBUG = 0 unless defined $DEBUG;
+
# TODO: settings updating stuff goes here.
}