[irssi] Configuration + script for notification && bitlbee

This commit is contained in:
Mathieu Maret 2010-11-29 12:19:21 +01:00
parent be9cc7f709
commit cd34f6b458
17 changed files with 1850 additions and 0 deletions

302
.irssi/config Normal file
View File

@ -0,0 +1,302 @@
servers = (
{ address = "irc.stealth.net"; chatnet = "IRCnet"; port = "6668"; },
{ address = "irc.efnet.net"; chatnet = "EFNet"; port = "6667"; },
{
address = "irc.undernet.org";
chatnet = "Undernet";
port = "6667";
},
{ address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
{ address = "irc.gnome.org"; chatnet = "GIMPNet"; port = "6667"; },
{ address = "irc.ptlink.net"; chatnet = "PTlink"; port = "6667"; },
{
address = "irc.sorcery.net";
chatnet = "SorceryNet";
port = "6667";
},
{ address = "localhost"; chatnet = "bitlbee"; port = "6667"; },
{
address = "irc.hashmark.net";
chatnet = "Hashmark";
port = "6667";
},
{ address = "irc.ptnet.org"; chatnet = "PTnet"; port = "6667"; },
{
address = "irc.azzurra.org";
chatnet = "AzzurraNET";
port = "6667";
},
{ address = "127.0.0.1";
chatnet = "bitlbee";
port = "6667";
autoconnect = "yes";
},
{ address = "silc.silcnet.org"; chatnet = "SILC"; port = "706"; },
{
address = "irc.freenode.net";
port = "6667";
chatnet = "freenode";
use_ssl = "no";
ssl_verify = "no";
autoconnect = "no";
}
);
chatnets = {
IRCnet = {
type = "IRC";
max_kicks = "4";
max_modes = "3";
max_msgs = "5";
max_whois = "4";
max_query_chans = "5";
};
EFNet = {
type = "IRC";
max_kicks = "4";
max_modes = "4";
max_msgs = "3";
max_whois = "1";
};
Undernet = {
type = "IRC";
max_kicks = "4";
max_modes = "3";
max_msgs = "3";
max_whois = "30";
};
DALnet = {
type = "IRC";
max_kicks = "4";
max_modes = "6";
max_msgs = "3";
max_whois = "30";
};
freenode = {
type = "IRC";
autosendcmd = "/^msg nickserv identify ***REMOVED***;/^msg nickserv set unfiltered on;";
max_kicks = "4";
max_msgs = "1";
max_modes = "4";
max_whois = "1";
};
GIMPNet = {
type = "IRC";
max_kicks = "4";
max_modes = "4";
max_msgs = "3";
max_whois = "1";
};
PTlink = {
type = "IRC";
max_kicks = "1";
max_modes = "6";
max_msgs = "30";
max_whois = "1";
};
SorceryNet = {
type = "IRC";
max_kicks = "30";
max_modes = "6";
max_msgs = "30";
max_whois = "30";
};
Hashmark = {
type = "IRC";
max_kicks = "4";
max_modes = "3";
max_msgs = "3";
max_whois = "30";
};
PTnet = {
type = "IRC";
max_kicks = "30";
max_modes = "13";
max_msgs = "10";
max_whois = "30";
};
AzzurraNET = {
type = "IRC";
max_kicks = "4";
max_modes = "6";
max_msgs = "3";
};
SILC = { type = "SILC"; };
bitlbee = { type = "IRC";
autosendcmd = "identify ***REMOVED***";
};
minbif = { type = "IRC"; };
};
channels = (
{ name = "&bitlbee"; chatnet = "bitlbee"; autojoin = "yes"; }
{ name = "#openwide"; chatnet = "freenode"; autojoin = "no"; },
);
aliases = {
J = "join";
WJOIN = "join -window";
WQUERY = "query -window";
LEAVE = "part";
BYE = "quit";
EXIT = "quit";
SIGNOFF = "quit";
DESCRIBE = "action";
DATE = "time";
HOST = "userhost";
LAST = "lastlog";
SAY = "msg *";
WI = "whois";
WII = "whois $0 $0";
WW = "whowas";
W = "who";
N = "names";
M = "msg";
T = "topic";
C = "clear";
CL = "clear";
K = "kick";
KB = "kickban";
KN = "knockout";
BANS = "ban";
B = "ban";
MUB = "unban *";
UB = "unban";
IG = "ignore";
UNIG = "unignore";
SB = "scrollback";
UMODE = "mode $N";
WC = "window close";
WN = "window new hide";
SV = "say Irssi $J ($V) - http://irssi.org/";
GOTO = "sb goto";
CHAT = "dcc chat";
RUN = "SCRIPT LOAD";
UPTIME = "eval exec - expr `date +%s` - \\$F | awk '{print \"Irssi uptime: \"int(\\\\\\$1/3600/24)\"d \"int(\\\\\\$1/3600%24)\"h \"int(\\\\\\$1/60%60)\"m \"int(\\\\\\$1%60)\"s\" }'";
CALC = "exec - if which bc &>/dev/null\\; then echo '$*' | bc | awk '{print \"$*=\"$$1}'\\; else echo bc was not found\\; fi";
SBAR = "STATUSBAR";
INVITELIST = "mode $C +I";
Q = "QUERY";
};
statusbar = {
# formats:
# when using {templates}, the template is shown only if it's argument isn't
# empty unless no argument is given. for example {sb} is printed always,
# but {sb $T} is printed only if $T isn't empty.
items = {
# start/end text in statusbars
barstart = "{sbstart}";
barend = "{sbend}";
topicbarstart = "{topicsbstart}";
topicbarend = "{topicsbend}";
# treated "normally", you could change the time/user name to whatever
time = "{sb $Z}";
user = "{sb {sbnickmode $cumode}$N{sbmode $usermode}{sbaway $A}}";
# treated specially .. window is printed with non-empty windows,
# window_empty is printed with empty windows
window = "{sb $winref:$itemname{sbmode $M}}";
window_empty = "{sb $winref{sbservertag $tag}}";
prompt = "{prompt $[.15]itemname}";
prompt_empty = "{prompt $winname}";
topic = " $topic";
topic_empty = " Irssi v$J - http://irssi.org/help/";
# all of these treated specially, they're only displayed when needed
lag = "{sb Lag: $0-}";
act = "{sb Act: $0-}";
more = "-- more --";
};
# there's two type of statusbars. root statusbars are either at the top
# of the screen or at the bottom of the screen. window statusbars are at
# the top/bottom of each split window in screen.
default = {
# the "default statusbar" to be displayed at the bottom of the window.
# contains all the normal items.
window = {
disabled = "no";
# window, root
type = "window";
# top, bottom
placement = "bottom";
# number
position = "1";
# active, inactive, always
visible = "active";
# list of items in statusbar in the display order
items = {
barstart = { priority = "100"; };
time = { };
user = { };
window = { };
window_empty = { };
lag = { priority = "-1"; };
act = { priority = "10"; };
more = { priority = "-1"; alignment = "right"; };
barend = { priority = "100"; alignment = "right"; };
};
};
# statusbar to use in inactive split windows
window_inact = {
type = "window";
placement = "bottom";
position = "1";
visible = "inactive";
items = {
barstart = { priority = "100"; };
window = { };
window_empty = { };
more = { priority = "-1"; alignment = "right"; };
barend = { priority = "100"; alignment = "right"; };
};
};
# we treat input line as yet another statusbar :) It's possible to
# add other items before or after the input line item.
prompt = {
type = "root";
placement = "bottom";
# we want to be at the bottom always
position = "100";
visible = "always";
items = {
prompt = { priority = "-1"; };
prompt_empty = { priority = "-1"; };
# treated specially, this is the real input line.
input = { priority = "10"; };
};
};
# topicbar
topic = {
type = "root";
placement = "top";
position = "1";
visible = "always";
items = {
topicbarstart = { priority = "100"; };
topic = { };
topic_empty = { };
topicbarend = { priority = "100"; alignment = "right"; };
};
};
};
};
settings = {
core = { real_name = "Mathieu"; user_name = "mmaret"; nick = "mmaret"; };
"fe-text" = { actlist_sort = "refnum"; };
};
logs = {
"~/irclogs/hop.log" = {
level = "ALL";
items = ( { type = "target"; name = "#archos-corp"; } );
};
};

294
.irssi/default.theme Normal file
View File

@ -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";
};

