-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaescript.pl
273 lines (252 loc) · 8.62 KB
/
caescript.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
use Irssi;
use strict;
use vars qw($VERSION %IRSSI);
$VERSION = '1.00';
%IRSSI = (
authors => 'CaeSpock',
contact => 'cae@CaeSpock.org',
name => 'CaeScript',
description => 'Simple set of aliases and commands' .
'Not everything is mine, but i made it possible:P',
license => 'Public Domain',
url => 'http://www.caespock.org/ircsoftware/',
changed => 'Web Feb 13 00:05 BOT 2014',
);
Irssi::theme_register([
'caescript_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.'
]);
Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'caescript_loaded', $IRSSI{name}, $VERSION, $IRSSI{authors});
# Some needed stuff
Irssi::command("^SET use_status_window OFF");
#
# Services stuff
#
Irssi::command_bind('nickserv', 'cmd_nickserv');
sub cmd_nickserv {
my ($data, $server, $channel) = @_;
if ($data) {
$server->send_raw("nickserv $data");
} else {
Irssi::active_win()->print("NickServ: Command not given, we can\'t send an empty request");
}
}
Irssi::command_bind('chanserv', 'cmd_chanserv');
sub cmd_chanserv {
my ($data, $server, $channel) = @_;
if ($data) {
$server->send_raw("chanserv $data");
} else {
Irssi::active_win()->print("ChanServ: Command not given, we can\'t send an empty request");
}
}
Irssi::command_bind('memoserv', 'cmd_memoserv');
sub cmd_memoserv {
my ($data, $server, $channel) = @_;
if ($data) {
$server->send_raw("memoserv $data");
} else {
Irssi::active_win()->print("MemoServ: Command not given, we can\'t send an empty request");
}
}
Irssi::command_bind('helpserv', 'cmd_helpserv');
sub cmd_helpserv {
my ($data, $server, $channel) = @_;
if ($data) {
$server->send_raw("privmsg helpserv :$data");
} else {
Irssi::active_win()->print("HelpServ: Command not given, we can\'t send an empty request");
}
}
# Whois everyone that sends a query to me
Irssi::signal_add_last('query created', 'sig_query');
sub sig_query() {
my ($query, $auto) = @_;
# don't say anything if we did /query,
# or if query went to active window
my $refnum = $query->window()->{refnum};
my $window = Irssi::active_win();
if ($auto && $refnum != $window->{refnum}) {
$window->print("Query started with ".$query->{name}." in window $refnum");
$query->{server}->command("whois ".$query->{name});
}
}
# This part shows notices into the active channel unless it has its own window.
Irssi::signal_add('print text', 'notice_move');
sub notice_move {
my ($dest, $text, $stripped) = @_;
my $server = $dest->{server};
return if (!$server || !($dest->{level} & MSGLEVEL_NOTICES) || $server->ischannel($dest->{target}));
my $witem = $server->window_item_find($dest->{target});
my $awin = Irssi::active_win();
return if $witem;
$awin->print($text, MSGLEVEL_NOTICES);
Irssi::signal_stop();
}
# This will tell you how many IRCops are in the channel
Irssi::command_bind('ircops', 'cmd_ircops');
sub cmd_ircops {
my ($data, $server, $channel) = @_;
my (@list,$text,$num);
if (!$channel || $channel->{type} ne 'CHANNEL') {
Irssi::print('No active channel in window');
return;
}
foreach my $nick ($channel->nicks()) {
if ($nick->{serverop}) {
push(@list,$nick->{nick});
}
}
$num = scalar @list;
if ($num == 0) {
$text = "no IrcOps on this channel";
} else {
$text = "IrcOps (".$num."): ".join(" ",@list);
}
$channel->print($text);
}
# This will help detect and count clones in a channel
Irssi::command_bind('clones', 'cmd_clones');
Irssi::settings_add_bool('misc', 'clones_host_only', 1);
Irssi::settings_add_int('misc', 'clones_min_show', 2);
sub cmd_clones {
my ($data, $server, $channel) = @_;
my $min = $data =~ /\d/ ? $data : Irssi::settings_get_int('clones_min_show');
if (!$channel || $channel->{type} ne 'CHANNEL') {
Irssi::print('No active channel in window');
return;
}
my %hostnames = {};
my $ident = Irssi::settings_get_bool('clones_host_only');
foreach my $nick ($channel->nicks()) {
my $hostname;
if($ident) {
($hostname = $nick->{host}) =~ s/^[^@]+@//;
}else{
$hostname = $nick->{host};
}
$hostnames{$hostname} ||= [];
push( @{ $hostnames{$hostname} }, $nick->{nick});
}
my $count = 0;
foreach my $host (keys %hostnames) {
next unless ref($hostnames{$host}) eq 'ARRAY'; # sometimes a hash is here
my @clones = @{ $hostnames{$host} };
if (scalar @clones >= $min) {
$channel->print('Clones:') if ($count == 0);
$channel->print("$host: " . join(' ',@clones));
$count++;
}
}
$channel->print('No clones in channel') if ($count == 0);
}
# Additional aliases
Irssi::command_bind('byeall', 'cmd_byeall');
sub cmd_byeall {
my ($data, $server, $witem) = @_;
if ($witem && ($witem->{type} eq "CHANNEL" ||
$witem->{type} eq "QUERY")) {
# there's query/channel active in window
$witem->command("MSG ".$witem->{name}." Bye to everybody!");
}
}
Irssi::command_bind('beer', 'cmd_beer');
sub cmd_beer {
my ($data, $server, $witem) = @_;
if ($witem && ($witem->{type} eq "CHANNEL" ||
$witem->{type} eq "QUERY")) {
# there's query/channel active in window
$witem->command("me invites a fine cold Bolivian beer to ".$witem->{name});
}
}
Irssi::command_bind('cinta', 'cmd_cinta');
sub cmd_cinta {
my ($data, $server, $witem) = @_;
if ($witem && ($witem->{type} eq "CHANNEL" ||
$witem->{type} eq "QUERY")) {
# there's query/channel active in window
$witem->command("msg ".$witem->{name}." 1,1 1,2 1,3 1,4 1,5 1,6 1,7 1,8 1,9 1,10 1,11 1,12 1,13 1,14 1,15 1,17 1,18 8,1 $data1,1 1,2 1,3 1,4 1,5 1,6 1,7 1,8 1,9 1,10 1,11 1,12 1,13 1,14 1,15 1,17 1,18 1,19");
}
}
Irssi::command_bind('csopme', 'cmd_csopme');
sub cmd_csopme {
my ($data, $server, $witem) = @_;
$witem->command("chanserv op ".$witem->{name}." ".$server->{nick});
}
Irssi::command_bind('hora', 'cmd_hora');
Irssi::command_bind('date', 'cmd_hora');
Irssi::command_bind('time', 'cmd_hora');
sub cmd_hora {
my ($data, $server, $witem) = @_;
my $output = `date`;
if ($witem && ($witem->{type} eq "CHANNEL" ||
$witem->{type} eq "QUERY")) {
# there's query/channel active in window
$witem->command("msg ".$witem->{name}." Current Date Time: $output");
}
}
Irssi::command_bind('o', 'cmd_o');
sub cmd_o {
my ($data, $server, $witem) = @_;
if ($witem && $witem->{type} eq "CHANNEL") {
$witem->command("mode ".$witem->{name}." +o $data");
}
}
Irssi::command_bind('ops', 'cmd_onotice');
Irssi::command_bind('onotice', 'cmd_onotice');
Irssi::command_bind('opnotice', 'cmd_onotice');
sub cmd_onotice {
my ($data, $server, $witem) = @_;
if ($witem && $witem->{type} eq "CHANNEL") {
$witem->command("notice @".$witem->{name}." [Ops] $data");
# Irssi::active_win()->print("-> [Ops] $data");
}
}
Irssi::command_bind('opsv', 'cmd_ovnotice');
Irssi::command_bind('opv', 'cmd_ovnotice');
Irssi::command_bind('opvnotice', 'cmd_ovnotice');
sub cmd_ovnotice {
my ($data, $server, $witem) = @_;
if ($witem && $witem->{type} eq "CHANNEL") {
$witem->command("notice "."@"."+".$witem->{name}." [OpsV] $data");
# Irssi::active_win()->print("-> [OpsV] $data");
}
}
Irssi::command_bind('so', 'cmd_so');
sub cmd_so {
my ($data, $server, $witem) = @_;
if ($witem && $witem->{type} eq "CHANNEL") {
$witem->command("mode ".$witem->{name}." -o $data");
}
}
Irssi::command_bind('sv', 'cmd_sv');
sub cmd_sv {
my ($data, $server, $witem) = @_;
if ($witem && $witem->{type} eq "CHANNEL") {
$witem->command("mode ".$witem->{name}." -v $data");
}
}
Irssi::command_bind('v', 'cmd_v');
sub cmd_v {
my ($data, $server, $witem) = @_;
if ($witem && $witem->{type} eq "CHANNEL") {
$witem->command("mode ".$witem->{name}." +v $data");
}
}
Irssi::command_bind('ver', 'cmd_ver');
sub cmd_ver {
my ($data, $server, $witem) = @_;
if ($witem && ($witem->{type} eq "CHANNEL" ||
$witem->{type} eq "QUERY")) {
# there's query/channel active in window
$witem->command("msg ".$witem->{name}." I'm ussing Irssi powered by ".$IRSSI{name}." v.".$VERSION." by ".$IRSSI{authors}.".");
Irssi::signal_stop();
}
}
# In case we oper, lets load IRCopTools
Irssi::signal_add('event 381', 'load_ircoptools');
sub load_ircoptools {
my ($server, $data, $server_name) = @_;
my $nick = Irssi::active_server()->{'nick'};
Irssi::command("script load ircoptools.pl");
$server->send_raw("mode $nick +aAb");
}