Advertising
- Unnamed
- Saturday, March 31st, 2007 at 10:06:31pm UTC
- # bleh stuff
- use Irssi;
- use Irssi::Irc;
- use strict;
- # 0.05 -- Add IPv6 support
- $VERSION = q$Revision: 1.1 $;
- %IRSSI = (authors => 'Don Armstrong',
- name => 'auto_bleh',
- description => 'Provides /ak /aq /ab /abr /abrn /arn /amb /amr /at',
- license => 'GPL',
- changed => q$Id: auto_bleh.pl,v 1.1 2005/03/17 08:19:53 don Exp $,
- );
- my ($actions, %defaults);
- %defaults = (GET_OP => 1, # Should we try to get opped when we auto_bleh?
- USE_CHANSERV => 1, # Should we use chanserv to get opped?
- EXPIRE => 6000, # Do not try to do anything if the action is more than 6000 seconds old.
- DEOP => 1, # Automatically deop after we've done whatever we were supposed to do.
- TIMEOUT => 10, # Timeout /at bans after 10 minutes
- );
- my %command_bindings = (ak => 'cmd_ak',
- ab => 'cmd_ab',
- aq => 'cmd_aq',
- ar => 'cmd_ar',
- abr => 'cmd_abr',
- abk => 'cmd_abk',
- abrn => 'cmd_abrn',
- abk => 'cmd_abkn',
- arn => 'cmd_arn',
- amb => 'cmd_amb',
- amr => 'cmd_amr',
- at => 'cmd_at',
- );
- my %bans_to_remove;
- sub cmd_at {
- my ($data, $server, $witem) = @_;
- }
- sub cmd_ak {
- my ($data, $server, $witem) = @_;
- }
- sub cmd_abk {
- my ($data, $server, $witem) = @_;
- }
- sub cmd_abkn {
- my ($data, $server, $witem) = @_;
- }
- sub cmd_amb{
- my ($data, $server, $witem) = @_;
- for (@nicks) {
- next unless /\w/;
- do_auto_bleh('ban',$_,$server,$witem);
- }
- }
- sub cmd_ab {
- my ($data, $server, $witem) = @_;
- }
- sub cmd_aq {
- my ($data, $server, $witem) = @_;
- }
- sub cmd_amr{
- my ($data, $server, $witem) = @_;
- for (@nicks) {
- next unless /\w/;
- do_auto_bleh('remove',$_,$server,$witem);
- }
- }
- sub cmd_ar {
- my ($data, $server, $witem) = @_;
- }
- sub cmd_abr{
- my ($data, $server, $witem) =@_;
- }
- sub cmd_abrn{
- my ($data, $server, $witem) =@_;
- }
- sub cmd_arn{
- my ($data, $server, $witem) =@_;
- }
- sub do_auto_bleh {
- my ($cmd, $data, $server, $witem, $duration) = @_;
- if (!$server || !$server->{connected}) {
- }
- if ($witem->{type} ne 'CHANNEL') {
- }
- # use Data::Dumper;
- # Irssi::print(Dumper($data,$server,$witem));
- # set the network that we're on, the channel and the nick to kick
- # once we've been opped
- # Heh. Looks like $data needs to be sanitized a bit.
- my $nick = $1;
- my $timeout = $2;
- my $reason = $3;
- my $nick_rec = $witem->nick_find($nick);
- }
- $hostname =~ s/.+\@//;
- my $action = {type => $cmd,
- nick => $nick,
- nick_rec => $nick_rec,
- network => $witem->{server}->{chatnet},
- server => $witem->{server},
- completed => 0,
- inserted => time,
- channel => $witem->{name},
- reason => $reason,
- hostname => $hostname,
- timeout => $timeout,
- };
- if ($witem->{chanop}) { # we seem to be opped.
- take_action($action,$server,$witem);
- }
- else {
- $actions->{$data.$action->{inserted}}=$action;
- get_op($server, $action->{channel}) if $defaults{GET_OP};
- }
- }
- sub get_op {
- my ($server,$channel) = @_;
- $server->command("MSG chanserv op $channel") if $defaults{USE_CHANSERV};
- }
- sub i_want {
- return "I've wanted to $action->{type} $action->{nick} off $action->{channel} on $action->{network} since $action->{inserted}";
- }
- sub take_action {
- my ($action,$server,$channel) = @_;
- # Now support multiple actions against a single nick (to FE, kick
- # ban, or remove ban). See /abr foo
- if (/timeout/) {
- Irssi::print("Quieting $action->{nick} on $action->{channel} with hostname $action->{hostname} for $action->{timeout} minutes");
- $channel->command("/quote MODE $action->{channel} +q *!*@".$action->{hostname}) if $action->{hostname} ne ''; #quiet hostname
- $bans_to_remove{"$action->{nick}$action->{inserted}"} = $action;
- }
- if (/quiet/) {
- Irssi::print("Quieting $action->{nick} on $action->{channel} with hostname $action->{hostname}") if $DEBUG;
- # Find hostname
- $channel->command("/quote MODE $action->{channel} +q *!*@".$action->{hostname}) if $action->{hostname} ne ''; #quiet hostname
- }
- if (/ban/) {
- Irssi::print("Banning $action->{nick} from $action->{channel} with hostname $action->{hostname}") if $DEBUG;
- $channel->command("/quote MODE $action->{channel} +b *!*@".$action->{hostname}) if $action->{hostname} ne ''; # ban hostname
- }
- if (/kick/) {
- $channel->command("/quote KICK $action->{channel} $action->{nick} :$action->{reason}");
- }
- else {
- $channel->command("/quote REMOVE $action->{channel} $action->{nick} $action->{reason}");
- }
- }
- if (/remove/) {
- $channel->command("/quote REMOVE $action->{channel} $action->{nick} :$action->{reason}");
- }
- else {
- $channel->command("/quote REMOVE $action->{channel} $action->{nick} $action->{reason}");
- }
- }
- if (/notice/) {
- $channel->command("/NOTICE $action->{nick} $action->{reason}");
- }
- # unquiet. This is crap, and needs to be changed to something sane.
- if (/teiuq/) {
- Irssi::print("Unquieting $action->{nick} on $action->{channel} with hostname $action->{hostname}") if $DEBUG;
- $channel->command("/quote MODE $action->{channel} -q *!*@".$action->{hostname});
- }
- return; #for now.
- }
- sub deop_us {
- my ($rec) = @_;
- my $channel = $rec->{channel};
- my $server = $rec->{server};
- #$server->command("MODE $channel->{name} -o $channel->{ownick}->{nick}");
- #if ($channel->{chanop}) {
- $channel->command("/deop $channel->{ownnick}->{nick}");
- #}
- }
- sub sig_mode_change {
- my ($channel,$nick) = @_;
- #Irssi::print(Dumper($nick));
- #Irssi::print(Dumper($channel));
- # Are there any actions to process?
- # See if we got opped.
- my @deop_array;
- if ($channel->{server}->{nick} eq $nick->{nick} and $nick->{op}) {
- # Ok, we've been opped, or we are opped now, so do whatever we're supposed to do.
- #Irssi::print(Dumper($actions->{$_}));
- # See if this action is too old
- next;
- }
- # Find the server to take action on
- #my $server = Irssi::server_find_chatnet($actions->{$_}->{network});
- my $server = $actions->{$_}->{server};
- # Find the channel to take action on
- my $channel = $server->channel_find($actions->{$_}->{channel});
- # Are we opped on that channel?
- #if ($channel->{chanop}) { # Yes? Take the action against the user.
- take_action($actions->{$_},$server,$channel);
- #}
- #else {
- # Irssi::print("We are not opped on the channel.") if $DEBUG;
- #}
- }
- foreach (@deop_array) {
- deop_us($_);
- }
- }
- else {
- }
- }
- sub try_to_remove_bans {
- $bans_to_remove{$key}{type} = 'teiuq'; #unquiet
- $actions->{$key} = $bans_to_remove{$key};
- get_op($actions->{$key}{server}, $actions->{$key}{channel}) if $defaults{GET_OP};
- }
- }
- }
- # call the try to remove bans function every minute
- Irssi::signal_add_last('nick mode changed','sig_mode_change');
- my ($command,$function);
- Irssi::command_bind($command,$function);
- }
- 1;
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.