3
.irssi/fnotify Normal file
View File

@ -0,0 +1,3 @@
mmaret_ hello
mmaret_ toto
#openwide < gugus> mmaret: ben dis donc t'as pas de veine, moi ils m'ont filé un pc sous windows en me disant "tu fais ce que tu veux avec"

View File

@ -0,0 +1,90 @@
use Irssi;
use Irssi::TextUI;
use strict;
use vars qw($VERSION %IRSSI);
#Setting variables:
#first_away_message - The first /away messsage
#second_away_message - The second /away message
#first_away_timeout - Number of seconds to activate the first away state
#second_away_timeout - Number of seconds to activate the second away state
#away_servers - list of servertags seperated by spaces where auto_away will work.
# If empty (/set -clear away_servers, it will work on every network
#
# CHANGELOG:
# 21 DEC 2004:
# the timer is only being reset when pressing enter. and the away timer starts counting after the last time you pressed enter.
# this is less CPU consuming :-D
$VERSION = '0.2';
%IRSSI = (
authors => 'Tijmen Ruizendaal',
contact => 'tijmen@fokdat.nl',
name => 'auto_away.pl',
description => 'server specific autoaway with two different away states at different intervals',
license => 'GPLv2',
url => 'http://the-timing.nl/stuff/irssi-bitlbee',
changed => '2004-12-21',
);
my $timer;
Irssi::settings_add_str('misc', 'first_away_message', undef);
Irssi::settings_add_str('misc', 'second_away_message', undef);
Irssi::settings_add_int('misc', 'first_away_timeout', undef);
Irssi::settings_add_int('misc', 'second_away_timeout', undef);
Irssi::settings_add_str('misc', 'away_servers', undef);
sub reset_timer{
my $key=shift;
if($key == 10){
my (@servers) = Irssi::servers();
foreach my $server (@servers) {
if($server->{usermode_away} == 1){
$server->command("AWAY -one");
}
}
Irssi::timeout_remove($timer);
my $timeout = Irssi::settings_get_int('first_away_timeout');
if ($timeout){
$timer = Irssi::timeout_add_once($timeout*1000, 'first_away', undef); ## activate first away state
}
}
}
sub first_away{
away(1);
my $timeout = Irssi::settings_get_int('second_away_timeout');
if ($timeout){
Irssi::timeout_remove($timer);
$timer = Irssi::timeout_add_once($timeout*1000, 'away', 2); ## activate second away state
}
}
sub away{
my $state = shift;
my $server_string = Irssi::settings_get_str('away_servers');
my (@away_servers) = split (/ +/, $server_string);
my (@servers) = Irssi::servers();
my $message;
if($state == 1){
$message = Irssi::settings_get_str('first_away_message');
}elsif($state == 2){
$message = Irssi::settings_get_str('second_away_message');
}
if($server_string){
foreach my $away_server (@away_servers) {
#print "|$away_server|";
foreach my $server (@servers) {
if ($away_server eq $server->{tag} && ($server->{usermode_away} == 0 || $state == 2) ){
$server->command("AWAY -one $message");
}
}
}
}else{
my $server=$servers[0];
$server->command("AWAY -all $message");
}
}
Irssi::signal_add_last('gui key pressed', 'reset_timer');

