Permalink
Browse files

update configs(mostly for irssi)

  • Loading branch information...
1 parent 521d2ba commit b2d7dcad61c86966f939c49f38b6083ab9833c24 @linsong committed Mar 7, 2007
View
1 .inputrc
@@ -18,6 +18,7 @@
# add by wangwei on 2004/2/27
set meta-flag on
set convert-meta off
+set input-meta on
set output-meta on
# ignore case while completing
set completion-ignore-case on
View
137 .irssi/config
@@ -1,6 +1,20 @@
servers = (
- { address = "irc.exoweb.net"; chatnet = "WorkIRCnet"; port = "6667"; },
- { address = "im.bitlbee.org"; chatnet = "BitBeeIRCnet"; port = "6667"; },
+ {
+ address = "irc.exoweb.net";
+ chatnet = "WorkIRCnet";
+ port = "6667";
+ use_ssl = "no";
+ ssl_verify = "no";
+ autoconnect = "yes";
+ },
+ {
+ address = "im.bitlbee.org";
+ chatnet = "BitlBeeIRCnet";
+ port = "6667";
+ use_ssl = "no";
+ ssl_verify = "no";
+ autoconnect = "yes";
+ },
{ address = "irc.stealth.net"; chatnet = "IRCnet"; port = "6668"; },
{ address = "irc.efnet.net"; chatnet = "EFNet"; port = "6667"; },
{
@@ -15,6 +29,14 @@ servers = (
port = "6667";
},
{ address = "silc.silcnet.org"; chatnet = "SILC"; port = "706"; },
+ {
+ address = "irc.freenode.net";
+ chatnet = "IRCnet";
+ port = "6667";
+ use_ssl = "no";
+ ssl_verify = "no";
+ autoconnect = "yes";
+ }
);
# for one chatnet, we can define multiple servers, so when we
@@ -37,7 +59,7 @@ chatnets = {
max_whois = "4";
max_query_chans = "5";
};
- BitBeeIRCnet = {
+ BitlBeeIRCnet = {
type = "IRC";
max_kicks = "4";
max_msgs = "5";
@@ -72,11 +94,11 @@ chatnets = {
};
channels = (
- { name = "#irssi"; chatnet = "ircnet"; autojoin = "No"; },
+ { name = "#irssi"; chatnet = "IRCnet"; autojoin = "yes"; },
{ name = "silc"; chatnet = "silc"; autojoin = "No"; },
- { name = "#dev"; chatnet = "IRCnet"; autojoin = "Yes"; },
- { name = "#livebet"; chatnet = "IRCnet"; autojoin = "Yes"; },
- { name = "#exoweb"; chatnet = "IRCnet"; autojoin = "Yes"; }
+ { name = "#livebet"; chatnet = "WorkIRCnet"; autojoin = "yes"; },
+ { name = "#dev"; chatnet = "WorkIRCnet"; autojoin = "yes"; },
+ { name = "#exoweb"; chatnet = "WorkIRCnet"; autojoin = "yes"; }
);
aliases = {
@@ -126,6 +148,13 @@ aliases = {
"MANUAL-WINDOWS" = "set use_status_window off;set autocreate_windows off;set autocreate_query_level none;set autoclose_windows off;set reuse_unused_windows on;save";
EXEMPTLIST = "mode $C +e";
ATAG = "WINDOW SERVER";
+ split2 = "window 3; window show 2; window size 20; window 3; window stick";
+ unstickall = "window goto 1; window stick off; window goto 2;window stick off; window goto 3; window stick off; window goto 4; window stick off; window goto 5; window stick off; window goto 6; window stick off";
+ single = "unstickall; window hide; window hide";
+ fortune = "exec - -o fortune -s ";
+ wu = "window up";
+ wd = "window down ";
+ wl = "window last ";
};
statusbar = {
@@ -240,9 +269,99 @@ statusbar = {
};
};
settings = {
- core = {
- real_name = "vincent";
+ core = {
+ real_name = "Vincent Wang";
user_name = "vincent";
nick = "vincent";
+ recode_fallback = "utf-8";
+ recode_out_default_charset = "utf-8";
};
+ "fe-common/core" = { print_active_channel = "no"; };
};
+keyboard = (
+ { key = "^F"; id = "forward_character"; data = ""; },
+ { key = "^B"; id = "backward_character"; data = ""; },
+ { key = "^W"; id = "key"; data = "window "; },
+ { key = "window-^C"; id = "command"; data = "WINDOW NEW SPLIT"; },
+ { key = "window-^K"; id = "command"; data = "WINDOW UP"; },
+ { key = "window-^J"; id = "command"; data = "WINDOW DOWN"; },
+ { key = "^X"; id = "active_window"; data = ""; }
+);
+hilights = (
+ { text = "ISSUE"; color = "%R"; nick = "no"; word = "yes"; },
+ {
+ text = "vincent.*";
+ color = "%R%4";
+ act_color = "%R";
+ priority = "9";
+ nick = "no";
+ word = "no";
+ },
+ {
+ text = "scrum";
+ color = "%5";
+ act_color = "%M";
+ nick = "no";
+ word = "yes";
+ }
+);
+windows = {
+ 3 = {
+ items = (
+ {
+ type = "CHANNEL";
+ chat_type = "IRC";
+ name = "#livebet";
+ tag = "WorkIRCnet";
+ }
+ );
+ sticky = "yes";
+ };
+ 1 = { immortal = "yes"; name = "(status)"; level = "ALL"; };
+ 2 = {
+ items = (
+ {
+ type = "CHANNEL";
+ chat_type = "IRC";
+ name = "#dev";
+ tag = "WorkIRCnet";
+ }
+ );
+ sticky = "yes";
+ };
+ 6 = { name = "hilight"; sticky = "yes"; parent = "3"; };
+ 5 = {
+ items = (
+ {
+ type = "CHANNEL";
+ chat_type = "IRC";
+ name = "&bitlbee";
+ tag = "BitlBeeIRCnet";
+ }
+ );
+ };
+ 4 = {
+ items = (
+ {
+ type = "CHANNEL";
+ chat_type = "IRC";
+ name = "#exoweb";
+ tag = "WorkIRCnet";
+ }
+ );
+ };
+};
+mainwindows = {
+ 3 = { first_line = "22"; lines = "22"; };
+ 2 = { first_line = "1"; lines = "21"; };
+};
+ignores = (
+ { mask = "*zzz*"; level = "NICKS"; },
+ {
+ level = "ACTIONS";
+ pattern = "is (away|gone|back)";
+ regexp = "yes";
+ },
+ { mask = "*afk*"; level = "NICKS"; },
+ { mask = "*away*"; level = "NICKS"; }
+);
View
294 .irssi/default.theme
@@ -0,0 +1,294 @@
+# When testing changes, the easiest way to reload the theme is with /RELOAD.
+# This reloads the configuration file too, so if you did any changes remember
+# to /SAVE it first. Remember also that /SAVE overwrites the theme file with
+# old data so keep backups :)
+
+# TEMPLATES:
+
+# The real text formats that irssi uses are the ones you can find with
+# /FORMAT command. Back in the old days all the colors and texts were mixed
+# up in those formats, and it was really hard to change the colors since you
+# might have had to change them in tens of different places. So, then came
+# this templating system.
+
+# Now the /FORMATs don't have any colors in them, and they also have very
+# little other styling. Most of the stuff you need to change is in this
+# theme file. If you can't change something here, you can always go back
+# to change the /FORMATs directly, they're also saved in these .theme files.
+
+# So .. the templates. They're those {blahblah} parts you see all over the
+# /FORMATs and here. Their usage is simply {name parameter1 parameter2}.
+# When irssi sees this kind of text, it goes to find "name" from abstracts
+# block below and sets "parameter1" into $0 and "parameter2" into $1 (you
+# can have more parameters of course). Templates can have subtemplates.
+# Here's a small example:
+# /FORMAT format hello {colorify {underline world}}
+# abstracts = { colorify = "%G$0-%n"; underline = "%U$0-%U"; }
+# When irssi expands the templates in "format", the final string would be:
+# hello %G%Uworld%U%n
+# ie. underlined bright green "world" text.
+# and why "$0-", why not "$0"? $0 would only mean the first parameter,
+# $0- means all the parameters. With {underline hello world} you'd really
+# want to underline both of the words, not just the hello (and world would
+# actually be removed entirely).
+
+# COLORS:
+
+# You can find definitions for the color format codes in docs/formats.txt.
+
+# There's one difference here though. %n format. Normally it means the
+# default color of the terminal (white mostly), but here it means the
+# "reset color back to the one it was in higher template". For example
+# if there was /FORMAT test %g{foo}bar, and foo = "%Y$0%n", irssi would
+# print yellow "foo" (as set with %Y) but "bar" would be green, which was
+# set at the beginning before the {foo} template. If there wasn't the %g
+# at start, the normal behaviour of %n would occur. If you _really_ want
+# to use the terminal's default color, use %N.
+
+#############################################################################
+
+# default foreground color (%N) - -1 is the "default terminal color"
+default_color = "-1";
+
+# print timestamp/servertag at the end of line, not at beginning
+info_eol = "false";
+
+# these characters are automatically replaced with specified color
+# (dark grey by default)
+replaces = { "[]=" = "%K$*%n"; };
+
+abstracts = {
+ ##
+ ## generic
+ ##
+
+ # text to insert at the beginning of each non-message line
+ line_start = "%B-%W!%B-%n ";
+
+ # timestamp styling, nothing by default
+ timestamp = "$*";
+
+ # any kind of text that needs hilighting, default is to bold
+ hilight = "%_$*%_";
+
+ # any kind of error message, default is bright red
+ error = "%R$*%n";
+
+ # channel name is printed
+ channel = "%_$*%_";
+
+ # nick is printed
+ nick = "%_$*%_";
+
+ # nick host is printed
+ nickhost = "[$*]";
+
+ # server name is printed
+ server = "%_$*%_";
+
+ # some kind of comment is printed
+ comment = "[$*]";
+
+ # reason for something is printed (part, quit, kick, ..)
+ reason = "{comment $*}";
+
+ # mode change is printed ([+o nick])
+ mode = "{comment $*}";
+
+ ##
+ ## channel specific messages
+ ##
+
+ # highlighted nick/host is printed (joins)
+ channick_hilight = "%C$*%n";
+ chanhost_hilight = "{nickhost %c$*%n}";
+
+ # nick/host is printed (parts, quits, etc.)
+ channick = "%c$*%n";
+ chanhost = "{nickhost $*}";
+
+ # highlighted channel name is printed
+ channelhilight = "%c$*%n";
+
+ # ban/ban exception/invite list mask is printed
+ ban = "%c$*%n";
+
+ ##
+ ## messages
+ ##
+
+ # the basic styling of how to print message, $0 = nick mode, $1 = nick
+ msgnick = "%K<%n$0$1-%K>%n %|";
+
+ # message from you is printed. "msgownnick" specifies the styling of the
+ # nick ($0 part in msgnick) and "ownmsgnick" specifies the styling of the
+ # whole line.
+
+ # Example1: You want the message text to be green:
+ # ownmsgnick = "{msgnick $0 $1-}%g";
+ # Example2.1: You want < and > chars to be yellow:
+ # ownmsgnick = "%Y{msgnick $0 $1-%Y}%n";
+ # (you'll also have to remove <> from replaces list above)
+ # Example2.2: But you still want to keep <> grey for other messages:
+ # pubmsgnick = "%K{msgnick $0 $1-%K}%n";
+ # pubmsgmenick = "%K{msgnick $0 $1-%K}%n";
+ # pubmsghinick = "%K{msgnick $1 $0$2-%n%K}%n";
+ # ownprivmsgnick = "%K{msgnick $*%K}%n";
+ # privmsgnick = "%K{msgnick %R$*%K}%n";
+
+ # $0 = nick mode, $1 = nick
+ ownmsgnick = "{msgnick $0 $1-}";
+ ownnick = "%W$*%n";
+
+ # public message in channel, $0 = nick mode, $1 = nick
+ pubmsgnick = "{msgnick $0 $1-}";
+ pubnick = "%N$*%n";
+
+ # public message in channel meant for me, $0 = nick mode, $1 = nick
+ pubmsgmenick = "{msgnick $0 $1-}";
+ menick = "%Y$*%n";
+
+ # public highlighted message in channel
+ # $0 = highlight color, $1 = nick mode, $2 = nick
+ pubmsghinick = "{msgnick $1 $0$2-%n}";
+
+ # channel name is printed with message
+ msgchannel = "%K:%c$*%n";
+
+ # private message, $0 = nick, $1 = host
+ privmsg = "[%R$0%K(%r$1-%K)%n] ";
+
+ # private message from you, $0 = "msg", $1 = target nick
+ ownprivmsg = "[%r$0%K(%R$1-%K)%n] ";
+
+ # own private message in query
+ ownprivmsgnick = "{msgnick $*}";
+ ownprivnick = "%W$*%n";
+
+ # private message in query
+ privmsgnick = "{msgnick %R$*%n}";
+
+ ##
+ ## Actions (/ME stuff)
+ ##
+
+ # used internally by this theme
+ action_core = "%W * $*%n";
+
+ # generic one that's used by most actions
+ action = "{action_core $*} ";
+
+ # own action, both private/public
+ ownaction = "{action $*}";
+
+ # own action with target, both private/public
+ ownaction_target = "{action_core $0}%K:%c$1%n ";
+
+ # private action sent by others
+ pvtaction = "%W (*) $*%n ";
+ pvtaction_query = "{action $*}";
+
+ # public action sent by others
+ pubaction = "{action $*}";
+
+
+ ##
+ ## other IRC events
+ ##
+
+ # whois
+ whois = "%# $[8]0 : $1-";
+
+ # notices
+ ownnotice = "[%r$0%K(%R$1-%K)]%n ";
+ notice = "%K-%M$*%K-%n ";
+ pubnotice_channel = "%K:%m$*";
+ pvtnotice_host = "%K(%m$*%K)";
+ servernotice = "%g!$*%n ";
+
+ # CTCPs
+ ownctcp = "[%r$0%K(%R$1-%K)] ";
+ ctcp = "%g$*%n";
+
+ # wallops
+ wallop = "%W$*%n: ";
+ wallop_nick = "%n$*";
+ wallop_action = "%W * $*%n ";
+
+ # netsplits
+ netsplit = "%R$*%n";
+ netjoin = "%C$*%n";
+
+ # /names list
+ names_prefix = "";
+ names_nick = "[%_$0%_$1-] ";
+ names_nick_op = "{names_nick $*}";
+ names_nick_halfop = "{names_nick $*}";
+ names_nick_voice = "{names_nick $*}";
+ names_users = "[%g$*%n]";
+ names_channel = "%G$*%n";
+
+ # DCC
+ dcc = "%g$*%n";
+ dccfile = "%_$*%_";
+
+ # DCC chat, own msg/action
+ dccownmsg = "[%r$0%K($1-%K)%n] ";
+ dccownnick = "%R$*%n";
+ dccownquerynick = "%W$*%n";
+ dccownaction = "{action $*}";
+ dccownaction_target = "{action_core $0}%K:%c$1%n ";
+
+ # DCC chat, others
+ dccmsg = "[%G$1-%K(%g$0%K)%n] ";
+ dccquerynick = "%G$*%n";
+ dccaction = "%W (*dcc*) $*%n %|";
+
+ ##
+ ## statusbar
+ ##
+
+ # default background for all statusbars. You can also give
+ # the default foreground color for statusbar items.
+ sb_background = "%4%w";
+
+ # default backround for "default" statusbar group
+ #sb_default_bg = "%4";
+ # background for prompt / input line
+ sb_prompt_bg = "%n";
+ # background for info statusbar
+ sb_info_bg = "%8";
+ # background for topicbar (same default)
+ #sb_topic_bg = "%4";
+
+ # text at the beginning of statusbars. sb-item already puts
+ # space there,so we don't use anything by default.
+ sbstart = "";
+ # text at the end of statusbars. Use space so that it's never
+ # used for anything.
+ sbend = " ";
+
+ topicsbstart = "{sbstart $*}";
+ topicsbend = "{sbend $*}";
+
+ prompt = "[$*] ";
+
+ sb = " %c[%n$*%c]%n";
+ sbmode = "(%c+%n$*)";
+ sbaway = " (%GzZzZ%n)";
+ sbservertag = ":$0 (change with ^X)";
+ sbnickmode = "$0";
+
+ # activity in statusbar
+
+ # ',' separator
+ sb_act_sep = "%c$*";
+ # normal text
+ sb_act_text = "%c$*";
+ # public message
+ sb_act_msg = "%W$*";
+ # hilight
+ sb_act_hilight = "%M$*";
+ # hilight with specified color, $0 = color, $1 = text
+ sb_act_hilight_color = "$0$1-%n";
+};
View
1 .irssi/scripts/autorun/nickcolor.pl
View
92 .irssi/scripts/mynotify.pl
@@ -0,0 +1,92 @@
+#!/usr/bin/env perl -w
+#
+# This is a simple irssi script to send out notifications using
+# growlnotify under MacOSX, notify-send under Linux.
+# Currently, it sends notifications when your name is
+# highlighted, and when you receive private messages.
+#
+# This script is modified based on Growl project's script for irssi
+
+use strict;
+use vars qw($VERSION %IRSSI $Notes $AppName);
+
+use Irssi;
+
+$VERSION = '0.1';
+%IRSSI = (
+ authors => 'Vincent Wang',
+ contact => 'linsong.qizi@gmail.com',
+ name => 'mynotify',
+ description => 'Sends out notifications for Irssi',
+ license => 'BSD',
+ url => 'http://vincent-wang.blogspot.com'
+);
+
+sub cmd_help ($$$) {
+ Irssi::print('%G>>%n Mynotify can be configured using three settings:');
+ Irssi::print('%G>>%n notify_show_privmsg : Notify about private messages.');
+ Irssi::print('%G>>%n notify_show_hilight : Notify when your name is hilighted.');
+ Irssi::print('%G>>$h notify_show_notify : Notify when someone on your away list joins or leaves.');
+}
+
+$Notes = ["Script message", "Message notification"];
+$AppName = "irssi";
+
+sub notify($$$$)
+{
+ my ($appname, $title, $nick, $data) = @_;
+
+ # for MacOSX
+ system("growlnotify -n '$appname' -t '$title' -d '$nick' -m '$data'");
+
+ #for linux
+ #system("notify-send -i gtk-dialog-info -t 5000 '$title' '$nick said: $data'");
+}
+
+sub sig_message_private ($$$$) {
+ return unless Irssi::settings_get_bool('notify_show_privmsg');
+
+ my ($server, $data, $nick, $address) = @_;
+
+ notify($AppName, "Message notification", "$nick", "$data");
+}
+
+sub sig_print_text ($$$) {
+ return unless Irssi::settings_get_bool('notify_show_hilight');
+
+ my ($dest, $text, $stripped) = @_;
+
+ if ($dest->{level} & MSGLEVEL_HILIGHT) {
+ notify($AppName, "Message notification", $dest->{target}, $stripped);
+ }
+}
+
+sub sig_notify_joined ($$$$$$) {
+ return unless Irssi::settings_get_bool('notify_show_notify');
+ my ($server, $nick, $user, $host, $realname, $away) = @_;
+
+ notify($AppName, "Message notification", $realname || $nick,
+ "<$nick!$user\@$host>\nHas joined $server->{chatnet}");
+}
+
+sub sig_notify_left ($$$$$$) {
+ return unless Irssi::settings_get_bool('notify_show_notify');
+ my ($server, $nick, $user, $host, $realname, $away) = @_;
+
+ notify($AppName, "Message notification", $realname || $nick,
+ "<$nick!$user\@$host>\nHas left $server->{chatnet}");
+}
+
+
+Irssi::command_bind('mynotify', 'cmd_help');
+
+Irssi::signal_add_last('message private', \&sig_message_private);
+Irssi::signal_add_last('print text', \&sig_print_text);
+Irssi::signal_add_last('notifylist joined', \&sig_notify_joined);
+Irssi::signal_add_last('notifylist left', \&sig_notify_left);
+
+Irssi::settings_add_bool($IRSSI{'name'}, 'notify_show_privmsg', 1);
+Irssi::settings_add_bool($IRSSI{'name'}, 'notify_show_hilight', 1);
+Irssi::settings_add_bool($IRSSI{'name'}, 'notify_show_notify', 1);
+
+Irssi::print('%G>>%n '.$IRSSI{name}.' '.$VERSION.' loaded (/mynotify for help)');
View
156 .irssi/scripts/nickcolor.pl
@@ -0,0 +1,156 @@
+use strict;
+use Irssi 20020101.0250 ();
+use vars qw($VERSION %IRSSI);
+$VERSION = "1";
+%IRSSI = (
+ authors => "Timo Sirainen, Ian Peters",
+ contact => "tss\@iki.fi",
+ name => "Nick Color",
+ description => "assign a different color for each nick",
+ license => "Public Domain",
+ url => "http://irssi.org/",
+ changed => "2002-03-04T22:47+0100"
+);
+
+# hm.. i should make it possible to use the existing one..
+Irssi::theme_register([
+ 'pubmsg_hilight', '{pubmsghinick $0 $3 $1}$2'
+]);
+
+my %saved_colors;
+my %session_colors = {};
+my @colors = qw/2 3 4 5 6 7 9 10 11 12 13/;
+
+sub load_colors {
+ open COLORS, "$ENV{HOME}/.irssi/saved_colors";
+
+ while (<COLORS>) {
+ # I don't know why this is necessary only inside of irssi
+ my @lines = split "\n";
+ foreach my $line (@lines) {
+ my($nick, $color) = split ":", $line;
+ $saved_colors{$nick} = $color;
+ }
+ }
+
+ close COLORS;
+}
+
+sub save_colors {
+ open COLORS, ">$ENV{HOME}/.irssi/saved_colors";
+
+ foreach my $nick (keys %saved_colors) {
+ print COLORS "$nick:$saved_colors{$nick}\n";
+ }
+
+ close COLORS;
+}
+
+# If someone we've colored (either through the saved colors, or the hash
+# function) changes their nick, we'd like to keep the same color associated
+# with them (but only in the session_colors, ie a temporary mapping).
+
+sub sig_nick {
+ my ($server, $newnick, $nick, $address) = @_;
+ my $color;
+
+ $newnick = substr ($newnick, 1) if ($newnick =~ /^:/);
+
+ if ($color = $saved_colors{$nick}) {
+ $session_colors{$newnick} = $color;
+ } elsif ($color = $session_colors{$nick}) {
+ $session_colors{$newnick} = $color;
+ }
+}
+
+# This gave reasonable distribution values when run across
+# /usr/share/dict/words
+
+sub simple_hash {
+ my ($string) = @_;
+ chomp $string;
+ my @chars = split //, $string;
+ my $counter;
+
+ foreach my $char (@chars) {
+ $counter += ord $char;
+ }
+
+ $counter = $colors[$counter % 11];
+
+ return $counter;
+}
+
+# FIXME: breaks /HILIGHT etc.
+sub sig_public {
+ my ($server, $msg, $nick, $address, $target) = @_;
+ my $chanrec = $server->channel_find($target);
+ return if not $chanrec;
+ my $nickrec = $chanrec->nick_find($nick);
+ return if not $nickrec;
+ my $nickmode = $nickrec->{op} ? "@" : $nickrec->{voice} ? "+" : "";
+
+ # Has the user assigned this nick a color?
+ my $color = $saved_colors{$nick};
+
+ # Have -we- already assigned this nick a color?
+ if (!$color) {
+ $color = $session_colors{$nick};
+ }
+
+ # Let's assign this nick a color
+ if (!$color) {
+ $color = simple_hash $nick;
+ $session_colors{$nick} = $color;
+ }
+
+ $color = "0".$color if ($color < 10);
+ $server->command('/^format pubmsg {pubmsgnick $2 {pubnick '.chr(3).$color.'$0}}$1');
+}
+
+sub cmd_color {
+ my ($data, $server, $witem) = @_;
+ my ($op, $nick, $color) = split " ", $data;
+
+ $op = lc $op;
+
+ if (!$op) {
+ Irssi::print ("No operation given");
+ } elsif ($op eq "save") {
+ save_colors;
+ } elsif ($op eq "set") {
+ if (!$nick) {
+ Irssi::print ("Nick not given");
+ } elsif (!$color) {
+ Irssi::print ("Color not given");
+ } elsif ($color < 2 || $color > 14) {
+ Irssi::print ("Color must be between 2 and 14 inclusive");
+ } else {
+ $saved_colors{$nick} = $color;
+ }
+ } elsif ($op eq "clear") {
+ if (!$nick) {
+ Irssi::print ("Nick not given");
+ } else {
+ delete ($saved_colors{$nick});
+ }
+ } elsif ($op eq "list") {
+ Irssi::print ("\nSaved Colors:");
+ foreach my $nick (keys %saved_colors) {
+ Irssi::print (chr (3) . "$saved_colors{$nick}$nick" .
+ chr (3) . "1 ($saved_colors{$nick})");
+ }
+ } elsif ($op eq "preview") {
+ Irssi::print ("\nAvailable colors:");
+ foreach my $i (2..14) {
+ Irssi::print (chr (3) . "$i" . "Color #$i");
+ }
+ }
+}
+
+load_colors;
+
+Irssi::command_bind('color', 'cmd_color');
+
+Irssi::signal_add('message public', 'sig_public');
+Irssi::signal_add('event nick', 'sig_nick');
View
32 .irssi/scripts/notify.pl
@@ -1,32 +0,0 @@
-##
-## Put me in ~/.irssi/scripts, and then execute the following in irssi:
-##
-## /load perl
-## /script load notify
-##
-
-use strict;
-use Irssi;
-use vars qw($VERSION %IRSSI);
-
-$VERSION = "0.01";
-%IRSSI = (
- authors => 'Luke Macken',
- contact => 'lewk@csh.rit.edu',
- name => 'notify.pl',
- description => 'TODO',
- license => 'GNU General Public License',
- url => 'http://lewk.org/log/code/irssi-notify',
-);
-
-sub notify {
- my ($dest, $text, $stripped) = @_;
- my $server = $dest->{server};
-
- return if (!$server || !($dest->{level} & MSGLEVEL_HILIGHT));
-
- $stripped =~ s/[^a-zA-Z0-9 .,!\?@\:\<\>]//g;
- system("notify-send -i gtk-dialog-info -t 5000 '$dest->{target}' '$stripped'");
-}
-
-Irssi::signal_add('print text', 'notify');
View
269 .irssi/scripts/openurl.pl
@@ -0,0 +1,269 @@
+# OpenURL by Stefan'tommie' Tomanek
+#
+# 05.06.2002
+# * complete rewrite
+
+use strict;
+
+use vars qw($VERSION %IRSSI);
+$VERSION = "20030208";
+%IRSSI = (
+ authors => "Stefan 'tommie' Tomanek",
+ contact => "stefan\@pico.ruhr.de",
+ name => "OpenURL",
+ description => "Stores URLs in a list and launches mail, web or ftp software",
+ license => "GPLv2",
+ url => "http://scripts.irssi.org",
+ changed => "$VERSION",
+ commands => "openurl"
+);
+
+use Irssi 20020324;
+use Irssi::TextUI;
+use Irssi::UI;
+
+use vars qw(@urls %urltypes $recent);
+$recent = 1;
+
+# RegExp & defaultcommands
+%urltypes = ( http => { regexp => qr#((?:https?://[^\s<>"]+|www\.[-a-z0-9.]+)[^\s.,;<">\):])#, cmd => 'w3m "$1"' },
+ ftp => { regexp => qr#((?:ftp://[^\s<>"]+|ftp\.[-a-z0-9.]+)[^\s.,;<">\):])#, cmd => 'ncftp "$1"' },
+ mail => { regexp => qr#([-_a-z0-9.]+\@[-a-z0-9.]+\.[-a-z0-9.]+)#, cmd => 'mutt "$1" -s "$2"' },
+ );
+
+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=$IRSSI{name}." ".$VERSION."
+/openurl
+ List the saved URLs
+/openurl <number> <number>...
+ Load the corresponding URLs in your browser/mailer
+/openurl paste <number> <number>...
+ Paste the selected URLs to the current channel/query
+/openurl topics
+ Look for URLs in channel topics
+/openurl clear
+ Clear all URLs
+/openurl help
+ Display this help
+";
+ my $text = '';
+ foreach (split(/\n/, $help)) {
+ $_ =~ s/^\/(.*)$/%9\/$1%9/;
+ $text .= $_."\n";
+ }
+ print CLIENTCRAP draw_box($IRSSI{name}." help", $text, "help", 1) ;
+}
+
+sub list_urls {
+ my $string = '';
+ my $i = 1;
+ foreach (@urls) {
+ my $text = $_->{url};
+ my $url = $_->{url};
+ $text = $_->{text} if Irssi::settings_get_bool('openurl_display_context');
+ $url =~ s/%/%%/g;
+ $text =~ s/%/%%/g;
+ $text =~ s/\Q$url/%U$url%U/;
+ if ($recent-1 == $i) {
+ $string .= '%B»%n';
+ } else {
+ $string .= ' ';
+ }
+ $string .= '%r['.$i.']%n ';
+ $string .= '<'.$_->{channel};
+ $string .= '/'.$_->{nick} unless $_->{nick} eq "";
+ $string .= '> ';
+ $string .= $text." %n\n";
+ $i++;
+ }
+ print CLIENTCRAP draw_box("OpenURL", $string, "URLs", 1);
+}
+
+sub event_private_message {
+ my ($server, $text, $nick, $address) = @_;
+ process_line($server, $nick, $nick, $text);
+}
+sub event_public_message {
+ my ($server, $text, $nick, $address, $target) = @_;
+ process_line($server, $target, $nick, $text);
+}
+sub event_topic_changed {
+ my ($channel) = @_;
+ process_line($channel->{server}, $channel->{name}, "", $channel->{topic});
+}
+
+sub process_line ($$$$) {
+ my ($server, $target, $nick, $line) = @_;
+ my $url = get_url($line);
+ if ($url) {
+ my $type = url_type($url);
+ return unless Irssi::settings_get_bool('openurl_watch_'.$type);
+ new_url($server, $target, $nick, $line, $url);
+ }
+}
+
+sub get_url ($) {
+ my ($text) = @_;
+ foreach (keys %urltypes) {
+ return $1 if ($text =~ /$urltypes{$_}->{regexp}/);
+ }
+}
+
+sub url_type ($) {
+ my ($url) = @_;
+ foreach (keys %urltypes) {
+ return $_ if ($url =~ /$urltypes{$_}->{regexp}/);
+ }
+}
+
+sub launch_url ($) {
+ my ($url) = @_;
+ my $type = url_type($url);
+ my $address = $url;
+ my $suffix= "";
+ if ($type eq "mail") {
+ $address = $1 if $url =~ /(.*?@.*?)($|\?)/;
+ $suffix = $2 if $url =~ /(.*?@.*?)\?subject=(.*)/;
+ }
+ my $command = Irssi::settings_get_str("openurl_app_".$type);
+ $command =~ s/\$1/$address/;
+ $command =~ s/\$2/$suffix/;
+ system($command);
+}
+
+sub new_url ($$$$$) {
+ my ($server, $channel, $nick, $text, $url) = @_;
+ $recent = 1 if ($recent > Irssi::settings_get_int('openurl_max_urls'));
+ # Check for existance of URL
+ my $i = 1;
+ foreach (@urls) {
+ if ($text eq $_->{text} && $channel eq $_->{channel}) {
+ my $note_id = add_note($server, $channel, $i);
+ push @{$_->{notes}}, $note_id;
+ return();
+ }
+ $i++;
+ }
+ if (defined $urls[$recent-1]) {
+ del_notes($recent);
+ }
+ $urls[$recent-1] = {channel => $channel,
+ text => $text,
+ nick => $nick,
+ url => $url,
+ notes => [],
+ };
+ my $note_id = add_note($server, $channel, $recent);
+ push @{$urls[$recent-1]{notes}}, $note_id;
+ $recent++;
+}
+
+
+sub del_notes ($) {
+ my ($num) = @_;
+ my $view;
+ my $witem = Irssi::window_item_find($urls[$num-1]->{channel});
+ if (defined $witem) {
+ $view = $witem->window()->view();
+ }
+ if (defined $view) {
+ foreach (@{$urls[$num-1]->{notes}}) {
+ my $line = $view->get_bookmark($_);
+ $view->remove_line($line) if defined $line;
+ $view->set_bookmark($_, undef);
+ }
+ @{$urls[$num-1]->{notes}} = ();
+ $view->redraw();
+ }
+}
+
+sub add_note ($$$) {
+ my ($server, $target, $num) = @_;
+ my $witem;
+ if (defined $server) {
+ $witem = $server->window_item_find($target);
+ } else {
+ $witem = Irssi::window_item_find($target);
+ }
+ if (defined $witem) {
+ $witem->print("%R>>%n OpenURL ".$num, MSGLEVEL_CLIENTCRAP);
+ # create a unique ID for the mark
+ my $foo = time().'-'.int(rand()*1000);
+ $witem->window()->view()->set_bookmark_bottom("openurl_".$num.'-'.$foo);
+ return("openurl_".$num.'-'.$foo);
+ }
+ return(undef);
+}
+
+sub clear_urls {
+ del_notes($_) foreach (0..scalar(@urls)-1);
+ pop(@urls) foreach (1..scalar(@urls));
+ $recent = 1;
+ print CLIENTCRAP '%R>>%n URLs cleared';
+}
+
+sub cmd_openurl ($$$) {
+ my ($arg, $server, $witem) = @_;
+ my @args = split(/ /, $arg);
+ if (scalar(@args) == 0) {
+ list_urls;
+ } elsif ($args[0] eq 'clear') {
+ clear_urls;
+ } elsif ($args[0] eq 'topics') {
+ event_topic_changed($_) foreach (Irssi::channels());
+ } elsif ($args[0] eq 'help') {
+ show_help();
+ } elsif ($args[0] eq 'open') {
+ launch_url($args[1]);
+ } else {
+ my $paste = 0;
+ if ($args[0] eq 'paste') {
+ $paste = 1;
+ shift(@args);
+ }
+ foreach (@args) {
+ next unless /\d+/;
+ next unless defined $urls[$_-1];
+ my $url = $urls[$_-1]->{url};
+ if ($paste == 1) {
+ if (ref $witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) {
+ $witem->command("MSG ".$witem->{name}." ".$url);
+ }
+ } else {
+ launch_url($url);
+ }
+ }
+ }
+}
+
+foreach (keys %urltypes) {
+ Irssi::settings_add_str($IRSSI{'name'}, 'openurl_app_'.$_, "screen ".$urltypes{$_}->{cmd});
+ Irssi::settings_add_bool($IRSSI{'name'}, 'openurl_watch_'.$_, 1);
+}
+Irssi::settings_add_int($IRSSI{'name'}, 'openurl_max_urls', 20);
+Irssi::settings_add_bool($IRSSI{'name'}, 'openurl_display_context', 1);
+
+Irssi::signal_add_last("message private", "event_private_message");
+Irssi::signal_add_last("message public", "event_public_message");
+Irssi::signal_add_last("channel topic changed", "event_topic_changed");
+
+#Irssi::signal_add('open url', \&launch_url);
+
+foreach my $cmd ('topics', 'clear', 'paste', 'help') {
+ Irssi::command_bind('openurl '.$cmd => sub {
+ cmd_openurl("$cmd ".$_[0], $_[1], $_[2]); });
+}
+Irssi::command_bind('openurl', 'cmd_openurl');
+
+print CLIENTCRAP '%B>>%n '.$IRSSI{name}.' '.$VERSION.' loaded: /openurl help for help';
View
175 .irssi/scripts/timer.pl
@@ -0,0 +1,175 @@
+# Fixes for multiple servers and window items by dg
+#
+# 2003-08-27 coekie:
+# - use item names and server tags, fixes irssi crash if window item or server is destroyed
+#
+# 2003-08-19
+# - changed timer stop code a bit.
+# should fix the random timer o.O never happened to me before.
+#
+# 2002-12-21 darix:
+# - nearly complete rewrite ;) the old version wasnt "use strict;" capable =)
+# - still some warnings with "use warnings;"
+# - use of command_runsub now :)
+#
+
+use strict;
+use Data::Dumper;
+use warnings;
+use vars qw ($VERSION %IRSSI);
+use Irssi 20020325 qw (command_bind command_runsub command timeout_add timeout_remove signal_add_first);
+
+$VERSION = '0.5';
+%IRSSI = (
+ authors => 'Kimmo Lehto, Marcus Rueckert',
+ contact => 'kimmo@a-men.org, darix@irssi.org' ,
+ name => 'Timer',
+ description => 'Provides /timer command for mIRC/BitchX type timer functionality.',
+ license => 'Public Domain',
+ changed => '2003-08-27'
+);
+
+our %timers;
+# my %timer = { repeat => \d+, command => '' , windowitem => NULL , server=> NULL, timer = NULL};
+
+sub timer_command {
+ my ( $name ) = @_;
+ if ( exists ( $timers{$name} ) ) {
+ if ( $timers{$name}->{'repeat'} != -1 ) {
+ if ( $timers{$name}->{'repeat'}-- == 0) {
+ cmd_timerstop( $name );
+ return;
+ }
+ }
+
+ my ($server, $item);
+ if ($timers{$name}->{'server'}) {
+ $server = Irssi::server_find_tag( $timers{$name}->{'server'} );
+ }
+ if ( $server ) {
+ if ( $timers{$name}->{'windowitem'}) {
+ $item = $server->window_find_item( $timers{$name}->{'windowitem'} );
+ }
+ ($item ? $item : $server)->command( $timers{$name}->{'command'} );
+ } else {
+ command( $timers{$name}->{'command'} );
+ }
+ }
+}
+
+sub cmd_timerstop {
+ my ( $name ) = @_;
+
+ if ( exists ( $timers{$name} ) ) {
+ timeout_remove($timers{$name}->{'timer'});
+ $timers{$name} = ();
+ delete ( $timers{$name} );
+ print( CRAP "Timer \"$name\" stopped." );
+ }
+ else {
+ print( CRAP "\cBTimer:\cB No such timer \"$name\"." );
+ }
+}
+
+sub cmd_timer_help {
+ print ( <<EOF
+
+TIMER LIST
+TIMER ADD <name> <internal in seconds> [<repeat>] <command>
+TIMER STOP <name>
+
+repeat value of 0 means unlimited too
+
+EOF
+ );
+}
+
+command_bind 'timer add' => sub {
+ my ( $data, $server, $item ) = @_;
+ my ( $name, $interval, $times, $command );
+
+ if ( $data =~ /^\s*(\w+)\s+(\d+)\s+(-?\d+)\s+(.*)$/ ) {
+ ( $name, $interval, $times, $command ) = ( $1, $2, $3, $4 );
+ $times = -1 if ( $times == 0 );
+ }
+ elsif ( $data =~ /^\s*(\w+)\s+(\d+)\s+(.*)$/ )
+ {
+ ( $name, $interval, $times, $command ) = ( $1, $2, -1, $3 );
+ }
+ else {
+ print( CRAP "\cBTimer:\cB parameters not understood. commandline was: timer add $data");
+ return;
+ };
+
+ if ( $times < -1 ) {
+ print( CRAP "\cBTimer:\cB repeat should be greater or equal to -1" );
+ return;
+ };
+
+ if ( $command eq "" ) {
+ print( CRAP "\cBTimer:\cB command is empty commandline was: timer add $data" );
+ return;
+ };
+
+ if ( exists ( $timers{$name} ) ) {
+ print( CRAP "\cBTimer:\cB Timer \"$name\" already active." );
+ }
+ else {
+ #$timers{$name} = {};
+ $timers{$name}->{'repeat'} = $times;
+ $timers{$name}->{'interval'} = $interval;
+ $timers{$name}->{'command'} = $command;
+ if ($item) {
+ $timers{$name}->{'windowitem'} = $item->{'name'};
+ }
+ if ($server) {
+ $timers{$name}->{'server'} = $server->{'tag'};
+ }
+
+ if ( $times == -1 ) {
+ $times = 'until stopped.';
+ }
+ else {
+ $times .= " times.";
+ }
+
+ print( CRAP "Starting timer \"$name\" repeating \"$command\" every $interval seconds $times" );
+
+ $timers{$name}->{'timer'} = timeout_add( $interval * 1000, \&timer_command, $name );
+ }
+};
+
+command_bind 'timer list' => sub {
+ print( CRAP "Active timers:" );
+ foreach my $name ( keys %timers ) {
+ if ( $timers{$name}->{repeat} == -1 ) {
+ print( CRAP "$name = $timers{$name}->{'command'} (until stopped)");
+ }
+ else {
+ print( CRAP "$name = $timers{$name}->{'command'} ($timers{$name}->{'repeat'} repeats left)" );
+ }
+ }
+ print( CRAP "End of /timer list" );
+};
+
+command_bind 'timer stop' => sub {
+ my ( $data, $server, $item ) = @_;
+ cmd_timerstop ($data);
+};
+
+command_bind 'timer help' => sub { cmd_timer_help() };
+
+command_bind 'timer' => sub {
+ my ( $data, $server, $item ) = @_;
+ $data =~ s/\s+$//g;
+ command_runsub ( 'timer', $data, $server, $item ) ;
+};
+
+
+signal_add_first 'default command timer' => sub {
+#
+# gets triggered if called with unknown subcommand
+#
+ cmd_timer_help()
+}
+
View
566 .irssi/scripts/trigger.pl
@@ -0,0 +1,566 @@
+# Do /TRIGGER HELP for help
+
+use strict;
+use Irssi 20020324 qw (command_bind command_runsub command signal_add_first signal_continue signal_stop);
+use Text::ParseWords;
+use IO::File;
+use Data::Dumper;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = '0.6.1';
+%IRSSI = (
+ authors => 'Wouter Coekaerts',
+ contact => 'wouter@coekaerts.be',
+ name => 'trigger',
+ description => 'executes an irssi command or replace text, triggered by a message,notice,join,part,quit,kick or topic',
+ license => 'GPLv2',
+ url => 'http://wouter.coekaerts.be/irssi/',
+ changed => '29/01/04',
+);
+
+my @triggers;
+
+sub cmd_help {
+ Irssi::print ( <<SCRIPTHELP_EOF
+
+TRIGGER DELETE <number>|<regexp>
+TRIGGER LIST
+TRIGGER SAVE
+TRIGGER RELOAD
+TRIGGER ADD %|[-<types>] [-regexp <regexp>] [-modifiers <modifiers>] [-channels <channels>] [-masks <masks>] [-hasmode <hasmode>] [-hasflag <hasflag>]
+ [-command <command>] [-replace <replace>] [-once]
+
+When to match:
+ -<types>: Trigger on these types of messages. The different types are:
+ publics,privmsgs,pubactions,privactions,pubnotices,privnotices,joins,parts,quits,kicks,topics
+ -all is an alias for all of them.
+ -regexp: the message must match <regexp>. (see man 7 regex)
+ -modifiers: use <modifiers> for the regexp. The modifiers you may use are:
+ i: Ignore case.
+ g: Match as many times as possible.
+ -channels: only trigger in <channels>. a space-delimited list. (use quotes)
+ examples: '#chan1 #chan2' or 'IRCNet/#channel'
+ -masks: only for messages from someone mathing one of the <masks> (space seperated)
+ -hasmode: only if the person who triggers it has the <hasmode>
+ examples: '-o' means not opped, '+ov' means opped OR voiced, '-o&-v' means not opped AND not voiced
+ -hasflag: only works if friends.pl (friends_shasta.pl) or people.pl is loaded
+ only trigger if the person who triggers it has <hasflag> in the script
+
+What to do when it matches:
+ -command: execute <command>
+ You are able to use \$1, \$2 and so on generated by your regexp pattern.
+ For multiple command \$; can be used as seperator
+ The following variables are also expanded:
+ \$T: Server tag
+ \$C: Channel name
+ \$N: Nickname of the person who triggered this command
+ \$A: His address (foo\@bar.com),
+ \$I: His ident (foo)
+ \$H: His hostname (bar.com)
+ \$M: The complete message
+
+ -replace: replaces the matching part with <replace> in your irssi (requires a <regexp>)
+ -once: remove the trigger if it is triggered, so it only executes once and then is forgotten.
+
+Examples:
+ knockout people who do a !list:
+ /TRIGGER ADD -publics -channels "#channel1 #channel2" -modifiers i -regexp ^!list -command "KN \$N This is not a warez channel!"
+ react to !echo commands from people who are +o in your friends-script:
+ /TRIGGER ADD -publics -regexp '^!echo (.*)' -hasflag '+o' -command 'say \$1'
+ ignore all non-ops on #channel
+ /TRIGGER ADD -publics -channels "#channel" -hasmode '-o' -stop
+
+Examples with -replace:
+ replace every occurence of shit with sh*t, case insensitive
+ /TRIGGER ADD -modifiers i -regexp shit -replace sh*t
+ strip all colorcodes from *!lamer\@*
+ /TRIGGER ADD -masks *!lamer\@* -regexp '\\x03\\d?\\d?(,\\d\\d?)?|\\x02|\\x1f|\\x16|\\x06' -replace ''
+ never let *!bot1\@foo.bar or *!bot2\@foo.bar hilight you
+ (this works by cutting your nick in 2 different parts, 'myn' and 'ick' here)
+ you don't need to understand the -replace argument, just trust that it works if the 2 parts separately don't hilight.
+ /TRIGGER ADD -masks '*!bot1\@foo.bar *!bot2\@foo.bar' -regexp '(myn)(ick)' -replace '\$1\\x02\\x02\$2'
+ avoid being hilighted by !top10 in eggdrops with stats.mod (but show your nick in bold)
+ /TRIGGER ADD -publics -regexp '(Top.0\\(.*\\): 1.*)(my)(nick)' -replace '\$1\\x02\$2\\x02\\x02\$3\\x02'
+ Convert a Windows-1252 Euro to an ISO-8859-15 Euro (same effect as euro.pl)
+ /TRIGGER ADD -regexp '\\x80' -replace '\\xA4'
+ Show tabs as spaces, not the inverted I (same effect as tab_stop.pl)
+ /TRIGGER ADD -regexp '\\t' -replace ' '
+
+WARNING: Be very careful when you use the 'eval' or 'exec' command with parameters that come from a remote user. Only use them if you understand the risk.
+SCRIPTHELP_EOF
+ ,MSGLEVEL_CLIENTCRAP);
+} # /
+
+#switches in -all option
+my @trigger_all_switches = ('publics','privmsgs','pubactions','privactions','pubnotices','privnotices','joins','parts','quits','kicks','topics');
+#list of all switches
+my @trigger_switches = @trigger_all_switches;
+push @trigger_switches, 'stop','once';
+#parameters (with an argument)
+my @trigger_params = ('masks','channels','modifiers','regexp','command','replace','hasmode','hasflag');
+#list of all options (including switches)
+my @trigger_options = ('all');
+push @trigger_options, @trigger_switches;
+push @trigger_options, @trigger_params;
+
+#########################################
+### catch the signals & do your thing ###
+#########################################
+
+# "message public", SERVER_REC, char *msg, char *nick, char *address, char *target
+signal_add_first("message public" => sub {check_signal_message(\@_,1,4,2,3,'publics');});
+# "message private", SERVER_REC, char *msg, char *nick, char *address
+signal_add_first("message private" => sub {check_signal_message(\@_,1,-1,2,3,'privmsgs');});
+# "message irc action", SERVER_REC, char *msg, char *nick, char *address, char *target
+signal_add_first("message irc action" => sub {
+ if ($_[4] eq $_[0]->{nick}) {
+ check_signal_message(\@_,1,-1,2,3,'privactions');
+ } else {
+ check_signal_message(\@_,1,4,2,3,'pubactions');
+ }
+});
+# "message irc notice", SERVER_REC, char *msg, char *nick, char *address, char *target
+signal_add_first("message irc notice" => sub {
+ if ($_[4] eq $_[0]->{nick}) {
+ check_signal_message(\@_,1,-1,2,3,'privnotices');
+ } else {
+ check_signal_message(\@_,1,4,2,3,'pubnotices');
+ }
+});
+
+# "message join", SERVER_REC, char *channel, char *nick, char *address
+signal_add_first("message join" => sub {check_signal_message(\@_,-1,1,2,3,'joins');});
+# "message part", SERVER_REC, char *channel, char *nick, char *address, char *reason
+signal_add_first("message part" => sub {check_signal_message(\@_,4,1,2,3,'parts');});
+# "message quit", SERVER_REC, char *nick, char *address, char *reason
+signal_add_first("message quit" => sub {check_signal_message(\@_,3,-1,1,2,'quits');});
+# "message kick", SERVER_REC, char *channel, char *nick, char *kicker, char *address, char *reason
+signal_add_first("message kick" => sub {check_signal_message(\@_,5,1,3,4,'kicks');});
+# "message topic", SERVER_REC, char *channel, char *topic, char *nick, char *address
+signal_add_first("message topic" => sub {check_signal_message(\@_,2,1,3,4,'topics');});
+
+# check the triggers on $signal's $parammessage parameter, for triggers with $condition set
+# in $paramchannel, for $paramnick!$paramaddress
+# set $param* to -1 if not present (only allowed for message and channel)
+sub check_signal_message {
+ my ($signal,$parammessage,$paramchannel,$paramnick,$paramaddress,$condition) = @_;
+ my ($trigger, $channel, $matched, $changed, $context);
+ my $server = $signal->[0];
+ my $message = ($parammessage == -1) ? '' : $signal->[$parammessage];
+
+TRIGGER:
+ for (my $index=0;$index < scalar(@triggers);$index++) {
+ my $trigger = $triggers[$index];
+ if (!$trigger->{"$condition"}) {
+ next; # wrong type of message
+ }
+ if ($trigger->{'channels'}) { # check if the channel matches
+ if ($paramchannel == -1) {
+ next;
+ }
+ my $matches = 0;
+ foreach $channel (split(/ /,$trigger->{'channels'})) {
+ if (lc($signal->[$paramchannel]) eq lc($channel)
+ || lc($server->{'tag'}.'/'.$signal->[$paramchannel]) eq lc($channel)
+ || lc($server->{'tag'}.'/') eq lc($channel)) {
+ $matches = 1;
+ last; # this channel matches, stop checking channels
+ }
+ }
+ if (!$matches) {
+ next; # this trigger doesn't match, try next trigger...
+ }
+ }
+ # check the mask
+ if ($trigger->{'masks'} && !$server->masks_match($trigger->{'masks'}, $signal->[$paramnick], $signal->[$paramaddress])) {
+ next; # this trigger doesn't match
+
+ }
+ # check hasmodes
+ if ($trigger->{'hasmode'}) {
+ my ($channel, $nick);
+ ( $paramchannel != -1
+ and $channel = $server->channel_find($signal->[$paramchannel])
+ and $nick = $channel->nick_find($signal->[$paramnick])
+ ) or next;
+
+ my $modes = ($nick->{'op'}?'o':'').($nick->{'voice'}?'v':'').($nick->{'halfop'}?'h':'');
+ if (!check_modes($modes,$trigger->{'hasmode'})) {
+ next;
+ }
+ }
+
+ # check hasflags
+ if ($trigger->{'hasflag'}) {
+ my $channel = ($paramchannel == -1) ? undef : $signal->[$paramchannel];
+ my $flags = get_flags ($server->{'chatnet'},$channel,$signal->[$paramnick],$signal->[$paramaddress]);
+ if (!defined($flags)) {
+ next;
+ }
+ if (!check_modes($flags,$trigger->{'hasflag'})) {
+ next;
+ }
+ }
+
+ # the only check left, is the regexp matching...
+ if (defined($trigger->{'replace'}) && $parammessage != -1) { # it's a -replace
+ # if you know a better way to do this, let me know:
+ eval('$matched = ($signal->[$parammessage] =~ s§'. $trigger->{'regexp'} . '§' . $trigger->{'replace'} . '§' . $trigger->{'modifiers'} . ');');
+ $changed = $changed || $matched;
+ }
+ if ($trigger->{'command'}) {
+ my @vars;
+ # check if the message matches the regexp (with the modifiers embedded), and put ($1,$2,$3,...) in @vars
+ @vars = $message =~ m/(?$trigger->{'modifiers'})$trigger->{'regexp'}/;
+ if (@vars){ # if it matched
+ $matched = 1;
+ my $command = $trigger->{'command'};
+ my $expands = {
+ 'M' => $message,
+ 'T' => $server->{'tag'},
+ 'C' => (($paramchannel == -1) ? '' : $signal->[$paramchannel]),
+ 'N' => (($paramnick == -1) ? '' : $signal->[$paramnick]),
+ 'A' => (($paramaddress == -1) ? '' : $signal->[$paramaddress]),
+ 'I' => (($paramaddress == -1) ? '' : split(/\@/,$signal->[$paramaddress]),2)[0],
+ 'H' => (($paramaddress == -1) ? '' : split(/\@/,$signal->[$paramaddress]),2)[1],
+ '$' => '$',
+ ';' => "\x00"
+ };
+ # $1 = the stuff behind the $ we want to expand: a number, or a character from %expands
+ $command =~ s/\$(\d+|[^0-9])/expand(\@vars,$1,$expands)/ge;
+
+
+ if ($paramchannel!=-1 && $server->channel_find($signal->[$paramchannel])) {
+ $context = $server->channel_find($signal->[$paramchannel]);
+ } else {
+ $context = $server;
+ }
+
+ foreach my $commandpart (split /\x00/,$command) {
+ $commandpart =~ s/^ +//; # remove spaces in front
+ $context->command($commandpart);
+ }
+ }
+ } elsif ($message =~ m/(?$trigger->{'modifiers'})$trigger->{'regexp'}/) {
+ $matched = 1;
+ }
+ if ($matched) {
+ if ($trigger->{'stop'}) {
+ signal_stop;
+ }
+ if ($trigger->{'once'}) {
+ splice (@triggers,$index,1);
+ $index--; # index of next trigger now is the same as this one was
+ }
+ }
+ }
+ if ($changed) { # changed with -replace
+ signal_continue(@$signal);
+ }
+}
+
+# used in check_signal_message, to expand $'s
+sub expand {
+ my ($vars,$to_expand,$expands) = @_;
+ if ($to_expand =~ /^\d+$/) { # a number => look up in $vars
+ return ($to_expand > @{$vars}) ? '' : $vars->[$to_expand-1];
+ } else { # look up in $expands
+ return $expands->{$to_expand};
+ }
+}
+
+sub check_modes {
+ my ($has_modes, $need_modes) = @_;
+ my $matches;
+ my $switch = 1; # if a '-' if found, will be 0 (meaning the modes should not be set)
+ foreach my $need_mode (split /&/,$need_modes) {
+ $matches = 0;
+ foreach my $char (split //,$need_mode) {
+ if ($char eq '-') {
+ $switch = 0;
+ } elsif ($char eq '+') {
+ $switch = 1;
+ } elsif ((index($has_modes,$char) != -1) == $switch) {
+ $matches = 1;
+ last;
+ }
+ }
+ if (!$matches) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+# get someones flags from people.pl or friends(_shasta).pl
+sub get_flags {
+ my ($chatnet, $channel, $nick, $address) = @_;
+ my $flags;
+ no strict 'refs';
+ if (defined %{ 'Irssi::Script::people::' }) {
+ if (defined ($channel)) {
+ $flags = (&{ 'Irssi::Script::people::find_local_flags' }($chatnet,$channel,$nick,$address));
+ } else {
+ $flags = (&{ 'Irssi::Script::people::find_global_flags' }($chatnet,$nick,$address));
+ }
+ $flags = join('',keys(%{$flags}));
+ } else {
+ my $shasta;
+ if (defined %{ 'Irssi::Script::friends_shasta::' }) {
+ $shasta = 'friends_shasta';
+ } elsif (defined &{ 'Irssi::Script::friends::get_idx' }) {
+ $shasta = 'friends';
+ }
+ if (!$shasta) {
+ return undef;
+ }
+ my $idx = (&{ 'Irssi::Script::'.$shasta.'::get_idx' }($nick,$address));
+ if ($idx == -1) {
+ return '';
+ }
+ $flags = (&{ 'Irssi::Script::'.$shasta.'::get_friends_flags' }($idx,undef));
+ if ($channel) {
+ $flags .= (&{ 'Irssi::Script::'.$shasta.'::get_friends_flags' }($idx,$channel));
+ }
+ }
+ return $flags;
+}
+
+################################
+### manage the triggers-list ###
+################################
+
+# TRIGGER SAVE
+sub cmd_save {
+ my $filename = Irssi::settings_get_str('trigger_file');
+ my $io = new IO::File $filename, "w";
+ if (defined $io) {
+ my $dumper = Data::Dumper->new([\@triggers]);
+ $dumper->Purity(1)->Deepcopy(1);
+ $io->print($dumper->Dump);
+ $io->close;
+ }
+ Irssi::print("Triggers saved to ".$filename);
+}
+
+# save on unload
+sub sig_command_script_unload {
+ my $script = shift;
+ if ($script =~ /(.*\/)?$IRSSI{'name'}\.pl$/) {
+ cmd_save();
+ }
+}
+
+# TRIGGER LOAD
+sub cmd_load {
+ my $converted = 0;
+ my $filename = Irssi::settings_get_str('trigger_file');
+ my $io = new IO::File $filename, "r";
+ if (not defined $io) {
+ if (-e $filename) {
+ Irssi::print "error opening triggers file";
+ }
+ return;
+ }
+ if (defined $io) {
+ no strict 'vars';
+ my $text;
+ $text .= $_ foreach ($io->getlines);
+ my $rep = eval "$text";
+ @triggers = @$rep if ref $rep;
+
+ # convert old names: notices => pubnotices, actions => pubactions
+ foreach $trigger (@triggers) {
+ foreach $oldname ('notices','actions') {
+ if ($trigger->{$oldname}) {
+ delete $trigger->{$oldname};
+ $trigger->{'pub'.$oldname} = 1;
+ $converted = 1;
+ }
+ }
+ }
+ }
+ Irssi::print("Triggers loaded from ".$filename);
+ if ($converted) {
+ Irssi::print("Trigger: Converted old (confusing) params -notices and -actions to -pubnotices and pubactions.\nTriggers file will be in new format next time it's saved.");
+ }
+}
+
+# converts a trigger back to "-switch -options 'foo'" form
+sub to_string {
+ my ($trigger) = @_;
+ my $string;
+
+ # check if all @trigger_all_switches are set
+ my $all_set = 1;
+ foreach my $switch (@trigger_all_switches) {
+ if (!$trigger->{$switch}) {
+ $all_set = 0;
+ last;
+ }
+ }
+ if ($all_set) {
+ $string .= ' -all ';
+ } else {
+ foreach my $switch (@trigger_switches) {
+ if ($trigger->{$switch}) {
+ $string .= '-'.$switch;
+ }
+ }
+ }
+
+ foreach my $param (@trigger_params) {
+ if ($trigger->{$param} || ($param eq 'replace' && defined($trigger->{'replace'}))) {
+ $string .= ' -' . $param . " '$trigger->{$param}'";
+ }
+ }
+ return $string;
+}
+
+# find a trigger (for REPLACE and DELETE), returns index of trigger, or -1 if not found
+sub find_trigger {
+ my ($data) = @_;
+ #my $index = $data-1;
+ if ($data =~ /^[0-9]*$/ and defined($triggers[$data-1])) {
+ return $data-1;
+ }
+ for (my $i=0;$i<scalar(@triggers);$i++) {
+ if ($triggers[$i]->{'regexp'} eq $data) {
+ return $i;
+ }
+ }
+ return -1; # not found
+}
+
+
+# TRIGGER ADD
+sub cmd_add {
+ my ($data, $server, $item) = @_;
+ my @args = &shellwords($data);
+
+ my $trigger = parse_options({},@args);
+ if ($trigger) {
+ push @triggers, $trigger;
+ Irssi::print("Added trigger " . scalar(@triggers) .": ". to_string($trigger));
+ }
+}
+
+# TRIGGER REPLACE <NR>|<regexp>
+sub cmd_replace {
+ my ($data, $server, $item) = @_;
+ my @args = &shellwords($data);
+ my $index = find_trigger(shift @args);
+ if ($index == -1) {
+ Irssi::print "Trigger not found.";
+ } else {
+ parse_options($triggers[$index],@args);
+ Irssi::print("Trigger " . ($index+1) ." changed to: ". to_string($triggers[$index]));
+ }
+}
+
+# parses options to TRIGGER ADD and TRIGGER REPLACE
+sub parse_options {
+ my ($trigger,@args) = @_;
+ARGS: for (my $arg = shift @args; $arg; $arg = shift @args) {
+ # -<param>
+ foreach my $param (@trigger_params) {
+ if ($arg eq '-'.$param) {
+ $trigger->{$param} = shift @args;
+ next ARGS;
+ }
+ }
+ # -all
+ if ($arg eq '-all') {
+ foreach my $switch (@trigger_all_switches) {
+ $trigger->{$switch} = 1;
+ }
+ next ARGS;
+ }
+
+ # -[no]<switch>
+ foreach my $switch (@trigger_switches) {
+ # -<switch>
+ if ($arg eq '-'.$switch) {
+ $trigger->{$switch} = 1;
+ next ARGS;
+ }
+ # -no<switch>
+ elsif ($arg eq '-no'.$switch) {
+ $trigger->{$switch} = undef;
+ next ARGS;
+ }
+ }
+ Irssi::print("Unknown option: $arg");
+ return undef;
+ }
+
+ # check if it has at least one type
+ my $has_a_type;
+ foreach my $type (@trigger_all_switches) {
+ if ($trigger->{$type}) {
+ $has_a_type = 1;
+ last;
+ }
+ }
+ if (!$has_a_type) {
+ Irssi::print("Warning: this trigger doesn't trigger on any type of message. you probably want to add -publics or -all");
+ }
+
+ return $trigger;
+}
+
+# TRIGGER DELETE <num>|<regexp>
+sub cmd_del {
+ my ($data, $server, $item) = @_;
+ my @args = &shellwords($data);
+ my $index = find_trigger($data);
+ if ($index == -1) {
+ Irssi::print ("Trigger $data not found.");
+ return;
+ }
+ print("Deleted ". ($index+1) .": ". to_string($triggers[$index]));
+ splice (@triggers,$index,1);
+}
+
+# TRIGGER LIST
+sub cmd_list {
+ #my (@args) = @_;
+ Irssi::print ("Trigger list:",MSGLEVEL_CLIENTCRAP);
+ my $i=1;
+ foreach my $trigger (@triggers) {
+ Irssi::print(" ". $i++ .": ". to_string($trigger),MSGLEVEL_CLIENTCRAP);
+ }
+}
+
+######################
+### initialisation ###
+######################
+
+command_bind('trigger help',\&cmd_help);
+command_bind('help trigger',\&cmd_help);
+command_bind('trigger add',\&cmd_add);
+command_bind('trigger replace',\&cmd_replace);
+command_bind('trigger list',\&cmd_list);
+command_bind('trigger delete',\&cmd_del);
+command_bind('trigger save',\&cmd_save);
+command_bind('trigger reload',\&cmd_load);
+command_bind 'trigger' => sub {
+ my ( $data, $server, $item ) = @_;
+ $data =~ s/\s+$//g;
+ command_runsub ( 'trigger', $data, $server, $item ) ;
+};
+signal_add_first 'default command trigger' => sub {
+ # gets triggered if called with unknown subcommand
+ cmd_help();
+};
+
+Irssi::signal_add_first('command script load', 'sig_command_script_unload');
+Irssi::signal_add_first('command script unload', 'sig_command_script_unload');
+Irssi::signal_add('setup saved', 'cmd_save');
+
+# This makes tab completion work
+Irssi::command_set_options('trigger add',join(' ',@trigger_options));
+
+Irssi::settings_add_str($IRSSI{'name'}, 'trigger_file', Irssi::get_irssi_dir()."/triggers");
+
+cmd_load();
View
6 .mutt/muttrc
@@ -22,11 +22,11 @@ set spoolfile = $HOME/Mail/vincent
#set pop_pass = "password"
#set pop_host = "pops://pop.gmail.com:995"
-set imap_user="vincent"
+#set imap_user="vincent"
#set imap_pass=xxxxxxxxxxx
-mailboxes imaps://imap.exoweb.net/INBOX
+#mailboxes imaps://imap.exoweb.net/INBOX
-set message_cachedir = $HOME/Mail/cache
+#set message_cachedir = $HOME/Mail/cache
set mail_check = 60 # How often(seconds) we look for new mails
set timeout = 15
View
1 .screenrc
@@ -105,6 +105,7 @@ screen -t work2 3
screen -t misc 4
screen -t ipython 5 ipython
screen -t w3m 6 w3m www.google.com
+screen -t irssi 7 irssi
# screen 0 top
# screen -t monkey ssh monkey
# screen -t daemon 9 tail -f /var/log/daemon.log
View
63 .vim/AsNeeded/ScreenShot.vim
@@ -52,6 +52,19 @@
" 1.02:
" Fixed:
" Reverse attribute improper handling in some cases
+" 1.03: A few bugfixes by Cyril Slobin <slobin@ice.ru>
+" Fixed:
+" 1. Unqualified variables in statusline are treated as global now
+" 3. When encoding is set to utf-8, non-ASCII letters are displayed now
+" 4. Flag options like [+] long ago haven't space before them, fixea
+" Fixed: (by MS)
+" 5. Incorrect highlighting in the case when foreground set and
+" background unset and reverse attribute set
+" 6. Incorrect HTML when vim compiled with gui but running in terminal
+" Added:
+" 7. Support for 256-color xterm added
+"
+"
"
""
" TODO:
@@ -228,11 +241,14 @@ function! s:Nodes.a.Value() " Argument list status as in default title. ({cu
endf
unlet s:Nodes['{'].Value
function! s:Nodes['{'].Value() " F Evaluate expression between '%{' and '}' and substitute result. Note that there is no '%' before the closing '}'.
- let res = eval(self.value)
- if type(res) == type("")
- return res
+ for s:var in keys(g:)
+ execute "let " . s:var . " = g:" . s:var
+ endfor
+ let s:res = eval(self.value)
+ if type(s:res) == type("")
+ return s:res
else
- return string(res)
+ return string(s:res)
endif
endf
function! s:TruncateArray(array,maxwid,left,invischar)
@@ -625,18 +641,30 @@ function! s:EnumWindows()
endf
"}}}
"{{{-----------Html generation functions
-if has('gui')
+if has('gui_running')
function! s:GetColor(id,type)
- return synIDattr(a:id,a:type?'fg#': 'bg#')
+ return synIDattr(a:id,a:type?'fg#': 'bg#')
endf
else
- let s:Colors = ['#000000', '#c00000', '#008000', '#808000', '#0000c0', '#c000c0', '#008080', '#c0c0c0', '#808080', '#ff6060', '#00ff00', '#ffff00', '#8080ff', '#ff40ff', '#00ffff', '#ffffff']
+ if &t_Co == 16
+ let s:Colors = ['#000000', '#c00000', '#008000', '#808000', '#0000c0', '#c000c0', '#008080', '#c0c0c0', '#808080', '#ff6060', '#00ff00', '#ffff00', '#8080ff', '#ff40ff', '#00ffff', '#ffffff']
+ elseif &t_Co == 8
+ let s:Colors = ['#000000', '#ff0000', '#00FF00', '#FFFF00', '#0000ff', '#ff00ff', '#00ffff', '#ffffff']
+ endif
+ let s:valuerange = [0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF]
+" let s:Colors = ['#000000', '#0000c0', '#008000', '#008080', '#c00000', '#c000c0', '#808000', '#c0c0c0', '#808080', '#6060ff', '#00ff00', '#00ffff', '#ff8080', '#ff40ff', '#ffff00', '#ffffff']
function! s:GetColor(id,type)
- let c = synIDattr(a:id,a:type?'fg#': 'bg#')
- if c == '-1' || c == ''
- return ''
- endif
- return s:Colors[eval(c)]
+ let c = synIDattr(a:id,a:type?'fg#': 'bg#')
+ if c == '-1' || c == ''
+ return ''
+ endif
+ let cc = eval(c)
+ if &t_Co != 256 || cc < 0x10
+ return s:Colors[cc]
+ else
+ let cc = cc - 16
+ return '#'.(cc <= 216?(printf('%.2x',s:valuerange[(cc/36)%6]).printf('%.2x',s:valuerange[(cc/6)%6]).printf('%.2x',s:valuerange[cc%6])):repeat(printf('%.2x',8 + (cc - 216)*0x0a),3))
+ endif
endf
endif
function! s:GetHlVect(id)
@@ -645,15 +673,10 @@ function! s:GetHlVect(id)
let reverse = synIDattr(id,'reverse') == '1' && id != hlID('Normal')
let color = s:GetColor(id,!reverse)
let background = s:GetColor(id,reverse)
- if color == '' && background == ''
+ if (color == '' || background == '') && reverse
if reverse
let style = s:GetHlVect('Normal')
- if style[0] != '' && style[1] != ''
- return reverse(style[0:1]) + style[2:]
- endif
- let [color, background] = ['#ffffff', '#000000']
- else
- let [color, background] = ['','']
+ let [color, background] = [color != ''?color : style[1] != ''?style[1] : '#ffffff', background != ''?background : style[0] != ''? style[0] : '#000000']
endif
endif
return [color, background, synIDattr(id, 'bold'), synIDattr(id, 'italic'), synIDattr(id, 'underline')]
@@ -810,7 +833,7 @@ function! s:GetColoredText(lines,start,finish,height,topfill,lineEnd)
while x <= xmax && eval(cond)
let newLine = ((xx<maxRealX)?(prefix):s:GetLinePrefix(y,numWidth,realWidth,1)).tab
while realX < maxRealX
- let char = strpart(str, x - 1, 1)
+ let [whole, char, str; dummy] = matchlist(str, '^\(.\=\)\(.*\)$')
if char == ''
if eol || !&list || !has_key(listChars,'eol')
let diff = maxRealX - realX
View
BIN tools/keycode
Binary file not shown.

0 comments on commit b2d7dca

Please sign in to comment.