Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Perl by Ben Sauvin ( 16 years ago )
use strict;
use warnings;
use Xchat qw(:all);


# I could envision this script being used for multiple overflow channels,
# each with its own things to pester users with.

my %target_overflow = (
 '##linux-overflow' =>
  "You are not in ##linux. Please see the topic or visit us in ##linux-ops. " .
  "The folks in #freenode may also be able to help. " .
  "The ops in here are the only ones in this channel who can see what you say. " .
  "This is an automated message; I am not necessarily awake.",
);

my %lastspoke = ();


register('Overflow Channel User Advisor', '001', 'Advise users unaware they are in overflow channels');
hook_print('Channel Message', \&channel;_message);


sub channel_message
{
 my ($nick,$message) = @{$_[0]};
 my $channel = get_info("channel");
 my $user_info = user_info($nick);
 my $host = user_info->{host};

 return EAT_NONE if !$host;
 $host =~ s/^~//;

 return EAT_NONE if $user_info->{prefix} eq '@';

 if ($target_overflow{$channel})
 {
  my $uid = $nick . "!" . $host;
  my $time = time;
  my $time_lapsed;

  if ($lastspoke{$uid})
  {
   $time_lapsed = $time - $lastspoke{$uid};
  } else {
   $time_lapsed = 99999;
  }

  if ($time_lapsed > 60)
  {
   command("msg $channel " . sprintf("%s: %s", $nick, $target_overflow{$channel}));
  }

  $lastspoke{$uid} = $time;
 }
 return EAT_NONE;
}

 

Revise this Paste

Your Name: Code Language: