Add dotfiles from home directory

Tracks shell configs (zsh/bash), vim, tmux, irssi, fonts, themes,
and ~/.local/bin scripts. Sensitive files (.ssh, .gnupg, history,
credentials) and large app data are excluded via .gitignore.
This commit is contained in:
2026-03-21 00:52:50 -07:00
parent bf3c24aa85
commit bc9f9d8094
71 changed files with 2742 additions and 0 deletions

392
.irssi/config Normal file
View File

@@ -0,0 +1,392 @@
servers = (
{ address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
{ address = "irc.efnet.org"; chatnet = "EFNet"; port = "6667"; },
{ address = "irc.esper.net"; chatnet = "EsperNet"; port = "6667"; },
{
address = "chat.freenode.net";
chatnet = "Freenode";
port = "6667";
},
{
address = "irc.gamesurge.net";
chatnet = "GameSurge";
port = "6667";
},
{ address = "eu.irc6.net"; chatnet = "IRCnet"; port = "6667"; },
{ address = "open.ircnet.net"; chatnet = "IRCnet"; port = "6667"; },
{
address = "irc.ircsource.net";
chatnet = "IRCSource";
port = "6667";
},
{ address = "irc.netfuze.net"; chatnet = "NetFuze"; port = "6667"; },
{ address = "irc.oftc.net"; chatnet = "OFTC"; port = "6667"; },
{
address = "irc.quakenet.org";
chatnet = "QuakeNet";
port = "6667";
},
{ address = "irc.rizon.net"; chatnet = "Rizon"; port = "6667"; },
{ address = "silc.silcnet.org"; chatnet = "SILC"; port = "706"; },
{
address = "irc.undernet.org";
chatnet = "Undernet";
port = "6667";
}
);
chatnets = {
DALnet = {
type = "IRC";
max_kicks = "4";
max_msgs = "20";
max_whois = "30";
};
EFNet = {
type = "IRC";
max_kicks = "1";
max_msgs = "4";
max_whois = "1";
};
EsperNet = {
type = "IRC";
max_kicks = "1";
max_msgs = "4";
max_whois = "1";
};
Freenode = {
type = "IRC";
max_kicks = "1";
max_msgs = "4";
max_whois = "1";
};
GameSurge = {
type = "IRC";
max_kicks = "1";
max_msgs = "1";
max_whois = "1";
};
IRCnet = {
type = "IRC";
max_kicks = "1";
max_msgs = "1";
max_whois = "1";
};
IRCSource = {
type = "IRC";
max_kicks = "1";
max_msgs = "4";
max_whois = "1";
};
NetFuze = {
type = "IRC";
max_kicks = "1";
max_msgs = "1";
max_whois = "1";
};
OFTC = { type = "IRC"; max_kicks = "1"; max_msgs = "1"; max_whois = "1"; };
QuakeNet = {
type = "IRC";
max_kicks = "1";
max_msgs = "1";
max_whois = "1";
};
Rizon = {
type = "IRC";
max_kicks = "1";
max_msgs = "1";
max_whois = "1";
};
SILC = { type = "SILC"; };
Undernet = {
type = "IRC";
max_kicks = "1";
max_msgs = "1";
max_whois = "1";
};
};
channels = (
{ name = "#lobby"; chatnet = "EsperNet"; autojoin = "No"; },
{ name = "#freenode"; chatnet = "Freenode"; autojoin = "No"; },
{ name = "#irssi"; chatnet = "Freenode"; autojoin = "No"; },
{ name = "#gamesurge"; chatnet = "GameSurge"; autojoin = "No"; },
{ name = "#irssi"; chatnet = "IRCNet"; autojoin = "No"; },
{ name = "#ircsource"; chatnet = "IRCSource"; autojoin = "No"; },
{ name = "#netfuze"; chatnet = "NetFuze"; autojoin = "No"; },
{ name = "#oftc"; chatnet = "OFTC"; autojoin = "No"; },
{ name = "silc"; chatnet = "SILC"; autojoin = "No"; }
);
aliases = {
ATAG = "WINDOW SERVER";
ADDALLCHANS = "SCRIPT EXEC foreach my \\$channel (Irssi::channels()) { Irssi::command(\"CHANNEL ADD -auto \\$channel->{name} \\$channel->{server}->{tag} \\$channel->{key}\")\\;}";
B = "BAN";
BACK = "AWAY";
BANS = "BAN";
BYE = "QUIT";
C = "CLEAR";
CALC = "EXEC - if command -v bc >/dev/null 2>&1\\; then printf '%s=' '$*'\\; echo '$*' | bc -l\\; else echo bc was not found\\; fi";
CHAT = "DCC CHAT";
CUBES = "SCRIPT EXEC Irssi::active_win->print(\"%_bases\", MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print( do { join '', map { \"%x0\\${_}0\\$_\" } '0'..'9','A'..'F' }, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print(\"%_cubes\", MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print( do { my \\$y = \\$_*6 \\; join '', map { my \\$x = \\$_ \\; map { \"%x\\$x\\$_\\$x\\$_\" } @{['0'..'9','A'..'Z']}[\\$y .. \\$y+5] } 1..6 }, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) for 0..5 \\; Irssi::active_win->print(\"%_grays\", MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print( do { join '', map { \"%x7\\${_}7\\$_\" } 'A'..'X' }, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print(\"%_mIRC extended colours\", MSGLEVEL_CLIENTCRAP) \\; my \\$x \\; \\$x .= sprintf \"\00399,%02d%02d\",\\$_,\\$_ for 0..15 \\; Irssi::active_win->print(\\$x, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) \\; for my \\$z (0..6) { my \\$x \\; \\$x .= sprintf \"\00399,%02d%02d\",\\$_,\\$_ for 16+(\\$z*12)..16+(\\$z*12)+11 \\; Irssi::active_win->print(\\$x, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) }";
DATE = "TIME";
DEHIGHLIGHT = "DEHILIGHT";
DESCRIBE = "ACTION";
DHL = "DEHILIGHT";
EXEMPTLIST = "MODE $C +e";
EXIT = "QUIT";
GOTO = "SCROLLBACK GOTO";
HIGHLIGHT = "HILIGHT";
HL = "HILIGHT";
HOST = "USERHOST";
INVITELIST = "MODE $C +I";
J = "JOIN";
K = "KICK";
KB = "KICKBAN";
KN = "KNOCKOUT";
LAST = "LASTLOG";
LEAVE = "PART";
M = "MSG";
MUB = "UNBAN *";
N = "NAMES";
NMSG = "^MSG";
P = "PART";
Q = "QUERY";
RESET = "SET -default";
RUN = "SCRIPT LOAD";
SAY = "MSG *";
SB = "SCROLLBACK";
SBAR = "STATUSBAR";
SIGNOFF = "QUIT";
SV = "MSG * Irssi $J ($V) - http://www.irssi.org";
T = "TOPIC";
UB = "UNBAN";
UMODE = "MODE $N";
UNSET = "SET -clear";
W = "WHO";
WC = "WINDOW CLOSE";
WG = "WINDOW GOTO";
WJOIN = "JOIN -window";
WI = "WHOIS";
WII = "WHOIS $0 $0";
WL = "WINDOW LIST";
WN = "WINDOW NEW HIDDEN";
WQUERY = "QUERY -window";
WW = "WHOWAS";
1 = "WINDOW GOTO 1";
2 = "WINDOW GOTO 2";
3 = "WINDOW GOTO 3";
4 = "WINDOW GOTO 4";
5 = "WINDOW GOTO 5";
6 = "WINDOW GOTO 6";
7 = "WINDOW GOTO 7";
8 = "WINDOW GOTO 8";
9 = "WINDOW GOTO 9";
10 = "WINDOW GOTO 10";
11 = "WINDOW GOTO 11";
12 = "WINDOW GOTO 12";
13 = "WINDOW GOTO 13";
14 = "WINDOW GOTO 14";
15 = "WINDOW GOTO 15";
16 = "WINDOW GOTO 16";
17 = "WINDOW GOTO 17";
18 = "WINDOW GOTO 18";
19 = "WINDOW GOTO 19";
20 = "WINDOW GOTO 20";
21 = "WINDOW GOTO 21";
22 = "WINDOW GOTO 22";
23 = "WINDOW GOTO 23";
24 = "WINDOW GOTO 24";
25 = "WINDOW GOTO 25";
26 = "WINDOW GOTO 26";
27 = "WINDOW GOTO 27";
28 = "WINDOW GOTO 28";
29 = "WINDOW GOTO 29";
30 = "WINDOW GOTO 30";
31 = "WINDOW GOTO 31";
32 = "WINDOW GOTO 32";
33 = "WINDOW GOTO 33";
34 = "WINDOW GOTO 34";
35 = "WINDOW GOTO 35";
36 = "WINDOW GOTO 36";
37 = "WINDOW GOTO 37";
38 = "WINDOW GOTO 38";
39 = "WINDOW GOTO 39";
40 = "WINDOW GOTO 40";
41 = "WINDOW GOTO 41";
42 = "WINDOW GOTO 42";
43 = "WINDOW GOTO 43";
44 = "WINDOW GOTO 44";
45 = "WINDOW GOTO 45";
46 = "WINDOW GOTO 46";
47 = "WINDOW GOTO 47";
48 = "WINDOW GOTO 48";
49 = "WINDOW GOTO 49";
50 = "WINDOW GOTO 50";
51 = "WINDOW GOTO 51";
52 = "WINDOW GOTO 52";
53 = "WINDOW GOTO 53";
54 = "WINDOW GOTO 54";
55 = "WINDOW GOTO 55";
56 = "WINDOW GOTO 56";
57 = "WINDOW GOTO 57";
58 = "WINDOW GOTO 58";
59 = "WINDOW GOTO 59";
60 = "WINDOW GOTO 60";
61 = "WINDOW GOTO 61";
62 = "WINDOW GOTO 62";
63 = "WINDOW GOTO 63";
64 = "WINDOW GOTO 64";
65 = "WINDOW GOTO 65";
66 = "WINDOW GOTO 66";
67 = "WINDOW GOTO 67";
68 = "WINDOW GOTO 68";
69 = "WINDOW GOTO 69";
70 = "WINDOW GOTO 70";
71 = "WINDOW GOTO 71";
72 = "WINDOW GOTO 72";
73 = "WINDOW GOTO 73";
74 = "WINDOW GOTO 74";
75 = "WINDOW GOTO 75";
76 = "WINDOW GOTO 76";
77 = "WINDOW GOTO 77";
78 = "WINDOW GOTO 78";
79 = "WINDOW GOTO 79";
80 = "WINDOW GOTO 80";
81 = "WINDOW GOTO 81";
82 = "WINDOW GOTO 82";
83 = "WINDOW GOTO 83";
84 = "WINDOW GOTO 84";
85 = "WINDOW GOTO 85";
86 = "WINDOW GOTO 86";
87 = "WINDOW GOTO 87";
88 = "WINDOW GOTO 88";
89 = "WINDOW GOTO 89";
90 = "WINDOW GOTO 90";
91 = "WINDOW GOTO 91";
92 = "WINDOW GOTO 92";
93 = "WINDOW GOTO 93";
94 = "WINDOW GOTO 94";
95 = "WINDOW GOTO 95";
96 = "WINDOW GOTO 96";
97 = "WINDOW GOTO 97";
98 = "WINDOW GOTO 98";
99 = "WINDOW GOTO 99";
};
statusbar = {
items = {
barstart = "{sbstart}";
barend = "{sbend}";
topicbarstart = "{topicsbstart}";
topicbarend = "{topicsbend}";
time = "{sb $Z}";
user = "{sb {sbnickmode $cumode}$N{sbmode $usermode}{sbaway $A}}";
window = "{sb $winref:$tag/$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://www.irssi.org";
lag = "{sb Lag: $0-}";
act = "{sb Act: $0-}";
more = "-- more --";
};
default = {
window = {
disabled = "no";
type = "window";
placement = "bottom";
position = "1";
visible = "active";
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"; };
};
};
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"; };
};
};
prompt = {
type = "root";
placement = "bottom";
position = "100";
visible = "always";
items = {
prompt = { priority = "-1"; };
prompt_empty = { priority = "-1"; };
input = { priority = "10"; };
};
};
topic = {
type = "root";
placement = "top";
position = "1";
visible = "always";
items = {
topicbarstart = { priority = "100"; };
topic = { };
topic_empty = { };
topicbarend = { priority = "100"; alignment = "right"; };
};
};
dccstat = { items = { dccstat = { }; }; disabled = "yes"; };
};
};
settings = {
core = { real_name = "g"; user_name = "g"; nick = "grave"; };
"fe-text" = { actlist_sort = "refnum"; };
"irc/core" = { cmds_max_at_once = "999999"; cmd_queue_speed = "0ms"; };
"irc/dcc" = {
dcc_download_path = "/media/dissimulo/PhantomPhreak/Anime";
};
"perl/core/scripts" = {
dccstat_short_mode = "no";
dccstat_EXPERIMENTAL_fast_refresh = "no";
dccstat_cycle_through_transfers = "yes";
dccstat_hide_sbar_when_inactive = "yes";
dccstat_progbar_width = "5";
dccstat_refresh = "1";
dccstat_auto_short_limit = "2";
dccstat_cycle_through_transfers_refresh = "3";
};
};