View File

@ -0,0 +1 @@
../auto_away.pl

View File

@ -0,0 +1 @@
../bitlbee_blist.pl

View File

@ -0,0 +1 @@
../bitlbee_html.pl

View File

@ -0,0 +1 @@
../bitlbee_tab_completion.pl

View File

@ -0,0 +1 @@
../bitlbee_typing_notice.pl

View File

@ -0,0 +1 @@
../fnotify.pl

View File

@ -0,0 +1,61 @@
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '0.4';
%IRSSI = (
authors => 'Tijmen "timing" Ruizendaal',
contact => 'tijmen.ruizendaal@gmail.com',
name => 'bitlbee_blist',
description => '/blist <all|online|offline|away> <word>, greps <word> from blist for bitlbee',
license => 'GPLv2',
url => 'http://the-timing.nl/stuff/irssi-bitlbee',
changed => '2006-10-27',
);
my $bitlbee_server_tag = "localhost";
my $bitlbee_channel = "&bitlbee";
my ($list, $word);
get_channel();
Irssi::signal_add_last 'channel sync' => sub {
my( $channel ) = @_;
if( $channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information." ){
$bitlbee_server_tag = $channel->{server}->{tag};
$bitlbee_channel = $channel->{name};
}
};
sub get_channel {
my @channels = Irssi::channels();
foreach my $channel(@channels) {
if ($channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information.") {
$bitlbee_channel = $channel->{name};
$bitlbee_server_tag = $channel->{server}->{tag};
return 1;
}
}
return 0;
}
sub blist {
my ($args, $server, $winit) = @_;
($list, $word) = split(/ /, $args, 2);
if (Irssi::active_win->{'active'}->{'name'} eq $bitlbee_channel) {
Irssi::active_win()->command("msg $bitlbee_channel blist $list");
Irssi::signal_add('event privmsg', 'grep');
} else {
print "Only use in $bitlbee_channel.";
}
}
sub grep {
my ($server, $data, $nick, $address) = @_;
my ($target, $text) = split(/ :/, $data, 2);
if ($text =~ /$word/ && $target =~ /$bitlbee_channel/){
##do nothing
} else {Irssi::signal_stop();}
if ($text =~ /buddies/ && $target =~/$bitlbee_channel/){Irssi::signal_remove('event privmsg', 'grep');}
}
Irssi::command_bind('blist','blist');

View File

