parrot.pl

This commit is contained in:
wowaname 2017-02-02 07:09:15 +00:00
parent 46c135b05e
commit 0957a2bd87
1 changed files with 19 additions and 4 deletions

View File

@ -55,6 +55,7 @@ sub sendto
sub add_relay
{
my ($groupname, $server, $channel, $flags) = @_;
return if exists $cbs{$server};
push @{ $chans{$server}{$channel} }, $groupname;
$groups{$groupname}{$server}{$channel} = $flags;
$cbs{$server}{PRIVMSG} =
@ -126,7 +127,7 @@ sub irc_privmsg_notice
sendto($to_serv, "/msg $to_chan * \x02$nick\x0f $message");
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");
}
@ -145,7 +146,7 @@ sub ircout_privmsg_notice
my ($to_serv, $to_chan, $flags, undef) = @$_;
next if $flags & $READ;
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) {
$message =~ s/^\x01ACTION |\x01$//g;
sendto($to_serv, "/$prefix $to_chan \x01ACTION $message\x01");
@ -223,7 +224,6 @@ sub irc_nick
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)) {
my ($to_serv, $to_chan, $flags, undef) = @$_;
@ -243,6 +243,10 @@ sub irc_quit
shift =~ /:([^! ]*)[^ ]* quit :?(.*)/i);
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)) {
my ($to_serv, $to_chan, $flags, undef) = @$_;
next unless $flags & $STAT;
@ -347,9 +351,18 @@ sub cmd_parrot
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,
$SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
$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,
"[-read] [-stat] [-mode] groupname\n".
"-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".
"groupname: all channels with the same group name are relayed together\n".
"-remove: remove this channel from the relay group",
'', 'cmd_parrot', '');
'-remove %(perl_parrot_groupname) %-'.
'||-read|-stat|-mode|%(perl_parrot_groupname)|%*',
'cmd_parrot', '');
read_conf();
}