297
.irssi/default.theme Normal file
View File

@@ -0,0 +1,297 @@
# 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-%n!%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. "ownnick" 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 = "%_$*%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 = "%_$*%n";
# private message in query
privmsgnick = "{msgnick %R$*%n}";
##
## Actions (/ME stuff)
##
# used internally by this theme
action_core = "%_ * $*%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 = "%_ (*) $*%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 = "%_$*%n: ";
wallop_nick = "%n$*";
wallop_action = "%_ * $*%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 = "%_$*%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 = "%_ (*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";
};
formats = {
"fe-common/core" = { pubmsg = "{pubmsgnick $2 {pubnick \00305$0}}$1"; };
};

View File

@@ -0,0 +1,500 @@
use Irssi::Irc;
use Irssi 20020217; # Irssi 0.8.0
use vars qw($VERSION %IRSSI);
$VERSION = "1.52";
%IRSSI = (
authors => "Matti 'qvr' Hiljanen",
contact => 'matti\@hiljanen.com',
contributors => 'stefan@pico.ruhr.de, dieck@gmx.de, peder@ifi.uio.no',
name => "dccstat",
description => "Shows verbose or short information of dcc send/gets on statusbar (speed, size, eta etc.)",
license => "GPL, Version 2",
url => "http://matin.maapallo.org/softa/irssi",
sbitems => "dccstat"
);
# Theme settings:
# sb_dccstat = "{sb $0-}";
# $0 = sb_ds_short(_waiting)/sb_ds_normal(_waiting)
# sb_ds_short = "$0%G:%n$1%Y@%n$2kB/s%G:%n$4%G:%n$3";
# $0 = G/S
# $1 = filename
# $2 = transfer speed
# $3 = percent
# $4 = progressbar
# sb_ds_short_waiting = "$0%G:%n$1 $2 $3 waiting";
# $0 = G/S
# $1 = filename
# $2 = to/from
# $3 = nick
# sb_ds_normal = "$0 $1: '$2' $3 of $4 [$8] $9 ($5) $6kB/s ETA: $7";
# $0 = GET/SEND
# $1 = nick
# $2 = filename
# $3 = transferred amount
# $4 = full filesize
# $5 = percent
# $6 = speed
# $7 = ETA
# $8 = progressbar
# $9 = rotator thingy :)
# sb_ds_normal_waiting = "$0 $1: '$2' $3 $4 $5 waiting";
# $0 = GET/SEND
# $1 = nick
# $2 = filename
# $3 = full filesize
# $4 = to/from
# $5 = nick
# sb_ds_separator = ", ";
#
# TODO:
# new ideas more than welcome :)
#
# FAQ:
# Q: my input line gets cleared every time dcc send/get starts or ends,
# why's that?!
# A: it's a bug in irssi which is already fixed in cvs (2002-03-24 Sunday 20:06)
# so the solution: upgrade to cvs or live with it and wait until the next stable release
#
use Irssi::TextUI;
use strict;
my $dccstat_refresh=5;
my ($refresh_tag, $old_refresh, $new_refresh, $displayed_since);
my $visible = -1;
my $displaying = 0;
my @rot_bar = ('|', '/', '-', '\\\\\\\\');
my $rot_bar_n = 0;
my %dccstat;
sub cmd_print_help {
Irssi::print(
"%_Dccstat.pl Help:%_\n\n".
"Statusbar called dccstat should have appeared when you loaded this script,\n".
"now you need to add the dccstat item into that statusbar:\n".
" /statusbar dccstat add dccstat\n".
" /save\n\n".
" The default verbose mode will produce output like this: \n".
" [GET nick: 'foobar.avi' 5500kB of 11MB (50%) 99kB/s ETA: 00:03:00]\n".
" and the short mode looks like this:\n".
" [G:foobar.avi\@99kB/s:(50%)]\n\n".
" %_/SETs:%_\n".
" /set dccstat_refresh <secs> (default: 5)\n".
" /set dccstat_short_mode <ON/OFF> (default: OFF)\n".
" shorter output and doesn't show DCCs: None when there are no GET/SENDs\n".
" /set dccstat_hide_sbar_when_inactive <ON/OFF> (default: OFF)\n".
" hides the statusbar called dccstat when there are no GET/SENDs\n".
" /set dccstat_auto_short_limit (default: 2)\n".
" amount of dcc sends/gets we can have before we automagically switch to short mode\n".
" (when all the info wouldn't fit to statusbar). setting it to 0 will disable it.\n".
" /set dccstat_progbar_width (default: 10)\n".
" progressbar width in chars\n".
" /set dccstat_progbar_transferred (default: '%%g=%%n')\n".
" /set dccstat_progbar_position (default: '%%y>%%n')\n".
" /set dccstat_progbar_remaining (default: '%%r-%%n')\n".
" /set dccstat_cycle_through_transfers (default: OFF)\n".
" cycle trough the transfers (ON) or show all transfers at the same time (OFF, default)\n".
" /set dccstat_cycle_through_transfers_refresh <secs> (default: 5)\n".
" how long to show one transfer at a time\n".
" /set dccstat_filename_max_length (default: 17)\n".
" /set dccstat_filename_max_length_shortmode (default: 10)\n".
" how much to show of a filename in normal and short modes\n\n".
" /set dccstat_EXPERIMENTAL_fast_refresh (default: OFF)\n".
" use very experimental and super fast refreshing, will probably consume all cpu power,\n".
" depending on your connection speed. but hey, it's fun :)\n".
" /set dccstat_debug (default: OFF)\n".
" show debug messages\n".
" \n".
"\nSee also: STATUSBAR, DCC and theme help in the actual script"
,MSGLEVEL_CRAP);
}
sub debug {
my ($text) = @_;
return unless Irssi::settings_get_bool('dccstat_debug');
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
$sec = sprintf("%02d", $sec);
$min = sprintf("%02d", $min);
$hour = sprintf("%02d", $hour);
Irssi::print("DEBUG(%_Dccstat.pl%_): ".$text." [$hour:$min:$sec]");
}
sub startup_check {
debug("START-UP - DEBUG IS ON");
my @dccs = Irssi::Irc::dccs();
my $act;
foreach my $dcc (@dccs) { $act=$dcc if $dcc->{type} eq "SEND" || $dcc->{type} eq "GET"; };
dcc_connected($act);
}
sub dcc_connected {
debug("entering dcc_connected");
my ($dcc) = @_;
return unless $dcc->{type} eq "SEND" || $dcc->{type} eq "GET";
debug("removing dcc connected -signal");
Irssi::signal_remove('dcc connected', 'dcc_connected');
my $refresh_msecs = (Irssi::settings_get_int('dccstat_refresh')*1000);
$refresh_msecs = ($dccstat_refresh*1000) if $refresh_msecs < 1000;
debug("adding normal timeout..");
$refresh_tag=Irssi::timeout_add($refresh_msecs, 'refresh_dccstat', undef);
$old_refresh=Irssi::settings_get_int('dccstat_refresh');
Irssi::signal_add_last('dcc destroyed', 'dcc_checklast');
refresh_dccstat();
}
sub dcc_setupcheck {
$new_refresh = Irssi::settings_get_int('dccstat_refresh');
if ($new_refresh != $old_refresh) {
debug("setting a new refresh timeout");
$new_refresh = ($new_refresh*1000);
Irssi::timeout_remove($refresh_tag);
$new_refresh = ($dccstat_refresh*1000) if $new_refresh < 1000;
$refresh_tag=Irssi::timeout_add($new_refresh, 'refresh_dccstat', undef);
$old_refresh=Irssi::settings_get_int('dccstat_refresh');
}
refresh_dccstat();
}
sub dcc_checklast {
my @dccs = Irssi::Irc::dccs();
my $count = dcc_getcount();
debug("check for last, count is '$count'");
return unless $count == 0;
debug("was last, removing timeout '$refresh_tag'");
Irssi::timeout_remove($refresh_tag);
Irssi::signal_remove('dcc destroyed', 'dcc_checklast');
Irssi::signal_add('dcc connected', 'dcc_connected');
refresh_dccstat();
}
# this function calculates the average speed of the last 10 seconds.
# i think that's better than irssis default way of calculating the
# average speed from the whole transfer
sub dcc_calcSpeed {
my @dccs = Irssi::Irc::dccs();
foreach my $dcc (@dccs) {
next unless $dcc->{type} eq "SEND" || $dcc->{type} eq "GET";
my $id = "$dcc->{created}" . "$dcc->{addr}" . "$dcc->{port}";
if (defined($dccstat{$id}{'speed'})) {
my $old = $dccstat{$id}{'position'};
my $current = $dcc->{transfd};
my $speed = (($current-$old)/10);
unless ($dccstat{$id}{'speed'} == "-1" && ($current-$old) == 0) {
$dccstat{$id}{'speed'} = $speed;
}
$dccstat{$id}{'position'} = $current;
} else {
# new dcc
my $id = "$dcc->{created}" . "$dcc->{addr}" . "$dcc->{port}";
debug("creating dcc hash '$id'");
$dccstat{$id}{'speed'} = "-1";
$dccstat{$id}{'position'} = "0";
}
}
# let's remove old hashes
foreach my $hash (keys %dccstat) {
my $keep = 0;
foreach my $dcc (@dccs) {
my $id = "$dcc->{created}" . "$dcc->{addr}" . "$dcc->{port}";
$keep = 1 if ($hash == $id);
}
if ($keep) {
debug("dcc '$hash' is still active, it's speed is '" . $dccstat{$hash}{'speed'} . "'");
} else {
debug("deleting dcc '$hash'");
delete $dccstat{$hash};
}
}
}
### this function originally implemented by dieck@gmx.de
sub dcc_calculateETA {
my $dcc = $_[0];
my ($dccspeed, $dccleft, $going, $dccsecs, $dcctime);
# calculate current speed
$going=(time-$dcc->{starttime});
$going=1 if $going==0;
my $id = "$dcc->{created}" . "$dcc->{addr}" . "$dcc->{port}";
if (defined($dccstat{$id})) {
$dccspeed=$dccstat{$id}{'speed'};
} else {
$dccspeed = -1;
}
## speed in bytes/sec
if ($dccspeed > 0) {
# calculate left transfer size
$dccleft = ($dcc->{size}-$dcc->{transfd});
## size left in byte
$dccspeed=1 if $dccspeed==0;
$dccsecs = $dccleft / $dccspeed;
$dcctime = sprintf("%02d:%02d:%02d", int($dccsecs/60/60), int($dccsecs/60%60), int($dccsecs%60));
} elsif ($dccspeed == "0") {
$dcctime = "stalled";
} elsif ($dccspeed == "-1") {
$dcctime = "???";
} else {
# panic!
$dcctime = "error!";
}
return $dcctime;
}
### this function originally implemented by stefan_tomanek@web.de
sub dcc_progbar {
my ($dcc) = @_;
my ($filebar, $nobar);
my $barwidth = Irssi::settings_get_int('dccstat_progbar_width');
my $char1 = Irssi::settings_get_str('dccstat_progbar_transferred');
my $char2 = Irssi::settings_get_str('dccstat_progbar_position');
my $char3 = Irssi::settings_get_str('dccstat_progbar_remaining');
if ($dcc->{size} > 0) {
my $width_per_size = ($barwidth) / $dcc->{size};
my $transf_chars = sprintf("%.0f",($width_per_size * $dcc->{transfd}));
$filebar = $char1 x $transf_chars;
$nobar = $char3 x ($barwidth - $transf_chars - 1);
return "${filebar}${char2}${nobar}";
} else {
return $barwidth x $char3;
}
}
sub dcc_calculateSIZE {
my $fsize = $_[0];
my ($size, $unit, $div);
if ($fsize >= 1024*1024*1024) { $size = $fsize/1024/1024/1024; $unit = "GB"; $div = 2; }
elsif ($fsize >= 1024*1024) { $size = $fsize/1024/1024; $unit = "MB"; $div = 2; }
elsif ($fsize >= 1024) { $size = $fsize/1024; $unit = "kB"; $div = 0; }
else { $size = $fsize; $unit = "B"; $div = 0; }
$size = sprintf("%.${div}f", $size);
return "${size}${unit}";
}
sub dcc_getcount {
my @dccs = Irssi::Irc::dccs();
my $count = 0;
foreach my $dcc (@dccs) { $count++ if $dcc->{type} eq "GET" || $dcc->{type} eq "SEND"; }
return $count;
}
sub dccstat {
#debug("going into main function");
my ($item, $get_size_only) = @_;
my @dccs=Irssi::Irc::dccs();
my (@results, $results);
my $mode = Irssi::settings_get_bool('dccstat_short_mode');
my $exp_flags = Irssi::EXPAND_FLAG_IGNORE_EMPTY | Irssi::EXPAND_FLAG_IGNORE_REPLACES;
my $theme = Irssi::current_theme();
my $format = $theme->format_expand("{sb_dccstat}");
my $count = dcc_getcount();
if ($count>0) {
my $sendcount=0;
my $getcount=0;
my (
$dccpercent, $dccspeed, $dcctype, $going,
$dccnick, $dccfile, $FooOfBar, $str,
$fsize, $transize, $dcceta, $from,
$to, $direction, $prep, $autolimit,
$separator, $dccprogbar, $dccrotbar
);
foreach my $dcc (@dccs) {
next unless $dcc->{type} eq "SEND" || $dcc->{type} eq "GET";
# if count is above the autolimit, we'll force the mode to short
# but not if we're cycling through transfers.
if (not Irssi::settings_get_bool('dccstat_cycle_through_transfers')) {
$autolimit=Irssi::settings_get_int('dccstat_auto_short_limit');
$mode=1 if $count > $autolimit && $autolimit > 0;
}
$sendcount++ if $dcc->{type} eq "SEND";
$getcount++ if $dcc->{type} eq "GET";
$dccpercent = ($dcc->{size} == 0) ? "(0%)" : sprintf("%.1f", $dcc->{transfd}/$dcc->{size}*100)."%%";
$going = (time-$dcc->{starttime});
$going = 1 if $going==0;
my $id = "$dcc->{created}" . "$dcc->{addr}" . "$dcc->{port}";
if (defined($dccstat{$id})) {
$dccspeed = $dccstat{$id}{'speed'};
} else {
$dccspeed = -1;
}
if ($dccspeed >= 0) {
$dccspeed = sprintf("%.2f", ($dccspeed/1024));
} else {
$dccspeed = sprintf("%.2f", ($dcc->{transfd}-$dcc->{skipped})/$going/1024);
}
$dcctype = $dcc->{type};
$dccnick = $dcc->{nick};
$dccnick =~ s/\\/\\\\/g;
$dccfile = $dcc->{arg};
$dccfile =~ s/ /\240/g;
$dccfile =~ s/\\/\\\\/g;
# if filename is longer than 17 chars, we'll show only the first 15 chars
# and in short mode we'll show only 8 chars
# (lengths are now configurable, but the idea is the same)
my $max_normal = Irssi::settings_get_int('dccstat_filename_max_length');
my $max_short = Irssi::settings_get_int('dccstat_filename_max_length_shortmode');
if (!$mode) {
$dccfile=substr($dccfile, 0, $max_normal-2).".." if (length($dccfile) > $max_normal);
} else {
$dccfile=substr($dccfile, 0, $max_short-2).".." if (length($dccfile) > $max_short);
}
$fsize = dcc_calculateSIZE($dcc->{size});
$transize = dcc_calculateSIZE($dcc->{transfd});
$dccprogbar = dcc_progbar($dcc);
$dccprogbar =~ s/ /\240/g;
$dcceta = dcc_calculateETA($dcc);
if ($dcctype eq "GET") { $direction = "G"; $prep = "from"; }
if ($dcctype eq "SEND") { $direction = "S"; $prep = "to"; }
$dccrotbar = $rot_bar[$rot_bar_n];
# short mode?
if ($mode) {
# theme?
if ($format) {
if ($dcc->{starttime} > 0) {
$str = $theme->format_expand("{sb_ds_short $direction $dccfile $dccspeed $dccpercent $dccprogbar $dccrotbar}", $exp_flags);
} else {
$str = $theme->format_expand("{sb_ds_short_waiting $direction $dccfile $prep $dccnick}", $exp_flags);
}
} else {
$str = "$direction%G:%n$dccfile";
$str .= ($dcc->{starttime} > 0) ? "%G@%n${dccspeed}kB/s%G:%n$dccprogbar%G:%n$dccrotbar%G:%n$dccpercent" : " $prep $dccnick waiting";
}
} else {
if ($format) {
if ($dcc->{starttime} > 0) {
$str = $theme->format_expand("{sb_ds_normal $dcctype $dccnick $dccfile $transize $fsize $dccpercent $dccspeed $dcceta $dccprogbar $dccrotbar}", $exp_flags);
} else {
$str = $theme->format_expand("{sb_ds_normal_waiting $dcctype $dccnick $dccfile $fsize $prep $dccnick}", $exp_flags);
}
} else {
$str = "$dcctype $dccnick: '$dccfile'";
$str .= ($dcc->{starttime} > 0) ? " $transize of $fsize [$dccprogbar] $dccrotbar ($dccpercent) ${dccspeed}kB/s ETA: $dcceta" : " $fsize $prep $dccnick waiting";
}
}
push @results,$str;
}
if (not Irssi::settings_get_bool('dccstat_cycle_through_transfers')) {
$separator = ($theme->format_expand("{sb_ds_separator}")) ? $theme->format_expand("{sb_ds_separator}") : ", ";
$results = join("$separator", @results);
} else {
if (scalar(@results)-1 < $displaying) { $displaying = 0 };
$results = @results[$displaying];
if (not $get_size_only) {
if ((time-$displayed_since) >= (Irssi::settings_get_int('dccstat_cycle_through_transfers_refresh'))) {
debug("refreshing cycle display");
$displaying++;
$displayed_since = time;
}
}
}
} else {
$results="%_DCCs:%_ None" if !$mode;
}
if ($format) {
if ($count > 0) {
$results = "{sb_dccstat $results}"
} else {
$results = "{sb_dccstat $results}" unless $mode;
}
} else {
if ($count > 0) {
$results = "{sb $results}";
} else {
$results = "{sb $results}" unless $mode;
}
}
$item->default_handler($get_size_only, "$results", undef, 1);
}
sub refresh_dccstat {
#debug("refreshing item");
my $hide = Irssi::settings_get_bool('dccstat_hide_sbar_when_inactive');
my $count = dcc_getcount();
if ($hide && $count == 0) {
if ($visible == -1 || $visible == 1) {
Irssi::command("statusbar dccstat disable");
debug("disabling statusbar");
$visible = 0;
}
return;
}
if ($visible == 0 || $visible == -1) {
Irssi::command("statusbar dccstat enable");
debug("enabling statusbar");
$visible = 1;
}
Irssi::statusbar_items_redraw('dccstat');
$rot_bar_n++;
$rot_bar_n %= @rot_bar;
}
my $fref = 0;
sub dcc_fast_refresh {
if (Irssi::settings_get_bool('dccstat_EXPERIMENTAL_fast_refresh'))
{
refresh_dccstat();
$fref++;
debug("transfer updated! ($fref)");
}
}
Irssi::settings_add_int($IRSSI{'name'}, "dccstat_refresh", $dccstat_refresh);
Irssi::settings_add_bool($IRSSI{'name'}, 'dccstat_short_mode', 0);
Irssi::settings_add_bool($IRSSI{'name'}, 'dccstat_hide_sbar_when_inactive', 0);
Irssi::settings_add_int($IRSSI{'name'}, 'dccstat_auto_short_limit', 2);
Irssi::settings_add_int($IRSSI{'name'}, 'dccstat_progbar_width', 10);
Irssi::settings_add_str($IRSSI{'name'}, 'dccstat_progbar_transferred', '%g=%n');
Irssi::settings_add_str($IRSSI{'name'}, 'dccstat_progbar_position', '%y>%n');
Irssi::settings_add_str($IRSSI{'name'}, 'dccstat_progbar_remaining', '%r-%n');
Irssi::settings_add_bool($IRSSI{'name'}, 'dccstat_cycle_through_transfers', 0);
Irssi::settings_add_int($IRSSI{'name'}, 'dccstat_cycle_through_transfers_refresh', 10);
Irssi::settings_add_bool($IRSSI{'name'}, 'dccstat_EXPERIMENTAL_fast_refresh', 0);
Irssi::settings_add_bool($IRSSI{'name'}, 'dccstat_debug', 0);
Irssi::settings_add_int($IRSSI{'name'}, 'dccstat_filename_max_length', 17);
Irssi::settings_add_int($IRSSI{'name'}, 'dccstat_filename_max_length_shortmode', 10);
Irssi::command_bind('dccstat', 'cmd_print_help');
Irssi::statusbar_item_register('dccstat', undef, 'dccstat');
Irssi::timeout_add('10000', 'dcc_calcSpeed', undef);
Irssi::signal_add('dcc connected', 'dcc_connected');
Irssi::signal_add(
{
'setup changed' => \&dcc_setupcheck,
'dcc request' => \&refresh_dccstat,
'dcc created' => \&refresh_dccstat,
'dcc destroyed' => \&refresh_dccstat,
'dcc transfer update' => \&dcc_fast_refresh,
}
);
# Startup
startup_check();
refresh_dccstat();
# lets save some global variables
$old_refresh = Irssi::settings_get_int('dccstat_refresh');
Irssi::print("Dccstat.pl loaded - /dccstat for help");
# EOF