@ -0,0 +1,460 @@
# This script is a drop-in HTML filter and parser for use with bitlbee and
# irssi. HTML that can be rendered will be, and the rest will be stripped.
# This should not interfere with other scripts for bitlbee; it is intended to be
# a transparent mangler.
#
# TO USE:
# 1) Adjust the channel and server tag settings below.
# 2) Load the script
# 3) In the bitlbee control channel (&bitlbee), type: set strip_html false
# 4) Enjoy.
#
# For use with bitlbee 1.0+. ChangeLog is available at the bottom of the file.
#
# SETTINGS
# [bitlbee]
# bitlbee_replace_html = ON
# -> replaces HTML in incoming AIM messages
# bitlbee_replace_control_codes = OFF
# -> replaces control codes (bold, underline, reverse) in outgoing private
# messages to AIM users with HTML equivalents. This is turned off by
# default due to the known bug below. If this wouldn't bother you, and you
# would like to have this feature, there's no real harm in turning it on.
# bitlbee_strip_trailing_whitespace = OFF
# -> removes whitespace at the end of messages
#
# KNOWN BUGS
# * This script is somewhat incompatible with splitlong.pl. When long messages
# get split up, and bitlbee_replace_control_codes is ON, the control codes
# will properly get replaced when they are sent to the remote user, but when
# the subsequent split parts are displayed, they may contain the html that
# is supposed to be hidden.
use strict;
use Irssi::TextUI;
use Data::Dumper;
use vars qw($VERSION %IRSSI);
$VERSION = '0.95';
%IRSSI = (
authors => 'Matt "f0rked" Sparks',
contact => 'ms+irssi@quadpoint.org',
name => 'bitlbee_html',
description => 'Adds some HTML parsing to bitlbee messages',
license => 'GPLv2',
url => 'http://quadpoint.org',
changed => '2005-12-18',
);
# TODO: Make these settings (?)
my $bitlbee_channel = "&bitlbee";
my $bitlbee_server_tag = "IM";
# Time to wait to collect all parts of a message from bitlbee server
my $buffer_timeout = 200; # milliseconds
# How long does a message have to be before we consider it a split?
my $split_length = 425;
my %buffer;
my %emitting;
my $debug = 0;
# Thanks to timing (http://the-timing.nl) for this
Irssi::signal_add_last 'channel sync' => sub
{
my($channel) = @_;
if ($channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information.") {
$bitlbee_server_tag = $channel->{server}->{tag};
$bitlbee_channel = $channel->{name};
}
};
# Debug to the active window
sub adebug
{
return if !$debug;
my($t) = @_;
my $w = Irssi::active_win();
$w->print($t, MSGLEVEL_CLIENTCRAP);
}
# Debug to the status window
sub sdebug
{
return if !$debug;
my($t) = @_;
print $t;
}
sub trim
{
($_) = @_;
s/^\s*(.+)\s*$/$1/;
return $_;
}
# return true if given address supports HTML, false if not.
sub does_html
{
my($address) = @_;
return ($address =~ /^[a-z].*\@login\.oscar\.aol\.com$/i ||
$address =~ /^[a-z].*\@login\.icq\.com$/i) ? 1 : 0;
}
# More advanced checking in the future?
sub bee_server
{
my($server) = @_;
return 0 if !$server;
return ($server->{tag} ne $bitlbee_server_tag) ? 0 : 1;
}
sub html2irc
{
($_) = @_;
#print "Before: $_";
s/<br ?\/?>/\n/isg;
s/<font .+?>//isg;
s/<\/font>//ig;
s/<\/?body.*?>//isg;
s/<\/?html>//ig;
s/<a .*?href="(.+?)".*?>(.*?)<\/a>/handle_link($1,$2)/iesg;
# note for <b>,<i>, and <u>, these are encapsulating tags, and they _may_
# contain newlines. This script will split by newlines and emit message
# signals for each part, and a part may end up looking like "<b>foo" with
# no end tag, because the end tag is on the next message. To fix this, we
# have to also check for <b>foo\n and ^foo</b> and put the control codes
# in the appropriate places to avoid formatting the wrong text.
s/<b>(.*?)<\/b>/\002$1\002/ig; # bold
s/<b>(.*?)\n/\002$1\n/isg;
s/^(.*?)<\/b>/\002$1\002/isg;
s/<u>(.*?)<\/u>/\037$1\037/ig; # underline
s/<u>(.*?)\n/\037$1\n/isg;
s/^(.*?)<\/u>/\037$1\037/isg;
s/<i>(.*?)<\/i>/\026$1\026/ig; # reverse (for italics)
s/<i>(.*?)\n/\026$1\n/isg;
s/^(.*?)<\/i>/\026$1\026/isg;
s/&quot;/"/ig;
s/&lt;/</ig;
s/&gt;/>/ig;
s/&amp;/&/ig;
#print "After: $_";
return $_;
}
sub irc2html
{
($_) = @_;
my $ret;
adebug "irc2html input: $_";
if (/^<html>/) {
# Already htmlized? This shouldn't happen. Assume that html tags were
# manually inserted, in which case we should just escape the html and
# return.
s/&/&amp;/g;
s/"/&quot;/g;
s/</&lt;/g;
s/>/&gt;/g;
$ret = "<html>$_</html>";
adebug "irc2html return: $ret";
return $ret;
}
my $orig = $_;
s/&/&amp;/g;
s/"/&quot;/g;
s/</&lt;/g;
s/>/&gt;/g;
s/\002(.*?)\002/<b>$1<\/b>/sg; # bold
s/\002(.*)/<b>$1<\/b>/sg; # unended bold
s/\037(.*?)\037/<u>$1<\/u>/sg; # underline
s/\037(.*)/<u>$1<\/u>/sg;
s/\026(.*?)\026/<i>$1<\/i>/sg; # reverse (italics)
s/\026(.*)/<i>$1<\/i>/sg;
s/\003/<br>/g; # newlines.. this is ctrl+c in irssi.
#print "After: $_, length: ".length($_);
my $ret = ($_ ne $orig) ? "<html>$_</html>" : $orig;
adebug "irc2html return: $ret";
return $ret;
}
sub handle_link
{
my($url, $title) = @_;
$title = html2irc($title);
#adebug $url;
#adebug $title;
if ($url eq $title) {
return $url;
} elsif ($url eq "mailto:$title") {
return $title;
} else {
my $str = "[$title]($url)";
$str =~ s/^\[(\n)*/$1\[/;
return $str;
}
}
sub event_privmsg
{
my($server, $msg, $nick, $address) = @_;
return if !Irssi::settings_get_bool("bitlbee_replace_html");
return if !does_html($address);
return if $emitting{"priv_$nick"}; # don't catch if we're sending signal
return if !bee_server($server);
#print "Received msg: $msg";
# Check the buffer. If it is empty, set a timeout. Fill it in either
# case. This step is necessary because long messages will naturally
# get split up, and to avoid the HTML cutting split up, we buffer
# and then parse everything at once.
if (!$buffer{"priv_$nick"}) {
# We have no buffer, this is a new message
my @data = ("priv", $server, $nick, $address);
Irssi::timeout_add_once($buffer_timeout, "check_buffer", \@data);
}
$msg .= " ";
sdebug "Adding part: '$msg'";
$buffer{"priv_$nick"} .= $msg;#."\002|\002";
# Length hack. Sometimes we get multiple messages quickly from bitlbee
# that aren't html formatted with <br>. Detect this and add newlines
# appropriately.
my $length = length("$nick $address $msg");
sdebug "Length: $length";
if ($length < $split_length) {
$buffer{"priv_$nick"} .= "\n";
}
Irssi::signal_stop;
}
sub event_pubmsg
{
my($server, $msg, $nick, $address, $target) = @_;
return if !Irssi::settings_get_bool("bitlbee_replace_html");
return if !bee_server($server);
return if !does_html($address) and $nick ne "root"; # only aim does html.
return if $emitting{"pub_$nick"};
if (!$buffer{"pub_$nick"}) {
my @data = ("pub", $server, $nick, $address, $target);
Irssi::timeout_add_once($buffer_timeout, "check_buffer", \@data);
}
$buffer{"pub_$nick"} .= $msg;
if (length("$nick $address $msg $target") < $split_length) {
$buffer{"pub_$nick"} .= "\n";
}
Irssi::signal_stop;
}
sub event_action
{
my($server, $msg, $nick, $address, $target) = @_;
#print $msg;
return if !Irssi::settings_get_bool("bitlbee_replace_html");
return if !does_html($address);
return if $emitting{"act_$nick"};
return if !bee_server($server);
if (!$buffer{"act_$nick"}) {
my @data = ("act", $server, $nick, $address, $target);
Irssi::timeout_add_once($buffer_timeout, "check_buffer", \@data);
}
$buffer{"act_$nick"} .= $msg;
if (length("$nick $address $msg $target") < $split_length) {
$buffer{"act_$nick"} .= "\n";
}
Irssi::signal_stop;
}
sub event_send_text
{
my($text, $server, $witem) = @_;
return if !bee_server($server);
return if !Irssi::settings_get_bool("bitlbee_replace_control_codes");
# This will make sure that the person we are talking to is on AIM.
my $address;
my $modified_text = $text;
if ($witem->{type} eq "CHANNEL") {
if (my($n, $s, $m) = $text =~ /^([^ ]+):([ ]*)(.*)$/) {
$address = $witem->nick_find($n)->{host};
$modified_text = "$n:$s" . irc2html($m);
}
} else {
$address = $witem->{address};
$modified_text = irc2html($text);
}
return if !does_html($address);
#print Dumper $witem;
#print "Sending: $modified_text";
Irssi::signal_stop;
Irssi::signal_continue($modified_text, $server, $witem);
}
sub event_send_command
{
my($args, $server, $witem) = @_;
return if !bee_server($server);
adebug "send command: $args";
}
sub event_message_own
{
my($server, $msg, $target, $orig_target) = @_;
return if !bee_server($server);
return if !Irssi::settings_get_bool("bitlbee_replace_control_codes");
return if !Irssi::settings_get_bool("bitlbee_replace_html");
if ($msg =~ /^<html>/ || $msg =~ /^([^ ]+):[ ]*<html>/) {
# If we're on the bitlbee server and the message looks like html,
# we're here.
#print "$server '$msg' $target $orig_target";
if ($orig_target && (my $qu = $server->query_find($target))) {
#print "orig target, found query.";
if ($qu->{address} && !does_html($qu->{address})) {
# The person we're talking to is not using an HTML-compatible
# protocol. Don't treat this as html.
return;
}
} elsif (!$orig_target &&
(my $ch = $server->channel_find($target)) &&
(my($t) = $msg =~ /^([^ ]+):/)) {
my $to_nick = $ch->nick_find($t);
if ($to_nick->{address} && !does_html($to_nick->{address})) {
# We're talking to someone in a particular channel on
# bitlbee, but they don't support HTML.
return;
}
}
# If we made it this far, treat the message as HTML.
Irssi::signal_stop;
Irssi::signal_continue($server, html2irc($msg), $target, $orig_target);
}
}
sub check_buffer
{
my($type, $server, $nick, $address, $target) = @{@_[0]};
# We should now have a full buffer for $nick, we can examine it, parse
# it, and re-emit the appropriate signals without any HTML splitting
# problems.
my $msg = $buffer{"${type}_${nick}"};
sdebug "Complete msg: $msg";
return if !$msg;
$msg = html2irc($msg);
$msg =~ s/[\s]*$//
if Irssi::settings_get_bool("bitlbee_strip_trailing_whitespace");
# $msg is now in the appropriate format, we can emit the signal.
$emitting{"${type}_${nick}"} = 1;
my $sig = "message ";
if ($type eq "priv") {
$sig.="private";
} elsif ($type eq "pub") {
$sig.="public";
} else {
$sig.="irc action";
}
#print "Emitting $sig";
for (split /\n/, $msg) {
Irssi::signal_emit($sig, $server, $_, $nick, $address, $target);
}
delete($buffer{"${type}_${nick}"});
delete($emitting{"${type}_${nick}"});
}
sub event_301
{
return if !Irssi::settings_get_bool("bitlbee_replace_html");
my($server, $data, $foo, $bar)=@_;
return if !bee_server($server);
my($me, $them, @msg) = split / /, $data;
my $msg = join " ", @msg;
$msg = html2irc($msg);
$msg = ~s/[\s]*$//
if Irssi::settings_get_bool("bitlbee_strip_trailing_whitespace");
Irssi::signal_stop;
Irssi::signal_continue($server, "$me $them $msg", $foo, $bar);
}
Irssi::signal_add_first("message private", "event_privmsg");
Irssi::signal_add_first("message public", "event_pubmsg");
Irssi::signal_add_first("event 301", "event_301");
Irssi::signal_add_first("message irc action", "event_action");
Irssi::signal_add_first("send text", "event_send_text");
Irssi::signal_add_first("send command", "event_send_command");
Irssi::signal_add_first("message own_private", "event_message_own");
Irssi::signal_add_first("message own_public", "event_message_own");
Irssi::signal_add_first("message irc own_action", "event_message_own");
# Settings
Irssi::settings_add_bool("bitlbee", "bitlbee_replace_html", 1);
Irssi::settings_add_bool("bitlbee", "bitlbee_replace_control_codes", 0);
Irssi::settings_add_bool("bitlbee", "bitlbee_strip_trailing_whitespace", 0);
### ChangeLog ###
# Version 0.95
# - fixed a small bug causing links to sometimes not be properly formatted
# Version 0.94
# - fixed bug causing a script error when typing in the status window and on
# startup of irssi
# Version 0.93
# - fixed a stupid case issue in address recognization.
# Version 0.92
# - code cleanups
# - control codes are allowed in control channel, but targets must be used
# (remoteuser: I'm talking to you) (this is the default)
# Version 0.91
# - more intelligent checking for HTML support
# - allowed html from AIM users over ICQ connections
# Version 0.9
# - removed html parsing for non-AIM connections
# - added support for replacing control codes (created by ctrl+b, ctrl+v, and
# cltr+-) with html equivalents. Disabled by default.
#
# Version 0.8 (2005-12-02)
# - Initial public release

View File

@ -0,0 +1,94 @@
#CHANGELOG:
#
#28-11-2004:
#it gives a join message in a query if a user joins &bitlbee and you hve a query open with that person.
#
#/statusbar window add join_notice
#use Data::Dumper;
use strict;
#use Irssi::TextUI;
#use Irssi::Themes;
use vars qw($VERSION %IRSSI);
$VERSION = '1.2';
%IRSSI = (
authors => 'Tijmen "timing" Ruizendaal',
contact => 'tijmen.ruizendaal@gmail.com',
name => 'BitlBee_join_notice',
description => ' 1. Adds an item to the status bar wich shows [joined: <nicks>] when someone is joining &bitlbee.
2. Shows join messages in the query.',
license => 'GPLv2',
url => 'http://the-timing.nl/stuff/irssi-bitlbee',
changed => '2006-10-27',
);
my %online;
my %tag;
my $bitlbee_channel= "&bitlbee";
my $bitlbee_server_tag="localhost";
get_channel();
Irssi::signal_add_last 'channel sync' => sub {
my( $channel ) = @_;
if( $channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information." ){
$bitlbee_server_tag = $channel->{server}->{tag};
$bitlbee_channel = $channel->{name};
}
};
sub get_channel {
my @channels = Irssi::channels();
foreach my $channel(@channels) {
if ($channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information.") {
$bitlbee_channel = $channel->{name};
$bitlbee_server_tag = $channel->{server}->{tag};
return 1;
}
}
return 0;
}
sub event_join {
my ($server, $channel, $nick, $address) = @_;
if ($channel eq ":$bitlbee_channel" && $server->{tag} eq $bitlbee_server_tag){
$online{$nick} = 1;
Irssi::timeout_remove($tag{$nick});
$tag{$nick} = Irssi::timeout_add(7000, 'empty', $nick);
Irssi::statusbar_items_redraw('join_notice');
my $window = Irssi::window_find_item($nick);
if($window){
$window->printformat(MSGLEVEL_JOINS, 'join', $nick, $address, $bitlbee_channel);
}
}
}
sub join_notice {
my ($item, $get_size_only) = @_;
my $line;
foreach my $key (keys(%online) )
{
$line = $line." ".$key;
}
if ($line ne "" ){
$item->default_handler($get_size_only, "{sb joined:$line}", undef, 1);
$line = "";
}else{
$item->default_handler($get_size_only, "", undef, 1);
}
}
sub empty{
my $nick = shift;
delete($online{$nick});
Irssi::timeout_remove($tag{$nick});
Irssi::statusbar_items_redraw('join_notice');
}
Irssi::signal_add("event join", "event_join");
Irssi::statusbar_item_register('join_notice', undef, 'join_notice');
Irssi::statusbars_recreate_items();
Irssi::theme_register([
'join', '{channick_hilight $0} {chanhost $1} has joined {channel $2}',
]);

View File

@ -0,0 +1,64 @@
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '1.2';
%IRSSI = (
authors => 'Tijmen "timing" Ruizendaal',
contact => 'tijmen.ruizendaal@gmail.com',
name => 'bitlbee_nick_change',
description => 'Shows an IM nickchange in an Irssi way. (in a query and in the bitlbee channel).',
license => 'GPLv2',
url => 'http://the-timing.nl/stuff/irssi-bitlbee',
changed => '2006-10-27',
);
my $bitlbee_channel = "&bitlbee";
my $bitlbee_server_tag = "localhost";
Irssi::signal_add_last 'channel sync' => sub {
my( $channel ) = @_;
if( $channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information." ){
$bitlbee_server_tag = $channel->{server}->{tag};
$bitlbee_channel = $channel->{name};
}
};
get_channel();
sub get_channel {
my @channels = Irssi::channels();
foreach my $channel(@channels) {
if ($channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information.") {
$bitlbee_channel = $channel->{name};
$bitlbee_server_tag = $channel->{server}->{tag};
return 1;
}
}
return 0;
}
sub message {
my ($server, $msg, $nick, $address, $target) = @_;
if($server->{tag} eq $bitlbee_server_tag) {
if($msg =~ /User.*changed name to/) {
$nick = $msg;
$nick =~ s/.* - User `(.*)' changed name to.*/$1/;
my $window = $server->window_find_item($nick);
if ($window) {
$window->printformat(MSGLEVEL_CRAP, 'nick_change',$msg);
Irssi::signal_stop();
} else {
my $window = $server->window_find_item($bitlbee_channel);
$window->printformat(MSGLEVEL_CRAP, 'nick_change',$msg);
Irssi::signal_stop();
}
}
}
}
Irssi::signal_add_last ('message public', 'message');
Irssi::theme_register([
'nick_change', '$0'
]);

View File

@ -0,0 +1,88 @@
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '1.3';
%IRSSI = (
authors => 'Tijmen "timing" Ruizendaal & Wilmer van der Gaast',
contact => 'tijmen.ruizendaal@gmail.com',
name => 'BitlBee_tab_completion',
description => 'Intelligent Tab-completion for BitlBee commands.',
license => 'GPLv2',
url => 'http://the-timing.nl/stuff/irssi-bitlbee',
changed => '2009-08-11',
);
my $root_nick = 'root';
my $bitlbee_channel = '&bitlbee';
my $bitlbee_server_tag = 'localhost';
my $get_completions = 0;
my @commands;
Irssi::signal_add_last 'channel sync' => sub {
my( $channel ) = @_;
if( $channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information." ){
$bitlbee_server_tag = $channel->{server}->{tag};
$bitlbee_channel = $channel->{name};
request_completions();
}
};
if (get_channel()) {
request_completions();
}
sub request_completions {
$get_completions = 1;
Irssi::server_find_tag($bitlbee_server_tag)->send_raw( 'COMPLETIONS' );
}
sub get_channel {
my @channels = Irssi::channels();
foreach my $channel(@channels) {
if ($channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information.") {
$bitlbee_channel = $channel->{name};
$bitlbee_server_tag = $channel->{server}->{tag};
return 1;
}
}
return 0;
}
sub irc_notice {
return unless $get_completions;
my( $server, $msg, $from, $address, $target ) = @_;
if( $msg =~ s/^COMPLETIONS // ) {
$root_nick = $from;
if( $msg eq 'OK' ) {
@commands = ();
}
elsif( $msg eq 'END' ) {
$get_completions = 0;
}
@commands = ( @commands, $msg );
Irssi::signal_stop();
}
}
sub complete_word {
my ($complist, $window, $word, $linestart, $want_space) = @_;
my $channel = $window->get_active_name();
if ($channel eq $bitlbee_channel or $channel eq $root_nick or $linestart =~ /^\/(msg|query) \Q$root_nick\E */i){
$linestart =~ s/^\/(msg|query) \Q$root_nick\E *//i;
$linestart =~ s/^\Q$root_nick\E[:,] *//i;
foreach my $command(@commands) {
if ($command =~ /^$word/i) {
push @$complist, $command;
}
}
}
}
Irssi::signal_add_last('complete word', 'complete_word');
Irssi::signal_add_first('message irc notice', 'irc_notice');

View File

@ -0,0 +1,320 @@
# INSTALLATION
# [&bitlbee] set typing_notice true
# <@root> typing_notice = `true'
# AND
# /statusbar window add typing_notice
#
# SETTINGS
# [bitlbee]
# bitlbee_send_typing = ON
# -> send typing messages to buddies
# bitlbee_typing_allwin = OFF
# -> show typing notifications in all windows
#
#
# Changelog:
#
# 2006-11-02 (version 1.6.1_
# * Sending typing works again.
#
# 2006-10-27 (version 1.6)
# * 'channel sync' re-implemented.
# * bitlbee_send_typing was a string setting, It's a boolean now, like it should.
#
# 2006-10-24 (version 1.5)
#
# * Sending notices to online users only.
# * Using the new get_channel function;
#
# 2005-12-15 (version 1.42):
# * Fixed small bug with typing notices disappearing under certain circumstances
# in channels
# * Fixed bug that caused outgoing notifications not to work
# * root cares not about our typing status.
#
# 2005-12-04 (version 1.41):
# * Implemented stale states in statusbar (shows "(stale)" for OSCAR connections)
# * Introduced bitlbee_typing_allwin (default OFF). Set this to ON to make
# typing notifications visible in all windows.
#
# 2005-12-03 (version 1.4):
# * Major code cleanups and rewrites for bitlbee 1.0 with the updated typing
# scheme. TYPING 0, TYPING 1, and TYPING 2 are now supported from the server.
# * Stale states (where user has typed in text but has stopped typing) are now
# recognized.
# * Bug where user thinks you are still typing if you close the window after
# typing something and then erasing it quickly.. fixed.
# * If a user signs off while they are still typing, the notification is removed
# This update by Matt "f0rked" Sparks
#
# 2005-08-26:
# Some fixes for AIM, Thanks to Dracula.
#
# 2005-08-16:
# AIM supported, for sending notices, using CTCP TYPING 0. (Use the AIM patch from Hanji http://get.bitlbee.org/patches/)
#
# 2004-10-31:
# Sends typing notice to the bitlbee server when typing a message in irssi. bitlbee > 0.92
#
# 2004-06-11:
# shows [typing: ] in &bitlbee with multiple users.
#
use strict;
use Irssi::TextUI;
use vars qw($VERSION %IRSSI);
$VERSION = '1.6.1';
%IRSSI = (
authors => 'Tijmen "timing" Ruizendaal, Matt "f0rked" Sparks',
contact => 'tijmen.ruizendaal@gmail.com, root@f0rked.com',
name => 'BitlBee_typing_notice',
description => '1. Adds an item to the status bar wich shows [typing] when someone is typing a message on the supported IM-networks
2. Sending typing notices to the supported IM networks (the other way arround)',
license => 'GPLv2',
url => 'http://the-timing.nl/stuff/irssi-bitlbee,
http://f0rked.com',
changed => '2006-11-02',
);
my $bitlbee_channel = "&bitlbee";
my $bitlbee_server_tag = "localhost";
my $KEEP_TYPING_TIMEOUT = 1;
my $STOP_TYPING_TIMEOUT = 7; # How often to check if we are typing, or on msn,
# how long to keep the typing notice up, or check
# if the other user is still typing...
my %timer_tag;
my %typing;
my %tag;
my $line;
my %out_typing;
my $lastkey;
my $keylog_active = 1;
my $command_char = Irssi::settings_get_str('cmdchars');
my $to_char = Irssi::settings_get_str("completion_char");
get_channel();
Irssi::signal_add_last 'channel sync' => sub {
my( $channel ) = @_;
if( $channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information." ){
$bitlbee_server_tag = $channel->{server}->{tag};
$bitlbee_channel = $channel->{name};
}
};
sub get_channel {
my @channels = Irssi::channels();
foreach my $channel(@channels) {
if ($channel->{topic} eq "Welcome to the control channel. Type \x02help\x02 for help information.") {
$bitlbee_channel = $channel->{name};
$bitlbee_server_tag = $channel->{server}->{tag};
return 1;
}
}
return 0;
}
sub event_ctcp_msg {
my ($server, $msg, $from, $address) = @_;
#print "CTCP: $msg $from $address";
return if $server->{tag} ne $bitlbee_server_tag;
if (my($type) = $msg =~ "TYPING ([0-9])") {
Irssi::signal_stop();
if ($type == 0) {
unset_typing($from);
}
elsif ($type == 1) {
$typing{$from}=1;
if ($address !~ /\@login\.oscar\.aol\.com/
and $address !~ /\@YAHOO/
and $address !~ /\@login\.icq\.com/) {
Irssi::timeout_remove($tag{$from});
$tag{$from}=Irssi::timeout_add_once($STOP_TYPING_TIMEOUT*1000,"unset_typing",$from);
}
redraw($from);
}
elsif ($type == 2) {
stale_typing($from);
}
}
}
sub unset_typing {
my($from,$no_redraw)=@_;
delete $typing{$from} if $typing{$from};
Irssi::timeout_remove($tag{$from});
redraw($from) if !$no_redraw;
}
sub stale_typing {
my($from)=@_;
$typing{$from}=2;
redraw($from);
}
sub redraw {
my($from)=@_;
my $window = Irssi::active_win();
my $channel = $window->get_active_name();
if ($from eq $channel || $channel eq $bitlbee_channel
|| $channel =~ /&chat_0/
|| Irssi::settings_get_bool("bitlbee_typing_allwin")) {
Irssi::statusbar_items_redraw('typing_notice');
}
}
sub event_msg {
my ($server,$data,$from,$address,$target) = @_;
return if $server->{tag} ne $bitlbee_server_tag;
my $channel=Irssi::active_win()->get_active_name();
unset_typing $from, "no redraw";
unset_typing $channel;
}
sub event_quit {
my($server,$nick,$address,$reason)=@_;
return if $server->{tag} ne $bitlbee_server_tag;
unset_typing $nick;
}
sub typing_notice {
my ($item, $get_size_only) = @_;
my $window = Irssi::active_win();
my $channel = $window->get_active_name();
if (exists($typing{$channel})) {
my $append=$typing{$channel}==2 ? " (stale)" : "";
$item->default_handler($get_size_only, "{sb typing$append}", 0, 1);
}
else {
$item->default_handler($get_size_only, "", 0, 1);
Irssi::timeout_remove($tag{$channel});
}
if ($channel eq $bitlbee_channel || $channel =~ /&chat_0/
|| Irssi::settings_get_bool("bitlbee_typing_allwin")) {
foreach my $key (keys(%typing)) {
$line .= " ".$key;
if ($typing{$key}==2) { $line .= " (stale)"; }
}
if ($line ne "") {
$item->default_handler($get_size_only, "{sb typing:$line}", 0, 1);
$line = "";
}
}
}
sub empty {
my $from = shift;
delete($typing{$from});
Irssi::statusbar_items_redraw('typing_notice');
}
sub window_change {
Irssi::statusbar_items_redraw('typing_notice');
my $win = !Irssi::active_win() ? undef : Irssi::active_win()->{active};
if (ref $win && ($win->{server}->{tag} eq $bitlbee_server_tag)) {
if (!$keylog_active) {
$keylog_active = 1;
Irssi::signal_add_last('gui key pressed', 'key_pressed');
#print "Keylog started";
}
}
else {
if ($keylog_active) {
$keylog_active = 0;
Irssi::signal_remove('gui key pressed', 'key_pressed');
#print "Keylog stopped";
}
}
}
sub key_pressed {
return if !Irssi::settings_get_bool("bitlbee_send_typing");
my $key = shift;
if ($key != 9 && $key != 10 && $lastkey != 27 && $key != 27
&& $lastkey != 91 && $key != 126 && $key != 127)
{
my $server = Irssi::active_server();
my $window = Irssi::active_win();
my $nick = $window->get_active_name();
if ($server->{tag} eq $bitlbee_server_tag &&
$nick ne "(status)" &&
$nick ne "root")
{
if ($nick eq $bitlbee_channel) {
my $input = Irssi::parse_special("\$L");
my ($first_word) = split(/ /,$input);
if ($input !~ /^$command_char.*/ && $first_word =~ s/$to_char$//){
send_typing($first_word);
}
}
else {
my $input = Irssi::parse_special("\$L");
if ($input !~ /^$command_char.*/ && length($input) > 0){
send_typing($nick);
}
}
}
}
$lastkey = $key;
}
sub out_empty {
my ($a) = @_;
my($nick,$tag)=@{$a};
delete($out_typing{$nick});
#print $winnum."|".$nick;
if (my $server=Irssi::server_find_tag($tag)) {
$server->command("^CTCP $nick TYPING 0");
}
}
sub send_typing {
my $nick = shift;
if (!exists($out_typing{$nick}) || time - $out_typing{$nick} > $KEEP_TYPING_TIMEOUT) {
my @nicks = Irssi::server_find_tag($bitlbee_server_tag)->channel_find($bitlbee_channel)->nicks();
my $exists=0;
foreach my $nick1(@nicks) { #check if the nickname is in the BitlBee channel
if($nick1->{'nick'} eq $nick) {
# print "Exists!";
$exists=1;
}
}
if (!$exists) {
#print "Does not exist";
return;
}
#print "Send typing";
my $server = Irssi::active_server();
$server->command("^CTCP $nick TYPING 1");
$out_typing{$nick} = time;
### Reset 'stop-typing' timer
if ($timer_tag{$nick}) {
Irssi::timeout_remove($timer_tag{$nick});
delete($timer_tag{$nick});
}
$timer_tag{$nick} = Irssi::timeout_add_once($STOP_TYPING_TIMEOUT*1000, 'out_empty', ["$nick", $server->{tag}]);
}
}
#README: Delete the old bitlbee_send_typing string from ~/.irssi/config. A boolean is better.
Irssi::settings_add_bool("bitlbee","bitlbee_send_typing",1);
Irssi::settings_add_bool("bitlbee","bitlbee_typing_allwin",0);
Irssi::signal_add("ctcp msg", "event_ctcp_msg");
Irssi::signal_add("message private", "event_msg");
Irssi::signal_add("message public", "event_msg");
Irssi::signal_add("message quit", "event_quit");
Irssi::signal_add_last('window changed', 'window_change');
Irssi::signal_add_last('gui key pressed', 'key_pressed');
Irssi::statusbar_item_register('typing_notice', undef, 'typing_notice');
Irssi::statusbars_recreate_items();

68
.irssi/scripts/fnotify.pl Normal file
View File

@ -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