parrot.pl
This commit is contained in:
parent
46c135b05e
commit
0957a2bd87
@ -55,6 +55,7 @@ sub sendto
|
|||||||
sub add_relay
|
sub add_relay
|
||||||
{
|
{
|
||||||
my ($groupname, $server, $channel, $flags) = @_;
|
my ($groupname, $server, $channel, $flags) = @_;
|
||||||
|
return if exists $cbs{$server};
|
||||||
push @{ $chans{$server}{$channel} }, $groupname;
|
push @{ $chans{$server}{$channel} }, $groupname;
|
||||||
$groups{$groupname}{$server}{$channel} = $flags;
|
$groups{$groupname}{$server}{$channel} = $flags;
|
||||||
$cbs{$server}{PRIVMSG} =
|
$cbs{$server}{PRIVMSG} =
|
||||||
@ -126,7 +127,7 @@ sub irc_privmsg_notice
|
|||||||
sendto($to_serv, "/msg $to_chan * \x02$nick\x0f $message");
|
sendto($to_serv, "/msg $to_chan * \x02$nick\x0f $message");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
my $prefix = $cmd eq 'notice' ? "[\x02$nick\x0f]" : "<\x02$nick\x0f>";
|
my $prefix = lc $cmd eq 'notice' ? "[\x02$nick\x0f]" : "<\x02$nick\x0f>";
|
||||||
sendto($to_serv, "/msg $to_chan $prefix $message");
|
sendto($to_serv, "/msg $to_chan $prefix $message");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +146,7 @@ sub ircout_privmsg_notice
|
|||||||
my ($to_serv, $to_chan, $flags, undef) = @$_;
|
my ($to_serv, $to_chan, $flags, undef) = @$_;
|
||||||
next if $flags & $READ;
|
next if $flags & $READ;
|
||||||
next unless weechat::buffer_search('irc', "$to_serv.$to_chan");
|
next unless weechat::buffer_search('irc', "$to_serv.$to_chan");
|
||||||
my $prefix = $cmd eq 'notice' ? 'notice' : 'msg';
|
my $prefix = lc $cmd eq 'notice' ? 'notice' : 'msg';
|
||||||
if ($message =~ /^\x01ACTION /i) {
|
if ($message =~ /^\x01ACTION /i) {
|
||||||
$message =~ s/^\x01ACTION |\x01$//g;
|
$message =~ s/^\x01ACTION |\x01$//g;
|
||||||
sendto($to_serv, "/$prefix $to_chan \x01ACTION $message\x01");
|
sendto($to_serv, "/$prefix $to_chan \x01ACTION $message\x01");
|
||||||
@ -223,7 +224,6 @@ sub irc_nick
|
|||||||
for my $channel (keys %{ $chans{$server} }) {
|
for my $channel (keys %{ $chans{$server} }) {
|
||||||
my $iptr = weechat::infolist_get('irc_nick', '', "$server,$channel,$nick");
|
my $iptr = weechat::infolist_get('irc_nick', '', "$server,$channel,$nick");
|
||||||
next unless $iptr;
|
next unless $iptr;
|
||||||
weechat::print('',$iptr);
|
|
||||||
weechat::infolist_free($iptr);
|
weechat::infolist_free($iptr);
|
||||||
for (getgroup($server, $channel)) {
|
for (getgroup($server, $channel)) {
|
||||||
my ($to_serv, $to_chan, $flags, undef) = @$_;
|
my ($to_serv, $to_chan, $flags, undef) = @$_;
|
||||||
@ -243,6 +243,10 @@ sub irc_quit
|
|||||||
shift =~ /:([^! ]*)[^ ]* quit :?(.*)/i);
|
shift =~ /:([^! ]*)[^ ]* quit :?(.*)/i);
|
||||||
|
|
||||||
for my $channel (keys %{ $chans{$server} }) {
|
for my $channel (keys %{ $chans{$server} }) {
|
||||||
|
my $iptr = weechat::infolist_get('irc_nick', '', "$server,$channel,$nick");
|
||||||
|
next unless $iptr;
|
||||||
|
weechat::print('',$iptr);
|
||||||
|
weechat::infolist_free($iptr);
|
||||||
for (getgroup($server, $channel)) {
|
for (getgroup($server, $channel)) {
|
||||||
my ($to_serv, $to_chan, $flags, undef) = @$_;
|
my ($to_serv, $to_chan, $flags, undef) = @$_;
|
||||||
next unless $flags & $STAT;
|
next unless $flags & $STAT;
|
||||||
@ -347,9 +351,18 @@ sub cmd_parrot
|
|||||||
return weechat::WEECHAT_RC_OK;
|
return weechat::WEECHAT_RC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub completion_groupnames
|
||||||
|
{
|
||||||
|
my $completion = pop;
|
||||||
|
weechat::hook_completion_list_add($completion, $_, 0,
|
||||||
|
weechat::WEECHAT_LIST_POS_SORT) for keys %groups;
|
||||||
|
}
|
||||||
|
|
||||||
if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
|
if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
|
||||||
$SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
|
$SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
|
||||||
$confpath = weechat::info_get('weechat_dir', '') . '/parrot.db';
|
$confpath = weechat::info_get('weechat_dir', '') . '/parrot.db';
|
||||||
|
weechat::hook_completion('perl_parrot_groupname', 'parrot.pl group names',
|
||||||
|
'completion_groupnames', '');
|
||||||
weechat::hook_command('parrot', $SCRIPT_DESC,
|
weechat::hook_command('parrot', $SCRIPT_DESC,
|
||||||
"[-read] [-stat] [-mode] groupname\n".
|
"[-read] [-stat] [-mode] groupname\n".
|
||||||
"-remove",
|
"-remove",
|
||||||
@ -359,6 +372,8 @@ if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
|
|||||||
"-mode: transfer modes to this channel, even if you are op".
|
"-mode: transfer modes to this channel, even if you are op".
|
||||||
"groupname: all channels with the same group name are relayed together\n".
|
"groupname: all channels with the same group name are relayed together\n".
|
||||||
"-remove: remove this channel from the relay group",
|
"-remove: remove this channel from the relay group",
|
||||||
'', 'cmd_parrot', '');
|
'-remove %(perl_parrot_groupname) %-'.
|
||||||
|
'||-read|-stat|-mode|%(perl_parrot_groupname)|%*',
|
||||||
|
'cmd_parrot', '');
|
||||||
read_conf();
|
read_conf();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user