View File

@@ -0,0 +1,53 @@
# /script load hilight-better.pl
use Irssi::Irc;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '1.02';
%IRSSI = (
authors => '',
contact => '',
name => 'hilight-better',
description => 'Highlight your nick mid-sentence without resorting
to /hilight',
license => 'GPLv3',
url => '',
changed => 'Thu Dec 6 03:15 EST 2012',
);
sub hilight_nick {
my ($dest, $text, $stripped) = @_;
my $server = $dest->{server};
my $nick = $server->{nick};
my $color = Irssi::settings_get_str("hilight_color");
# default attempts to use format message though this is broken
# by nickcolors if you use nick colours I recommend switching
# method to msg and doing /set hilight_nick_matches OFF
my $method = "msg";
if ($dest->{server} && $dest->{level} &
(MSGLEVEL_PUBLIC|MSGLEVEL_MSGS|MSGLEVEL_ACTIONS)) {
# return if you are the source of a msg/public or action
return if ($stripped =~ /<.$nick>/ || $stripped =~ /\* $nick/);
if ($text =~ /$nick/i) {
if ($method eq "default") {
$server->command('/^format pubmsg '.
'{pubmsgnick $2 {pubnick '.chr(3).$color.'$0}}$1');
$dest->{window}->print($text,
MSGLEVEL_PUBLIC+MSGLEVEL_HILIGHT) if($dest->{window});
$server->command('/^format -reset pubmsg');
}
else {
$text =~ s/($nick)/$color$1%n%N/gi;
$dest->{window}->print($text,
MSGLEVEL_PUBLIC+MSGLEVEL_HILIGHT) if($dest->{window});
}
Irssi::signal_stop();
}
}
}
# Signals
#printtext.c:
#"print text", TEXT_DEST_REC *dest, char *text, char *stripped
Irssi::signal_add('print text', 'hilight_nick');

View File

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

@@ -0,0 +1,177 @@
#!/usr/bin/perl -w
# USAGE:
#
# /RSAY <text>
# - same as /say, but outputs a coloured text
#
# /RME <text>
# - same as /me, but outputs a coloured text
#
# /RTOPIC <text>
# - same as /topic, but outputs a coloured text :)
#
# /RKICK <nick> [reason]
# - kicks nick from the current channel with coloured reason
# Written by Jakub Jankowski <shasta@atn.pl>
# for Irssi 0.7.98.4 and newer
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = "1.4";
%IRSSI = (
authors => 'Jakub Jankowski',
contact => 'shasta@atn.pl',
name => 'rainbow',
description => 'Prints colored text. Rather simple than sophisticated.',
license => 'GNU GPLv2 or later',
url => 'http://irssi.atn.pl/',
);
use Irssi;
use Irssi::Irc;
# colors list
# 0 == white
# 4 == light red
# 8 == yellow
# 9 == light green
# 11 == light cyan
# 12 == light blue
# 13 == light magenta
# my @colors = ('0', '4', '8', '9', '11', '12', '13');
# my @colors = ('2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13');
my @colors = ('4', '8', '9', '11', '12', '13');
# str make_colors($string)
# returns random-coloured string
sub make_colors_rand {
my ($string) = @_;
my $newstr = "";
my $last = 255;
my $color = 0;
for (my $c = 0; $c < length($string); $c++) {
my $char = substr($string, $c, 1);
if ($char eq ' ') {
$newstr .= $char;
next;
}
while (($color = int(rand(scalar(@colors)))) == $last) {};
$last = $color;
$newstr .= "\003";
$newstr .= sprintf("%02d", $colors[$color]);
$newstr .= (($char eq ",") ? ",," : $char);
}
return $newstr;
}
# str make_colors($string)
# returns random-coloured string
my $last_color = 0;
sub make_colors {
my ($string) = @_;
my $newstr = "";
my $last = $last_color;
my $color = 0;
my $colorrep = 2;
for (my $c = 0; $c < length($string); $c++) {
my $char = substr($string, $c, 1);
#if ($char eq ' ') {
# $newstr .= $char;
# next;
#}
$last++;
$color = ($last / $colorrep) % scalar(@colors);
$newstr .= "\003";
$newstr .= sprintf("%02d", $colors[$color]);
$newstr .= (($char eq ",") ? "\," : $char);
}
$last_color += 2;#rotate $last;
return $newstr;
}
# void rsay($text, $server, $destination)
# handles /rsay
sub rsay {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
return unless $dest;
if ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY") {
$dest->command("/msg " . $dest->{name} . " " . make_colors($text));
}
}
# void rme($text, $server, $destination)
# handles /rme
sub rme {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
if ($dest && ($dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY")) {
$dest->command("/me " . make_colors($text));
}
}
# void rtopic($text, $server, $destination)
# handles /rtopic
sub rtopic {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
if ($dest && $dest->{type} eq "CHANNEL") {
$dest->command("/topic " . make_colors($text));
}
}
# void rkick($text, $server, $destination)
# handles /rkick
sub rkick {
my ($text, $server, $dest) = @_;
if (!$server || !$server->{connected}) {
Irssi::print("Not connected to server");
return;
}
if ($dest && $dest->{type} eq "CHANNEL") {
my ($nick, $reason) = split(/ +/, $text, 2);
return unless $nick;
$reason = "Irssi power!" if ($reason =~ /^[\ ]*$/);
$dest->command("/kick " . $nick . " " . make_colors($reason));
}
}
Irssi::command_bind("rsay", "rsay");
Irssi::command_bind("rtopic", "rtopic");
Irssi::command_bind("rme", "rme");
Irssi::command_bind("rkick", "rkick");
# changes:
#
# 25.01.2002: Initial release (v1.0)
# 26.01.2002: /rtopic added (v1.1)
# 29.01.2002: /rsay works with dcc chats now (v1.2)
# 02.02.2002: make_colors() doesn't assign any color to spaces (v1.3)
# 23.02.2002: /rkick added